星空网 > 软件开发 > 数据库

sql: Oracle 11g create procedure

CREATE OR REPLACE PROCEDURE proc_Insert_BookKindList (temTypeName nvarchar2,temParent int)ASncount number;begin--SELECT COUNT (*) INTO ncount FROM BookKindList fm1 where EXISTS (SELECT BookKindName from BookKindList fm2 where fm2.BookKindName=temTypeName);--判斷是否存SELECT count(*) INTO ncount FROM BookKindList where BookKindName=temTypeName;if ncount<=0 thenbeginINSERT INTO BookKindList (BookKindName,BookKindParent) VALUES(temTypeName,temParent);commit;end;elsebegin SELECT BookKindID INTO ncount FROM BookKindList where BookKindName=temTypeName; dbms_output.put_line('存在相同的记录,添加不成功!'||ncount);end;end if;Exception   When others then    dbms_output.put_line('存在问题,添加不成功!'||ncount);    Rollback; end proc_Insert_BookKindList;--测试 oracle 11g 涂聚文 20150526exec proc_Insert_BookKindList ('油彩画',3);drop PROCEDURE proc_Insert_BookKindOut;CREATE OR REPLACE PROCEDURE procInsertBookKindOut --添加返回ID(temTypeName nvarchar2,temParent number,temId out number  )ASncount number;reid number;begin--SELECT COUNT (*) INTO ncount FROM BookKindList fm1 where EXISTS (SELECT BookKindName from BookKindList fm2 where fm2.BookKindName=temTypeName);--判斷是否存SELECT count(*) INTO ncount FROM BookKindList where BookKindName=temTypeName;if ncount<=0 thenbeginINSERT INTO BookKindList (BookKindID,BookKindName,BookKindParent) VALUES(BookKindList_SEQ.nextval,temTypeName,temParent);select BookKindList_SEQ.currval into reid from dual;temId:=reid;dbms_output.put_line('添加成功!'||temId);commit;end;elsebegin SELECT BookKindID INTO ncount FROM BookKindList where BookKindName=temTypeName; dbms_output.put_line('存在相同的记录,添加不成功!'||ncount); temId:=0;end;end if;Exception   When others then   begin   dbms_output.put_line('存在问题,添加不成功!'||ncount);   temId:=0;    Rollback;   end;end procInsertBookKindOut;--测试 oracle 11g 涂聚文 20150526declaremid number:=0;nam nvarchar2(100):='黑白画';par number:=3;begin--proc_Insert_BookKindOut(nam in nvarchar2,par in int,mid in out int);procInsertBookKindOut(nam,par ,mid);if mid>0 thendbms_output.put_line('添加成功!输出参数:'||mid);elsedbms_output.put_line('存在相同的记录,添加不成功!输出参数:'||mid);end if;end;

  




原标题:sql: Oracle 11g create procedure

关键词:sql

sql
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

注意:亚马逊广告有这5大常见误区!:https://www.ikjzd.com/articles/98058
亚马逊公开最佳差评处理流程及索评邮件模板!:https://www.ikjzd.com/articles/98059
跨境通、傲基、价之链2018年3季度财报大比拼!:https://www.ikjzd.com/articles/9806
敲黑板!亚马逊ASIN创建政策:https://www.ikjzd.com/articles/98061
赶跟卖越赶越多?黑心服务商损招不断!:https://www.ikjzd.com/articles/98062
亚马逊FBA卖家必须要掌握哪些技巧?:https://www.ikjzd.com/articles/98063
恐怖游轮2002 恐怖游轮2022:https://www.vstour.cn/a/365178.html
时尚电商平台Meesho拟融资3亿美元!:https://www.kjdsnews.com/a/1836524.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流