Re: Do pl/sql record fields allow "indirect referencing"?

From: Eric Givler <egivler_at_flash.net>
Date: Fri, 08 Dec 2000 17:38:51 GMT
Message-ID: <L09Y5.3076$bw.238015_at_news.flash.net>


Why not create the before snapshot in a record group? You could build the column names dynamically there.

<mrbozo_at_my-deja.com> wrote in message news:90qfrs$8cm$1_at_nnrp1.deja.com...
> Hi all,
>
> I'm working on a Forms application and I would like to avoid making
> explicit references to column names wherever possible.
>
> In one of the blocks I want to store the inital value of each of its
> database items into a record variable (my_record). I have the names of
> the columns (retrieved from user_tab_columns) stored in a pl/sql table
> (column_names). Ideally I would like to be able to do something like:
> --==================================================================
> declare
> type column_names_type is table of user_tab_columns.column_name%type
> index by binary_integer;
> column_names column_names_type;
> my_record my_table%rowtype;
> i integer;
> begin
> for x in (
> select column_name
> from user_tab_columns
> where table_name = 'MY_TABLE')
> loop
> i:= i + 1;
> column_names(i) := x.column_name;
>
> -- *** I need help with the left-hand side of the next statement!!
> -- (The way I have done it won't work)
> my_record(column_names(i)) := name_in(:system.current_block || '.'
> || column_names(i));
> -- ***
> end loop;
> end;
> --==================================================================
> instead of hard-coding:
> my_record.code := :my_block.code;
> my_record.desc := :my_block.desc;
> my_record.status := :my_block.status;
> etc.
>
> Using the name_in() function I can refer to block items indirectly. I
> need something similar for the fields of a pl/sql record. Perhaps I can
> even get the column names from the declaration of my_record (somehow?)
> instead of having to go to user_tab_columns. Any suggestions greatly
> appreciated.
>
> Thanks in advance,
>
> :)
>
> MB
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
Received on Fri Dec 08 2000 - 18:38:51 CET

Original text of this message