will trillich wrote:
> 
> let's say you have the name of a table in a string.
> 
>         'mytable'
> 
> you also have field names, such as
> 
>         'lookupfield' 'valuefield'
> 
> which would be assembled like this
> 
>         select valuefield from mytable where lookupfield = '?'
> 
> is there a way to write sql/plpgsql that'll take a varchar
> argument (table and field names) and be able to turn it into the
> appropriate query?

You can use the "EXECUTE" statement in plpgsql (v7.1) to dynamically
build a query. The catch is you can't return rows from a function. You
could use it to build a view and then query that.

Probably easiest to do in the application layer though.

- Richard Huxton

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to [EMAIL PROTECTED] so that your
message can get through to the mailing list cleanly

Reply via email to