Thread: Quoting for a Select Into - Please Help

Quoting for a Select Into - Please Help

From
A E
Date:
Hi,
 
Could someone help me with quoting this right?
 
select into aliasvalue ''|| trim(arrayval[i]) ||''  from ''|| trim(realname) ||'' where ''|| trim(searchfield) ||'' like ''''%''|| trim(searchvalue) ||''%'''';
 
The parser does not seem to want to put the value of the variables into the statement.
 
Alex

Re: Quoting for a Select Into - Please Help

From
"ezra epstein"
Date:
Maybe if you could show what the final SELECT statement should look like -- after variable substitution -- that would give a sense of how to quote things.
 
NOTE 1. Regardless, this, of course, needs to be done inside of an EXECUTE statement (assuming pl/pgSQL is the procedure language being used), regular ol' SELECT does not do the dynamic variable substitution this would require.
 
NOTE 2. Another way (that also avoids use of EXECUTE) is to put the values being stored in "arrayval[]", "realname", etc. into a temporary table and join to this (single-row) temp table in the select.... performance may be an issue, but it would work even outside of pl/pgsql.
 
== Ezra Epstein
 
 
Hi,
 
Could someone help me with quoting this right?
 
select into aliasvalue ''|| trim(arrayval[i]) ||''  from ''|| trim(realname) ||'' where ''|| trim(searchfield) ||'' like ''''%''|| trim(searchvalue) ||''%'''';
 
The parser does not seem to want to put the value of the variables into the statement.
 
Alex