ORACLE插入语句问题:插入一条记录前如果表中已经有了该数据,则不插入,反之则插入,这个该如何做? 5
1个回答
展开全部
declare
V_COUNT NUMBER(1);
begin
SELECT COUNT(1) INTO V_COUNT FROM PRT_COMPANY_REPORT WHERE NREPORT = '2' AND SCOMPANY = '2' AND SPERIOD='201509';
if V_COUNT = 0 then
insert into PRT_COMPANY_REPORT (NID,NREPORT,SCOMPANY,SPERIOD,SMONTH,NLOCKED,SYEAR,SCREATEUSER,SLOCKEDUSER,SLOCKEDTIME,SCREATTIME)
values (2,'2','2','201509','09',0,2015,'super','super',sysdate,sysdate);
end if;
end;
/
commit;
V_COUNT NUMBER(1);
begin
SELECT COUNT(1) INTO V_COUNT FROM PRT_COMPANY_REPORT WHERE NREPORT = '2' AND SCOMPANY = '2' AND SPERIOD='201509';
if V_COUNT = 0 then
insert into PRT_COMPANY_REPORT (NID,NREPORT,SCOMPANY,SPERIOD,SMONTH,NLOCKED,SYEAR,SCREATEUSER,SLOCKEDUSER,SLOCKEDTIME,SCREATTIME)
values (2,'2','2','201509','09',0,2015,'super','super',sysdate,sysdate);
end if;
end;
/
commit;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询