Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id B5DCC9FA372 for ; Fri, 24 Nov 2006 11:28:00 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 03888-04 for ; Fri, 24 Nov 2006 15:27:53 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from rwcrmhc14.comcast.net (rwcrmhc14.comcast.net [216.148.227.154]) by postgresql.org (Postfix) with ESMTP id CC56C9F93A1 for ; Fri, 24 Nov 2006 11:27:52 -0400 (AST) Received: from [192.168.0.9] (c-24-17-161-80.hsd1.wa.comcast.net[24.17.161.80]) by comcast.net (rwcrmhc14) with ESMTP id <20061124152750m14001evsre>; Fri, 24 Nov 2006 15:27:50 +0000 From: Adrian Klaver Reply-To: aklaver@comcast.net To: pgsql-sql@postgresql.org Subject: Re: select into Date: Fri, 24 Nov 2006 07:30:33 -0800 User-Agent: KMail/1.6.2 Cc: Mulham freshcode , Tom Lane References: <20061124065413.38499.qmail@web90514.mail.mud.yahoo.com> In-Reply-To: <20061124065413.38499.qmail@web90514.mail.mud.yahoo.com> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <200611240730.33837.aklaver@comcast.net> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.556 tagged_above=0 required=5 tests=BAYES_00, DNS_FROM_RFC_POST, DNS_FROM_RFC_WHOIS X-Spam-Level: X-Archive-Number: 200611/248 X-Sequence-Number: 26900 On Thursday 23 November 2006 10:54 pm, Mulham freshcode wrote: > 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 > I am trying to sort this out. Are you trying to find the data for a single field from each table, or for some set of fields?. If you are looking for data from a single field couldn't you dispense with the RECORD variable and just build a query of the form SELECT col_name FROM tbl_name. If you want to go through a set of fields then it would involve some nested loops. -- Adrian Klaver aklaver@comcast.net