Re: REPOST from SQL List: Use of Setof Record Dynamically

Поиск
Список
Период
Сортировка
От Joe Conway
Тема Re: REPOST from SQL List: Use of Setof Record Dynamically
Дата
Msg-id 3FECE463.4080009@joeconway.com
обсуждение исходный текст
Ответ на REPOST from SQL List: Use of Setof Record Dynamically  (A E <cooljoint@yahoo.com>)
Список pgsql-hackers
A E wrote:
> I am attempting to use Setof Record dynamically. I am developing an
> application where I will not know what the end-user is trying to work
> with from a web front end. Thus I will not know before hand the
> structure of the table I am trying to pull the record from.

[code]

> I know that I would execute the procedure with select * from
> retrievecollection as x(x typex, y typey) but how do I do this if I
> don't know which table was passed to the function?

The short answer is there is no way to do what you seem to want to do,
at least not directly.

You might try storing a suitable column definition string ("columndef") 
in the "applicationaliases" table for each referenced table. From your 
web page first do:
  SELECT columndef  FROM applicationaliases  WHERE tablealias = qoute_literal(tablealias);

Alternatively you could dynamically build the columndef based on tablename.

Then use the result to build the second query; something like:
  SELECT *  FROM retrievecollection($tablealias, $crmid, $username)  AS ($columndef);


HTH,

Joe



В списке pgsql-hackers по дате отправления:

Предыдущее
От: David Fetter
Дата:
Сообщение: Re: feature request: \qf datatype
Следующее
От: "Alex J. Avriette"
Дата:
Сообщение: Re: feature request: \qf datatype