oracle - Create a table using plsql -
issues: while executing query throws following error ora-01422: exact fetch returns more requested number of rows ora-06512: @ line 5 01422. 00000 - "exact fetch returns more requested number of row
other issue trying primary key columns @ 1 place creating separate sql line other column in same primary key column.
declare v_create varchar2(10000); v_alter varchar2(10000); v_index varchar2(10000); begin select 'create table owner_new.' ||table_name ||' select * ' ||owner ||'.' ||table_name ||';', 'alter table owner_new.' ||table_name ||' add (time timestamp not null default systimestamp, action varchar2(10) not null default ''i'');', 'create index ' ||cc.owner ||'.' ||cc.constraint_name ||' on ' ||cc.owner ||'.' ||cc.table_name ||'(' ||cc.column_name ||' asc ' ||')' ||';' v_create, v_alter, v_index all_tables, all_cons_columns cc, all_constraints pk cc.owner = pk.owner , cc.constraint_name = pk.constraint_name , pk.constraint_type = 'p' , cc.owner = owner , owner in ('old_owner', ) execute immediate v_create; execute immediate v_alter; execute immediate v_index; end;
you trying select returns multiple rows 3 sqls variables. not going work.
create cursors query , execute immediate in loop
Comments
Post a Comment