Re: Anything akin to an Evaluate Statement in Postgresql?

Поиск
Список
Период
Сортировка
От A E
Тема Re: Anything akin to an Evaluate Statement in Postgresql?
Дата
Msg-id 20040105032623.55190.qmail@web12105.mail.yahoo.com
обсуждение исходный текст
Ответ на Re: Anything akin to an Evaluate Statement in Postgresql?  (Christopher Kings-Lynne <chriskl@familyhealth.com.au>)
Ответы Re: Anything akin to an Evaluate Statement in Postgresql?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Thanks. I searched for it and I found something. It tells me to use the perl module. But Tom Lane mentions using the execute command see(http://archives.postgresql.org/pgsql-general/2001-03/msg01614.php).
 
Since I have no interest in picking up yet another language, I tried this:
 
   qry := ''select * from ''|| trim(realname) ||'' where ''|| trim(searchfield) ||'' like ''''%''|| trim(searchvalue) ||''%'''''';
   arrayval := string_to_array(coltoparammatch(3, talias, insertparams, insertdelimiter), '','');   
   for objectdefinition in execute qry loop
    for i in array_lower(arrayval, 1)..array_upper(arrayval, 1) loop
      qry := ''select into aliasvalue objectdefinition.''|| arrayval[i];
      execute qry;
      RAISE NOTICE ''field = %'', aliasvalue;
    end loop; 
   end loop;
 
I tried to execute a dynamic sql string using the dynamic record column name but I getting this error: ERROR:  syntax error at or near "into" at character 8. Does the execute statement not allow the into keyword into or am I not quoting right?
 
TIA
 
Alex

Christopher Kings-Lynne <chriskl@familyhealth.com.au> wrote:
> Was wondering if there was anything akin to an evaluate statement in
> Postgresql for dynamic strings?

By dint of tricky programming you can a function that can generate and
execute arbitrary strings. I believe there's even an example of this in
the docs.

Chris

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

Предыдущее
От: Mark Feit
Дата:
Сообщение: Re: (Mis?)Behavior of \copy with -f and \i
Следующее
От: Martin Marques
Дата:
Сообщение: Re: time format