Dear Gurus.
I created a procedure and this procedure takes parameters and then makes and alter table DDL on the database.
But when I write
exec pp(table_name1,field,table_name2);
Gives error.
ERROR at line 1:
ORA-06550: line 1, column 10:
PLS-00357: Table,View Or Sequence reference 'K_CT_IST_KTP_SYF_ALN' not allowed in this context
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
Here is the source 
 
create or replace procedure pp(table_name in varchar2,field in  
 varchar2,pk_table_name in varchar2) is 
 cursor_name  INTEGER;
 rows_processed  INTEGER;
 begin
temp:='ALTER TABLE '||table_name||' ADD CONSTRAINT '||table_name||'_FK'||' FOREIGN KEY ('||field||') REFERENCES '|| pk_table_name||'('||field||')';
dbms_output.put_line(temp);
dbms_sql.parse(cursor_name, 'ALTER TABLE '||table_name||' ADD CONSTRAINT '||table_name||'_FK'||' FOREIGN KEY ('||field||') REFERENCES '|| pk_table_name||'('||field||')', dbms_sql.native);
rows_processed := dbms_sql.execute(cursor_name);
dbms_sql.close_cursor(cursor_name);
end;

Reply via email to