Re: select into - Mailing list pgsql-sql

From Mulham freshcode
Subject Re: select into
Date
Msg-id 20061124042134.55885.qmail@web90512.mail.mud.yahoo.com
Whole thread Raw
In response to Re: select into  (Adrian Klaver <aklaver@comcast.net>)
Responses Re: select into
List pgsql-sql
Hello Adrian,<br /><br />Here is my execute string,<br /><br />sql_str1 = 'select * from ' || svc_tbl_name || ' where
uid= ' || sub_id ;<br />execute sql_str1 into svc_data_rec ;<br /><br />svc_data_rec is a RECORD, which is supposed to
bedynamic. If I need to define the structure of the record then there will be no point in using it since I need
somethingto change according the structure the table, which i don't know in advance...<br /><br />Thank you,<br /><br
/>Mustafa...<br/><br /><br /><b><i>Adrian Klaver <aklaver@comcast.net></i></b> wrote:<blockquote class="replbq"
style="border-left:2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"> On Thursday 23 November 2006
09:19am, Mulham freshcode wrote:<br />> Hi,<br />> Thanks very much for all the suggestions. Like Andreas said i
haveto<br />> use EXECUTE to do this. That was my guess too but i was putting the INTO<br />> cluase into the
stringbefore executing it. This is a step forward. The<br />> problem now is getting the into to work with a record.
Amusing a RECORD<br />> 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-assigned record is<br
/>>indeterminate. CONTEXT: PL/pgSQL function "foo" line 130 at execute<br />> statement<br />><br />> I
readin the docs the following, "The INTO clause specifies where the<br />> results of a SELECT command should be
assigned.If a row or variable list<br />> is provided, it must exactly match the structure of the results produced
by<br/>> the SELECT (when a record variable is used, it will configure itself to<br />> match the result's
structureautomatically)." That i take to mean that the<br />> above is ok. But it ain't.<br />><br />> Thanks
againfor your guys help...<br />><br />> "A. Kretschmer"  wrote: am Wed, dem <br />22.11.2006, um 0:28:15 -0800
mailteMulham freshcode folgendes:<br />> > Hi guys,<br />> ><br />> > Am new to sql scripting so this
mightbe a stupid question. Am getting<br />> > an error while trying to do the following<br />> ><br />>
>SELECT INTO svc_data_rec * from svc_tbl_name where 'uid' = sub_id;<br />> ><br />> > where svc_data_rec
isdefined as record and svc_tbl_name is a varchar<br />> > that holds the name of a table and sub_id is another
varchar.the error<br />> > message is<br />><br />> You should rewrite your plpgsql-function. You can't
handlewith<br />> string-vars in this way, you must create a string with your complete sql<br />> and EXECUTE
thisstring.<br />><br />> Read<br />>
http://www.postgresql.org/docs/8.1/interactive/plpgsql-statements.html#PLPG<br/>>SQL-STATEMENTS-EXECUTING-DYN<br
/>><br/>><br />> Andreas<br /><br />My guess is that the error message is correct, the svc_data_rec has not
had<br />any values assigned to it. In other words the EXECUTE statement is not <br />working the way you think it is.
Couldyou post the EXECUTE string?<br /><br />-- <br />Adrian Klaver <br />aklaver@comcast.net<br /></blockquote><br
/><p><hrsize="1" />Want to start your own business? Learn how on <a
href="http://us.rd.yahoo.com/evt=41244/*http://smallbusiness.yahoo.com/r-index">Yahoo!Small Business.</a> 

pgsql-sql by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: select into
Next
From: Tom Lane
Date:
Subject: Re: select into