Re: from string to table...?
От | Richard Huxton |
---|---|
Тема | Re: from string to table...? |
Дата | |
Msg-id | 3ABB0103.FA63B92F@archonet.com обсуждение исходный текст |
Ответ на | from string to table...? (will trillich <will@serensoft.com>) |
Ответы |
Re: from string to table...?
|
Список | pgsql-general |
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
В списке pgsql-general по дате отправления: