From: | Michael Fuhr <mike(at)fuhr(dot)org> |
---|---|
To: | hu js <hu(dot)bill2005(at)hotmail(dot)com> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: How to declare cursor if tablename is a variable? |
Date: | 2007-03-23 11:47:03 |
Message-ID: | 20070323114703.GA76452@winnie.fuhr.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Wed, Mar 21, 2007 at 02:20:21AM +0000, hu js wrote:
> But I get into another trouble.See following program.
As I requested before, please post questions to the mailing list
so others can participate in and learn from the discussion.
> "query_xypos" is ok. but "query_xydata" is not ok.
> I find "objectid" not quoted corrected.It seems relevant with variable
> varchar and "'".
[...]
> query_xypos text := 'SELECT mrc_xy_position FROM ' ||
> quote_ident(tablename);
> query_xydata text := 'SELECT x,y FROM ' || tablename || ' where
> mrc_xy_position = ' || quote_ident(objectid) ;
See the documentation to learn more about quote_ident() and
quote_literal() and when to use each:
http://www.postgresql.org/docs/8.2/interactive/plpgsql-statements.html#PLPGSQL-STATEMENTS-EXECUTING-DYN
http://www.postgresql.org/docs/8.2/interactive/functions-string.html#FUNCTIONS-STRING-OTHER
--
Michael Fuhr
From | Date | Subject | |
---|---|---|---|
Next Message | Wilkinson, Jim | 2007-03-26 13:36:10 | Selecting different views from a Boolean expression |
Previous Message | Ezequias R. da Rocha | 2007-03-22 20:26:37 | Re: Dummy question |