失效链接处理 |
GBase8s 存储过程和触发器测试方法 PDF 下载
本站整理下载:
提取码:0wb5
相关截图:
主要内容:
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;
/
|