Re: Getting results from a dynamic query in PL/pgSQL
| От | Johann Uhrmann |
|---|---|
| Тема | Re: Getting results from a dynamic query in PL/pgSQL |
| Дата | |
| Msg-id | 3E37EF2D.6080907@xpecto.com обсуждение исходный текст |
| Ответ на | Re: Getting results from a dynamic query in PL/pgSQL ("Patrick Fiche" <patrick.fiche@aqsacom.com>) |
| Список | pgsql-general |
Patrick Fiche wrote: > I'm not sure I really understood what you want... > > Here is perhaps what you need... > > > CREATE TABLE t1 > ( > col1 text > ); > > create or replace function foo(text) returns text as ' > DECLARE > colname ALIAS FOR $1; > sqlquery text; > result text; > BEGIN > sqlquery := ''INSERT INTO t1 (col1 ) SELECT '' || colname || '' from > toto''; > EXECUTE( sqlquery ); > > SELECT INTO result col1 FROM t1; > DELETE FROM t1; > RETURN result; > END; > ' language 'plpgsql'; Thank You Patrick. I consider Your solution as a workaround as it uses a temporary table. As far as I know, PL/Tcl directly supports dynamic table names - but now I have difficulties to specify a literal value which should not be treated as column name but as varchar-value. Please see my other post for details. Regards, Hans
В списке pgsql-general по дате отправления: