Home » SQL & PL/SQL » SQL & PL/SQL » Access programatically a record (%rowtype)
Access programatically a record (%rowtype) [message #572071] Wed, 05 December 2012 18:05 Go to next message
fgt.marcelo
Messages: 1
Registered: December 2012
Location: Brasil
Junior Member
Dear friends,

How can I do something like that...
It has to be possivel... Not this way, but somehow..


CREATE OR REPLACE PROCEDURE access_reg_column (reg_user user%ROWTYPE)
IS
v_column_name VARCHAR (50);
BEGIN
V_column_name := 'name';

DBMS_OUTPUT.put_line (reg_user.'v_column_name'); ????

END;


Some ideia?
Re: Access programatically a record (%rowtype) [message #572072 is a reply to message #572071] Wed, 05 December 2012 18:13 Go to previous messageGo to next message
BlackSwan
Messages: 22804
Registered: January 2009
Senior Member
Please read and follow the forum guidelines, to enable us to help you:

http://www.orafaq.com/forum/t/88153/0/


what exactly are you trying to accomplish?

http://docs.oracle.com/cd/E11882_01/appdev.112/e25519/rowtype_attribute.htm#LNPLS01342

[Updated on: Wed, 05 December 2012 18:14]

Report message to a moderator

Re: Access programatically a record (%rowtype) [message #572073 is a reply to message #572071] Wed, 05 December 2012 18:26 Go to previous message
Solomon Yakobson
Messages: 2033
Registered: January 2010
Senior Member
Not possible. Well, just as "art for art's sake" using package and dynamic SQL:

SQL> create or replace
  2    package pkg1
  3      is
  4        g_emp_rec emp%rowtype;
  5        procedure p1(
  6                     p_emp_rec     emp%rowtype,
  7                     p_column_name varchar2
  8                    );
  9  end;
 10  /

Package created.

SQL> create or replace
  2    package body pkg1
  3      is
  4        procedure p1(
  5                     p_emp_rec     emp%rowtype,
  6                     p_column_name varchar2
  7                    )
  8          is
  9          begin
 10              g_emp_rec := p_emp_rec;
 11              execute immediate 'begin dbms_output.put_line(pkg1.g_emp_rec.'
|| p_column_name || '); end;';
 12        end;
 13  end;
 14  /

Package body created.

SQL> set serveroutput on
SQL> declare
  2      v_emp_rec emp%rowtype;
  3  begin
  4      select  *
  5        into  v_emp_rec
  6        from  emp
  7        where ename = 'KING';
  8      pkg1.p1(v_emp_rec,'ename');
  9      pkg1.p1(v_emp_rec,'job');
 10      pkg1.p1(v_emp_rec,'sal');
 11  end;
 12  /
KING
PRESIDENT
5000

PL/SQL procedure successfully completed.

SQL>


SY.
Previous Topic: triggers dropped (unable to restore it)
Next Topic: DEADLOCK FOUND
Goto Forum:
  


Current Time: Tue Sep 23 14:08:19 CDT 2014

Total time taken to generate the page: 0.10208 seconds