前端之家收集整理的这篇文章主要介绍了
ORACLE PL/SQL基本语法 触发器 存储过程,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
declare
n_age number:=12;
o_name varchar(20);
pi constant number:=1.32;
begin
delete from jmonster;
insert into jmonster values(pi,'测试',n_age);
select name into o_name from jmonster where age = n_age;
DBMS_OUTPUT.PUT_LINE(O_NAME);
exception
when NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE('无数据');
end;
SELECT * FROM JOMSTER_VIEW_TEST;
//触发器
create or replace trigger JMONSTER_TRIGGER_TEST
before insert on JMONSTER
for each row
declare
v_cnt integer;
begin
select count(*) into v_cnt from JMONSTER;
dbms_output.put_line('test count:'||to_char(v_cnt));
update JMONSTER set age=100;
end;
INSERT INTo JMONSTER VALUES(1,'123',3);
//存储过程
create or replace
PROCEDURE JMONSTER_PROCEDURE_TEST
( NAME IN VARCHAR2,ID IN NUMBER
) AS
BEGIN
insert into JMONSTER values(321,NAME,ID);
END JMONSTER_PROCEDURE_TEST;
call JMONSTER_PROCEDURE_TEST('12321',1);
原文链接:https://www.f2er.com/oracle/208358.html