pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Fuhr <mike@fuhr.org>
To: hu js <hu.bill2005@hotmail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: How to declare cursor if tablename is a variable?
Date: Fri, 23 Mar 2007 05:47:03 -0600
Message-ID: <20070323114703.GA76452@winnie.fuhr.org> (raw)
In-Reply-To: <BAY102-F214FE93AE1D197BF1DBE61F0740@phx.gbl>
References: <20070320034111.GA23662@winnie.fuhr.org>
	<BAY102-F214FE93AE1D197BF1DBE61F0740@phx.gbl>

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-...
http://www.postgresql.org/docs/8.2/interactive/functions-string.html#FUNCTIONS-STRING-OTHER

-- 
Michael Fuhr



view thread (4+ messages)

Message-ID: <20070323114703.GA76452@winnie.fuhr.org>
Permalink:  ../20070323114703.GA76452@winnie.fuhr.org/
Also on:    postgresql.org/message-id/20070323114703.GA76452@winnie.fuhr.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: mike@fuhr.org, hu.bill2005@hotmail.com
  Subject: Re: How to declare cursor if tablename is a variable?
  In-Reply-To: <20070323114703.GA76452@winnie.fuhr.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox