Re: select into - Mailing list pgsql-sql

From Tom Lane
Subject Re: select into
Date
Msg-id 1138.1164212062@sss.pgh.pa.us
Whole thread Raw
In response to select into  (Mulham freshcode <mulhamcode@yahoo.com>)
List pgsql-sql
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


pgsql-sql by date:

Previous
From: Andreas Kretschmer
Date:
Subject: Re: select into
Next
From: Richard Broersma Jr
Date:
Subject: Re: select into