Re: select into - Mailing list pgsql-sql
From | Mulham freshcode |
---|---|
Subject | Re: select into |
Date | |
Msg-id | 20061123171909.89660.qmail@web90510.mail.mud.yahoo.com Whole thread Raw |
In response to | Re: select into ("A. Kretschmer" <andreas.kretschmer@schollglas.com>) |
Responses |
Re: select into
|
List | pgsql-sql |
Hi,<br /> Thanks very much for all the suggestions. Like Andreas said i have to use EXECUTE to do this. That was my guesstoo but i was putting the INTO cluase into the string before executing it. This is a step forward. The problem now isgetting the into to work with a record. Am using a RECORD variable after declaring it in the INTO clause. pg is complaining<br /><br /> ERROR: record "svc_data_rec" is not assigned yet<br /> DETAIL: The tuple structure of a not-yet-assignedrecord is indeterminate.<br /> CONTEXT: PL/pgSQL function "foo" line 130 at execute statement<br /><br/> I read in the docs the following, "The INTO clause specifies where the results of a SELECT command should be assigned.If a row or variable list is provided, it must exactly match the structure of the results produced by the SELECT(when a record variable is used, it will configure itself to match the result's structure automatically)." That i taketo mean that the above is ok. But it ain't.<br /><br />Thanks again for your guys help...<br /><br /><br /><b><i>"A.Kretschmer" <andreas.kretschmer@schollglas.com></i></b> wrote:<blockquote class="replbq" style="border-left:2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"> am Wed, dem 22.11.2006, um 0:28:15-0800 mailte Mulham freshcode folgendes:<br />> Hi guys,<br />> <br />> Am new to sql scripting so this mightbe a stupid question. Am getting an<br />> error while trying to do the following<br />> <br />> SELECT INTOsvc_data_rec * from svc_tbl_name where 'uid' = sub_id;<br />> <br />> where svc_data_rec is defined as record andsvc_tbl_name is a varchar that<br />> holds the name of a table and sub_id is another varchar. the error message is<br/><br />You should rewrite your plpgsql-function. You can't handle with<br />string-vars in this way, you must createa string with your complete sql<br />and EXECUTE this string.<br /><br />Read<br />http://www.postgresql.org/docs/8.1/interactive/plpgsql-statements.html#PLPGSQL-STATEMENTS-EXECUTING-DYN<br/><br /><br />Andreas<br/>-- <br />Andreas Kretschmer<br />Kontakt: Heynitz: 035242/47215, D1: 0160/7141639 (mehr: -> Header)<br />GnuPG-ID:0x3FFF606C, privat 0x7F4584DA http://wwwkeys.de.pgp.net<br /><br />---------------------------(end of broadcast)---------------------------<br/>TIP 1: if posting/reading through Usenet, please send an appropriate<br /> subscribe-nomailcommand to majordomo@postgresql.org so that your<br /> message can get through to the mailing list cleanly<br/></blockquote><br /><p><hr size="1" />Access over 1 million songs - <a href="http://pa.yahoo.com/*http://us.rd.yahoo.com/evt=36035/*http://music.yahoo.com/unlimited/">Yahoo!Music Unlimited.</a>