暂无图片
暂无图片
暂无图片
暂无图片
暂无图片
GBase8s 存储过程和触发器测试方法
1416
8页
2次
2020-09-21
5墨值下载
GBase8s
存储过程测试方法
-- '------------------
存储过程
--------------------------------'
--
在交互式
sql
交互式工具中执行,创建表
CREATE TABLE COM_T2 (C1 INT,C2 varchar2(10));
INSERT INTO COM_T2 VALUES(10,'a');
INSERT INTO COM_T2 VALUES(20,'b');
INSERT INTO COM_T2 VALUES(30,'c');
COMMIT;
CREATE TABLE PRO_T3 (C1 INT,C2 VARCHAR2(10));
INSERT INTO PRO_T3 VALUES(10,'a');
INSERT INTO PRO_T3 VALUES(20,'b');
INSERT INTO PRO_T3 VALUES(30,'c');
INSERT INTO PRO_T3 VALUES(40,'d');
COMMIT;
CREATE TABLE PRO_T4 (C1 INT,C2 VARCHAR2(10));
COMMIT;
CREATE TABLE PRO_T5 (C1 INT,C2 VARCHAR2(10));
INSERT INTO PRO_T5 VALUES(10,'a');
INSERT INTO PRO_T5 VALUES(20,'b');
INSERT INTO PRO_T5 VALUES(30,'c');
INSERT INTO PRO_T5 VALUES(40,'d');
COMMIT;
CREATE TABLE PRO_T6 (C1 INT,C2 VARCHAR2(10));
COMMIT;
--
创建存储过程
CREATE OR REPLACE PROCEDURE PRO1(A INT)
IS
STR VARCHAR2(100);
c1t2 int;
c2t2 varchar2(10);
e exception;
BEGIN
DELETE FROM COM_T2;
SELECT c1,c2 INTO c1t2,c2t2 from pro_t3 where c1=a;
if c1t2<30 then
insert into COM_T2 values(c1t2,c2t2);
else
raise e;
end if;
EXCEPTION
when no_data_found then
insert into COM_T2 values(a,'no data');
when e then
raise_application_error(-20101,'found c1 is 40');
END;
/
CREATE OR REPLACE PROCEDURE PRO2(A INT)
IS
STR VARCHAR2(100);
c1t2 int;
c2t2 varchar2(10);
e exception;
BEGIN
DELETE FROM pro_t4;
SELECT c1,c2 INTO c1t2,c2t2 from pro_t3 where c1=a;
if c1t2<30 then
insert into pro_t4 values(c1t2,c2t2);
else
raise e;
end if;
EXCEPTION
when no_data_found then
insert into pro_t4 values(a,'no data');
when e then
raise_application_error(-20101,'found c1 is 40');
END;
/
CREATE OR REPLACE PROCEDURE PRO3(A INT)
IS
STR VARCHAR2(100);
c1t2 int;
c2t2 varchar2(10);
e exception;
BEGIN
DELETE FROM pro_t6;
SELECT c1,c2 INTO c1t2,c2t2 from pro_t5 where c1=a;
if c1t2<30 then
insert into pro_t6 values(c1t2,c2t2);
else
raise e;
end if;
EXCEPTION
when no_data_found then
insert into pro_t6 values(a,'no data');
when e then
raise_application_error(-20101,'found c1 is 40');
END;
/
of 8
5墨值下载
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文档的来源(墨天轮),文档链接,文档作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论

关注
最新上传
暂无内容,敬请期待...
下载排行榜
Top250 周榜 月榜