Procedure with cursor and variables [message #4584] |
Fri, 27 December 2002 13:18 |
Rusty
Messages: 2 Registered: December 2002
|
Junior Member |
|
|
Hi,
I need to create a Procedure that will accept two variables, the table name and a specific column. I am trying to have the procedure copy from the variable column in the variable table, to a consistent column.
The purpose is to modify a number of tables which already contain a new column, and copy from an existing column into the new column for each of these tables.
Here's what I have, which doesn't work. Can someone tell me how to do this correctly?
Thanks,
Rusty
COMMON_IDENTIFIER is the name of the new column exisitng in all the tables.
CREATE PROCEDURE FILL_CI_COLUMN (INPUT_TABLE VARCHAR2, COLUMN_NAME VARCHAR2)IS
CURSOR FILL_CURSOR (INPUT_TABLE VARCHAR2, COLUMN_NAME VARCHAR2) IS
Select COLUMN_NAME from INPUT_TABLE FOR UPDATE OF INPUT_TABLE.COMMON_IDENTIFIER;
BEGIN
FOR CURRENT_ROW IN FILL_CURSOR LOOP
COPY_FROM := CURRENT_ROW.COLUMN_NAME;
UPDATE INPUT_TABLE
SET INPUT_TABLE.COMMON_IDENTIFIER = COPY_FROM
WHERE CURRENT OF FILL_CURSOR;
END LOOP;
END FILL_CI_COLUMN;
|
|
|
|
|