From: Adrian Klaver <aklaver@comcast.net>
To: pgsql-sql@postgresql.org
Cc: Mulham freshcode <mulhamcode@yahoo.com>
Subject: Re: select into
Date: Sun, 26 Nov 2006 14:45:57 -0800
Message-ID: <200611261445.57554.aklaver@comcast.net> (raw)
In-Reply-To: <20061125041743.60657.qmail@web90513.mail.mud.yahoo.com>
References: <20061125041743.60657.qmail@web90513.mail.mud.yahoo.com>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: aklaver@comcast.net, mulhamcode@yahoo.com
Subject: Re: select into
In-Reply-To: <200611261445.57554.aklaver@comcast.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox