使用call在sqlplus中调用procedure和funtion!call 不可以使用在plsql中,只能在sqlplus中使用。

SQL> create or replace procedure proc_test
2 is
3 v_count number;
4 begin
5 select count(*) into v_count from tt;
6 dbms_output.put_line(v_count);
7 end;
8 /

过程已创建。

SQL> set serveroutput on
SQL> call proc_test();
2

调用完成。

--使用call调用过程时即使过程没有参数依然要加上括号

SQL> exec proc_test;
2

PL/SQL 过程已成功完成。
SQL> create or replace function fun_test(p_a int , p_b int)
2 return number
3 is
4 begin
5 return p_a/p_b;
6 end fun_test;
7 /

函数已创建。

SQL> select fun_test(10,2) from dual;

FUN_TEST(10,2)
--------------
5

SQL> call fun_test(10,2) ;
call fun_test(10,2)
*
第 1 行出现错误:
ORA-06576: 不是有效的函数或过程名

--由于函数有返回值,所以要使用绑定变量来接收。
SQL> variable i number;
SQL> call fun_test(10,2) into :i;

调用完成。

SQL> print i;

I
----------
5

相关文章:

  • 2021-11-15
  • 2021-10-03
  • 2021-08-14
  • 2021-04-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-03
猜你喜欢
  • 2021-05-21
  • 2021-09-07
  • 2022-12-23
  • 2021-12-09
  • 2021-07-06
  • 2022-12-23
  • 2021-10-12
相关资源
相似解决方案