Re: select into

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Mulham freshcode <mulhamcode(at)yahoo(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: select into
Date: 2006-11-22 16:14:22
Message-ID: 1138.1164212062@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Mulham freshcode <mulhamcode(at)yahoo(dot)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

In response to

  • select into at 2006-11-22 08:28:15 from Mulham freshcode

Browse pgsql-sql by date

  From Date Subject
Next Message Richard Broersma Jr 2006-11-22 17:26:57 Re: select into
Previous Message Andreas Kretschmer 2006-11-22 16:07:33 Re: select into