Oracle数据库创建存储过程
发布时间:2020-12-12 15:01:42 所属栏目:百科 来源:网络整理
导读:1.最简单的存储过程 SQL create procedure sample_proc is 2 begin 3 null; 4 end sample_proc; 5 / 2.如果我们重复建立存储过程 SQL create procedure sample_proc is 2 begin 3 dbms_output.put_line('Hello World'); 4 end sample_proc; 5 / 会出现以下状
1.最简单的存储过程
SQL> create procedure sample_proc is 2 begin 3 null; 4 end sample_proc; 5 / 2.如果我们重复建立存储过程
SQL> create procedure sample_proc is 2 begin 3 dbms_output.put_line('Hello World'); 4 end sample_proc; 5 /
create procedure sample_proc is
3.避免存储过程,使用OF REPLACE
SQL> create or replace procedure sample_proc is 2 begin 3 dbms_output.put_line('Hello World'); 4 end sample_proc; 5 / 4.在PL/SQL程序块中调用该存储过程
SQL> set serveroutput on SQL> begin 2 sample_proc; 3 end; 4 / 结果: Hello World
5.使用EXECUTE在PL/SQL程序块中调用该存储过程
SQL> execute sample_proc 结果: Hello World
6.使用EXECUTE简写exec在PL/SQL程序块中调用该存储过程
exec sample_proc;
SQL> create or replace procedure sample_proc is 2 begin 3 dbms_output.put_line(Hello World); 4 end sample_proc; 5 / 结果: 警告: 创建的过程带有编译错误。 SQL> show error PROCEDURE SAMPLE_PROC 出现错误: LINE/COL ERROR -------- ----------------------------------------------------------------- 3/30 PLS-00103: 出现符号 "WORLD"在需要下列之一时: . ( ),* @ % & = - + < / > at in is mod remainder not rem => <an exponent (**)> <> or != or ~= >= <= <> and or like like2 like4 likec as between from using || multiset member submultiset 符号 "." 被替换为 "WORLD" 后继续。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |