Bind Variables in DBMS_SQL - PL/SQL GURU NEEDED [message #38423] |
Wed, 17 April 2002 06:59 |
Tony
Messages: 190 Registered: June 2001
|
Senior Member |
|
|
I need a PL/SQL guru to tell me why this procedure is not working..All I want to do is to select the indexes that have more than 3 leaf levels and rebuild them using dynamic SQL. Thank you for your time in advance..
CREATE OR REPLACE PROCEDURE INDEX_REBUILD
IS
first_cursor integer;
second_cursor integer;
index_name_var VARCHAR2(100);
ret integer;
begin
first_cursor:=DBMS_SQL.OPEN_CURSOR;
DBMS_SQL.PARSE(first_cursor,'select index_name from user_indexes where blevel>=3',DBMS_SQL.native);
DBMS_SQL.DEFINE_COLUMN(first_cursor, 1, index_name_var, 100);
ret:=DBMS_SQL.EXECUTE(first_cursor);
second_cursor:=DBMS_SQL.OPEN_CURSOR;
DBMS_SQL.PARSE(second_cursor,'alter index :index_name_bind rebuild online',DBMS_SQL.native);
LOOP
IF DBMS_SQL.FETCH_ROWS(first_cursor)>0 THEN
DBMS_SQL.COLUMN_VALUE(first_cursor, 1, index_name_var);
DBMS_SQL.BIND_VARIABLE(second_cursor, ':index_name_bind', index_name_var);
ret:=DBMS_SQL.EXECUTE(second_cursor);
ELSE
EXIT;
END IF;
END LOOP;
DBMS_SQL.CLOSE_CURSOR(first_cursor);
DBMS_SQL.CLOSE_CURSOR(second_cursor);
END;
|
|
|
|
|