我想检验我的A表中有多少条记录,超过5条后,就把A中的数据给B表,然后删除A表,现在出现错误,
想请教高手为什么错了??????
create or replace procedure Pro_Tab_A_B
is
tab_a_count integer;
begin
select count(pid) tab_a_count from A;
if tab_a_count > 5 then
create or replace table B as select * from A;
delete from A;
end if;
end;
/
想请教高手为什么错了??????
create or replace procedure Pro_Tab_A_B
is
tab_a_count integer;
begin
select count(pid) tab_a_count from A;
if tab_a_count > 5 then
create or replace table B as select * from A;
delete from A;
end if;
end;
/
is
tab_a_count number;
begin
select count(pid) into tab_a_count from A;
if tab_a_count > 5 then
insert into B as select * from A;
delete from A;
commit;
end if;
end;
/
EXECUTE IMMEDIATE 'create table B as select * from A';试试
这个存储过程很难么????
is
tab_a_count number;
begin
select count(pid) into tab_a_count from scott.A;
if tab_a_count > 5 then
insert into scott.B select * from scott.A;
delete from scott.A;
commit;
end if;
end;
/
另外,你两个表结构是否一样?如果不一样,这样是错的。
你是想drop table A还是删除里面数据?还有,
select count(pid) tab_a_count from A;改成 select count(*) into tab_a_count from A;
试试看
is
tab_a_count number;
begin
select count(pid) into tab_a_count from scott.A;
if tab_a_count > 5 then
insert into scott.B select * from scott.A;
delete from scott.A;
commit;
end if;
end;
/