Database Administration (MOSC)

MOSC Banner

Passing table name dynamically

edited Nov 21, 2011 5:16AM in Database Administration (MOSC) 3 comments
I'm not able to pass the tab_name dynamically to the following procedure. The objective is to get the table_name from the cursor, pass that name within the loop , get the value of WEEK_ID, do some calculation and exit.

*******************

declare

 tab_name varchar2(30) := NULL ;

 cursor c1 is select name
 from dba_PART_KEY_COLUMNS
 where owner='CARSDM'
 and object_type='TABLE'
 and column_name='WEEK_ID';

begin
open c1;
loop
 fetch c1 into tab_name;
 exit when c1%notfound;
 tab_name := 'CARSDM.'||tab_name ;
 select max(WEEK_ID) into YR_WEEK from tab_name ;

 dbms_output.put_line(' table name  '|| tab_name ); 

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center