pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Mulham freshcode <mulhamcode@yahoo.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: select into
Date: Wed, 22 Nov 2006 11:14:22 -0500
Message-ID: <1138.1164212062@sss.pgh.pa.us> (raw)
In-Reply-To: <20061122082816.26958.qmail@web90504.mail.mud.yahoo.com>
References: <20061122082816.26958.qmail@web90504.mail.mud.yahoo.com>

Mulham freshcode <mulhamcode@yahoo.com> writes:
>    Am new to sql scripting so this might be a stupid question. Am getting an error while trying to do the following
> SELECT INTO svc_data_rec * from svc_tbl_name where 'uid' = sub_id;

The error message shows that this is getting rewritten into

>    QUERY:  SELECT  * from  $1  where 'uid' =  $2

so the problem is that you are using svc_tbl_name as a plpgsql variable,
and plpgsql is not bright enough to realize that it shouldn't substitute
the variable value at this particular spot in the query.  You need to
change the variable name to something that won't conflict.  In general,
don't use plpgsql variables that are named the same as any SQL tables or
columns you need to mention in the function.

			regards, tom lane



view thread (43+ messages)  latest in thread

Message-ID: <1138.1164212062@sss.pgh.pa.us>
Permalink:  ../1138.1164212062@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/1138.1164212062@sss.pgh.pa.us

 · 

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: tgl@sss.pgh.pa.us, mulhamcode@yahoo.com
  Subject: Re: select into
  In-Reply-To: <1138.1164212062@sss.pgh.pa.us>

* 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