oracle课堂收录-存储过程

创建或重新定义存储过程

SQL> create or replace procedure sample_proc is
  2  begin
  3     dbms_output.put_line('Hello WOrld');
  4  end sample_proc;
  5  /

过程已创建。

在匿名程序块中调用刚创建的存储过程,可以直接在BEGIN-END部分使用过程名调用存储过程SAMPLE_PROC。

SQL> set serverout on
SQL> begin
  2  sample_proc;
  3  end;
  4  /
Hello WOrld

PL/SQL 过程已成功完成。

在SQL*PLUS中使用EXECUTE或者EXEC调用存储过程

SQL> execute sample_proc;
Hello WOrld

PL/SQL 过程已成功完成。

SQL> exec sample_proc;
Hello WOrld

PL/SQL 过程已成功完成。

如果在创建的过程中出现了错误 可以使用 SHOW ERRORS命令显示创建时产生的错误。

SQL> create or replace procedure sample_proc is
  2  begin
  3  dbms_output.put_line(hello world);
  4  end sample_proc;
  5  /

警告: 创建的过程带有编译错误。

SQL> show errors;
PROCEDURE SAMPLE_PROC 出现错误:

LINE/COL ERROR
-------- -----------------------------------------------------------------
3/28     PLS-00103: 出现符号 "WORLD"在需要下列之一时:
         . ( ) , * @ % & | = - + <
         / > at in is mod remainder not range rem => ..
         <an exponent (**)> <> or != or ~= >= <= <> and or like LIKE2_
         LIKE4_ LIKEC_ as between from using || multiset member
         SUBMULTISET_
         符号 "." 被替换为 "WORLD" 后继续。
产生该错误的原因是输出语句中省略了表示字符的引号,是系统误认为该字符为变量。















  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值