您的位置:首页 > 数据库

call 不可以使用在plsql中,只能在sql*plus中使用。

2012-05-15 00:40 239 查看
转载地址 :http://warehouse.itpub.net/post/777/488171

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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: