From: | A E <cooljoint(at)yahoo(dot)com> |
---|---|
To: | Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Anything akin to an Evaluate Statement in Postgresql? |
Date: | 2004-01-05 03:26:23 |
Message-ID: | 20040105032623.55190.qmail@web12105.mail.yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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(at)familyhealth(dot)com(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Martin Marques | 2004-01-05 03:50:02 | Re: time format |
Previous Message | Mark Feit | 2004-01-05 02:22:26 | Re: (Mis?)Behavior of \copy with -f and \i |