Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id B0E899FB1DF for ; Sun, 26 Nov 2006 18:42:41 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-new, port 10024) with ESMTP id 00940-08 for ; Sun, 26 Nov 2006 18:42:33 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from rwcrmhc12.comcast.net (rwcrmhc12.comcast.net [216.148.227.152]) by postgresql.org (Postfix) with ESMTP id 5592A9FA430 for ; Sun, 26 Nov 2006 18:42:37 -0400 (AST) Received: from [192.168.0.9] (c-24-17-161-80.hsd1.wa.comcast.net[24.17.161.80]) by comcast.net (rwcrmhc12) with ESMTP id <20061126224235m1200kr0kre>; Sun, 26 Nov 2006 22:42:35 +0000 From: Adrian Klaver Reply-To: aklaver@comcast.net To: pgsql-sql@postgresql.org Subject: Re: select into Date: Sun, 26 Nov 2006 14:45:57 -0800 User-Agent: KMail/1.6.2 Cc: Mulham freshcode References: <20061125041743.60657.qmail@web90513.mail.mud.yahoo.com> In-Reply-To: <20061125041743.60657.qmail@web90513.mail.mud.yahoo.com> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <200611261445.57554.aklaver@comcast.net> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200611/251 X-Sequence-Number: 26903 On Friday 24 November 2006 08:17 pm, Mulham freshcode wrote: > Hi Adrian, > > I have number of similar tables that have different number of fields > (similar in functionality). An in my stored procedure am trying to select a > row from one of these tables (that i don't know in advance, hence the use > of record) and return the data in the form of a table that has > column_name:value pairs. where column name is that from the original table. > I have no problem finding the column names but I don't know how to say > data[column_name] to get the corresponding value. Is there a way to do it > in pgsql? > > here is my code so far > > sql_str1 = 'select * from ' || svc_tbl_name || ' where uid = ' || > sub_id ; > > for svc_data_rec in execute sql_str1 loop > end loop; > > -- get service_user table's column names > for col_name in select column_name > from information_schema.columns > where table_name~svc_tbl_name loop > > raise notice 'Column name:%', col_name.column_name; > raise notice 'Value: %', svc_data_rec[col_name.column_name]; > > end loop; > > Thank you, > > Mustafa ... > I am afraid I can't make it work either. -- Adrian Klaver aklaver@comcast.net