Re: select into

From: Mulham freshcode <mulhamcode(at)yahoo(dot)com>
To: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: select into
Date: 2006-11-23 17:19:09
Message-ID: 20061123171909.89660.qmail@web90510.mail.mud.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi,
Thanks very much for all the suggestions. Like Andreas said i have to use EXECUTE to do this. That was my guess too but i was putting the INTO cluase into the string before executing it. This is a step forward. The problem now is getting the into to work with a record. Am using a RECORD variable after declaring it in the INTO clause. pg is complaining

ERROR: record "svc_data_rec" is not assigned yet
DETAIL: The tuple structure of a not-yet-assigned record is indeterminate.
CONTEXT: PL/pgSQL function "foo" line 130 at execute statement

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 take to mean that the above is ok. But it ain't.

Thanks again for your guys help...

"A. Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com> wrote: am Wed, dem 22.11.2006, um 0:28:15 -0800 mailte Mulham freshcode folgendes:
> Hi guys,
>
> 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;
>
> where svc_data_rec is defined as record and svc_tbl_name is a varchar that
> holds the name of a table and sub_id is another varchar. the error message is

You should rewrite your plpgsql-function. You can't handle with
string-vars in this way, you must create a string with your complete sql
and EXECUTE this string.

Read
http://www.postgresql.org/docs/8.1/interactive/plpgsql-statements.html#PLPGSQL-STATEMENTS-EXECUTING-DYN

Andreas
--
Andreas Kretschmer
Kontakt: Heynitz: 035242/47215, D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID: 0x3FFF606C, privat 0x7F4584DA http://wwwkeys.de.pgp.net

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
message can get through to the mailing list cleanly


---------------------------------
Access over 1 million songs - Yahoo! Music Unlimited.

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Adrian Klaver 2006-11-23 18:35:54 Re: select into
Previous Message lms 2006-11-22 20:54:11 How to check coding