Re: Difficulty passing in an array of values to EXECUTE

From: Nick Rowlands <nick(dot)rowlands(at)scotwebshops(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Difficulty passing in an array of values to EXECUTE
Date: 2006-10-25 12:07:01
Message-ID: 453F5365.6090000@scotwebshops.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

William Leite Araújo wrote:
>
> 2006/10/25, Richard Huxton <dev(at)archonet(dot)com <mailto:dev(at)archonet(dot)com>>:
>
> Nick Rowlands wrote:
> > Hi there,
> >
> > I'm having trouble creating a function using plpgsql. I cannot
> pass the
> > array 'productids' to the ANY construct of the IN EXECUTE SELECT
> > statement. Any ideas on what I'm doing wrong would be most
> appreciated.
> > Here's the function:
>
> > FOR row IN EXECUTE 'SELECT p.id <http://p.id>, sku,
> description, base_price,
> > j.name <http://j.name> AS jname, r.name <http://r.name> AS rname
> > FROM products2 p
> > INNER JOIN jewellery_types j ON j.id <http://j.id> =
> p.jewellery_type
> > INNER JOIN ranges r ON r.id <http://r.id> = p.range_id
>
>
> WHERE p.id <http://p.id> = ANY(
> '|||array_to_string(|productids,',')||') '|| filter_jewellery LOOP
>
>
>
>
> EXECUTE takes a string, so you're giving it the word "productids" not
> the contents of the variable with that name.
>
> You'll need to generate a string containing comma-separated values (or
> the array definition) and use that.
> --
> Richard Huxton
> Archonet Ltd
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 5: don't forget to increase your free space map settings
>
>
>
> --
> William Leite Araújo
Fantastic. Thank you very much.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Hannes Dorbath 2006-10-25 12:21:51 DBI-Link, Oracle, database encoding
Previous Message William Leite Araújo 2006-10-25 11:57:16 Re: Difficulty passing in an array of values to EXECUTE