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');
评论