oracle删除多张表数据, 存储过程

create or replace procedure Pr_delCar(d2_cpkid in d2_car.cpkid%type) is
begin
select t.*, t.rowid from D2_HC t where fkpkid in (d2_cpkid) and hctype='2';

select t.*, t.rowid from D2_KYRETURNCONTENT t where kypkid in (select kypkid from D2_KY t where fkpkid in (d2_cpkid) and kytype='2');

select t.*, t.rowid from D2_MONITOR t where ppkid in (d2_cpkid) and zt='2';

select t.*, t.rowid from D2_PASSCAREXT t where cpkid in (d2_cpkid);

select t.*, t.rowid from D2_KY t where fkpkid in (d2_cpkid) and kytype='2';

select t.*, t.rowid from D2_CAR t where cpkid in (d2_cpkid);
end;
这样写有什么错吗???在oracl里面报错的.
begin里面的内容应该是delete 我为了测试,写的是查询

第1个回答  2012-05-16
报什么错,能把错误贴一下吗
另外注意delete语句和select还是有区别的,delete时只能删除满足条件的行,所以在delete后面不用指定列字段,即
delete D2_HC t where fkpkid in (d2_cpkid) and hctype='2';
第2个回答  2012-05-16
直接用Delete吧,因为在过程体里用select 的时候要用into子句接收查询结果的。本回答被提问者采纳
第3个回答  2012-05-16
where子句中的字段名也要加别名的,即:t.fkpkid t.hctype
相似回答