Home » RDBMS Server » Server Administration » Using variables for record groups
Using variables for record groups [message #370480] Thu, 02 December 1999 08:12 Go to next message
Shane
Messages: 27
Registered: December 1999
Junior Member
Hi
Can anyone figure out why this is not working!!

procedure fud1( l_column_name IN VARCHAR2)
is
cursor cu_getval
IS
select * from mytable;

val_rec cu_getval%rowtype;

l_temp VARCHAR2(100);
begin

for val_rec in cu_getval loop
l_temp := val_rec.l_column_name;
dbms_output.put_line(l_temp);
end loop;

end fud1;

Thanks for the help!!
Re: Using variables for record groups [message #370481 is a reply to message #370480] Thu, 02 December 1999 09:50 Go to previous message
hmg
Messages: 40
Registered: March 1999
Member
Hi,

please look my at my script. I think it's a workaround for your problem.

Bye

connect scott/tiger

create or replace package pk
as
   cursor cur_emp is
      select * from emp;
      
   rec cur_emp%rowtype;
end;
/
show errors

create or replace procedure show_column_values(column_in varchar2)
is
   cursor cur_emp is
      select * from emp;
      
   output   varchar2(2000);
begin
   for rec_emp in cur_emp loop
   
      pk.rec := rec_emp;
      
      declare
         cur   integer;
         dummy number;
         stmt varchar2(2000);  
      begin
         cur := dbms_sql.open_cursor;
         stmt := 'begin :column_value := pk.rec.' || column_in || '; end;';
         dbms_sql.parse(cur, stmt, dbms_sql.native);
         dbms_sql.bind_variable(cur, ':column_value', 'something');
         dummy := dbms_sql.execute(cur);
         dbms_sql.variable_value(cur, ':column_value', output);
         dbms_sql.close_cursor(cur);
      end;
      dbms_output.put_line( output );        
   
   end loop;
end;
/
show errors

set serveroutput on
begin
   show_column_values('empno');
   show_column_values('ename');
   show_column_values('hiredate');
end;
/
 
Previous Topic: Dynamic SQL and Update table question!
Next Topic: CLOB to VARCHAR2
Goto Forum:
  


Current Time: Fri Oct 30 02:40:15 CDT 2020