Received: from localhost (uranus.hub.org [200.46.204.60]) by postgresql.org (Postfix) with ESMTP id 7A3609FB1EC for ; Fri, 24 Nov 2006 03:08:38 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.60]) (amavisd-new, port 10024) with ESMTP id 51903-02-6 for ; Fri, 24 Nov 2006 03:08:34 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from web90514.mail.mud.yahoo.com (web90514.mail.mud.yahoo.com [216.252.100.181]) by postgresql.org (Postfix) with SMTP id E0CDA9FBBBB for ; Fri, 24 Nov 2006 02:54:14 -0400 (AST) Received: (qmail 38501 invoked by uid 60001); 24 Nov 2006 06:54:13 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=OwaNmv3XhiCnPAgqtmcT460CrAcYzrswbnLD52nZbDMv0qPreqLzqLFsaNRZZST3sTdzkEcnfZmyvpsQCFW5m+xb8d48cubZ22Fap6WBR8F+AcvuGUYx8hwiozAUexWOkETTV4r6j+OqyIdPwhkHBpJqskyzTrNpWVEnU1sGCTM= ; Message-ID: <20061124065413.38499.qmail@web90514.mail.mud.yahoo.com> Received: from [219.95.167.205] by web90514.mail.mud.yahoo.com via HTTP; Thu, 23 Nov 2006 22:54:13 PST Date: Thu, 23 Nov 2006 22:54:13 -0800 (PST) From: Mulham freshcode Subject: Re: select into To: Tom Lane Cc: pgsql-sql@postgresql.org In-Reply-To: <28318.1164343519@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-1258307272-1164351253=:38398" Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=1.571 tagged_above=0 required=5 tests=AWL, BAYES_00, DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST, DNS_FROM_RFC_WHOIS, HTML_MESSAGE, RCVD_IN_NJABL_PROXY X-Spam-Level: * X-Archive-Number: 200611/240 X-Sequence-Number: 26892 --0-1258307272-1164351253=:38398 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Hi Tom, Thanks for the help. Am using version 8.0 and it seems like RECORD is not that dynamic still. I tried with the FOR ... IN EXECUTE ... LOOP and it does the trick. But am still finding it hard to move forward with this. I have the name of table field in a varchar variable that i got from information_schema.columns and I have the records variable that stores the contains the data from that table. Usually I'd do something like data_rec.col_name to extract the data from the record but now I don't know the name per se. how can i say something like data_rec[col_name] where col_name is a variable that has the actual column name. I found no examples in the docs that explain this. Can it be done in version 8.0.1? I find variable substitution kind of confusing. I mean why is there no way of saying explicitly replace this variable with its content before executing the statement? Sorry for the long question, and thanks again for the help Mustafa... Tom Lane wrote: Mulham freshcode writes: > execute sql_str1 into svc_data_rec ; > svc_data_rec is a RECORD, which is supposed to be dynamic. This should work --- in PG 8.1 or later. In older versions you'd have to fool around with a FOR ... IN EXECUTE ... loop. regards, tom lane ---------------------------(end of broadcast)--------------------------- TIP 3: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faq --------------------------------- Everyone is raving about the all-new Yahoo! Mail beta. --0-1258307272-1164351253=:38398 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Hi Tom,

Thanks for the help. Am using version 8.0 and it seems like RECORD is not that dynamic still. I tried with the FOR ... IN EXECUTE ... LOOP and it does the trick. But am still finding it hard to move forward with this. I have the name of table field in a varchar variable that i got from information_schema.columns and I have the records variable that stores the  contains the data from that table. Usually I'd do something like data_rec.col_name to extract the data from the record but now I don't know the name per se. how can i say something like data_rec[col_name]  where col_name is a variable that has the actual column name. I found no examples in the docs that explain this. Can it be done in version 8.0.1?

I find variable substitution kind of confusing. I mean why is there no way of saying explicitly replace this variable with its content before executing the statement?

Sorry for the long question,
and thanks again for the help

Mustafa...


Tom Lane <tgl@sss.pgh.pa.us> wrote:
Mulham freshcode writes:
> execute sql_str1 into svc_data_rec ;

> svc_data_rec is a RECORD, which is supposed to be dynamic.

This should work --- in PG 8.1 or later. In older versions you'd have
to fool around with a FOR ... IN EXECUTE ... loop.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq


Everyone is raving about the all-new Yahoo! Mail beta. --0-1258307272-1164351253=:38398--