IN主要用于传入参数,可以是变量,常量,表达式,在子程序内部不能改变其值.
复制代码 代码如下:
DECLARE
n NUMBER := 10;
PROCEDURE do_something (
n1 IN NUMBER) IS
BEGIN
dbms_output.put_line(n1); -- prints 10
--n1:=20; --illegal assignment.
END;
BEGIN
do_something(n);
do_something(20);
END;
复制代码 代码如下:
DECLARE
n NUMBER := 10;
PROCEDURE do_something (
n1 OUT NUMBER) IS
BEGIN
dbms_output.put_line('before assign: ' || n1); -- prints none <<1>>
n1:=20;
dbms_output.put_line('before return: ' || n); -- prints 10 <<2>>
END;
BEGIN
do_something(n);
dbms_output.put_line('after return: ' || n); -- prints 20
END;
复制代码 代码如下:
DECLARE
n NUMBER := 10;
PROCEDURE do_something (
n1 IN NUMBER,
n2 IN OUT NUMBER,
n3 IN OUT NOCOPY NUMBER) IS
BEGIN
n2 := 20;
dbms_output.put_line(n1); -- prints 10<<1>>
n3 := 30;
dbms_output.put_line(n1); -- prints 30 <<2>>
END;
BEGIN
do_something(n, n, n);
dbms_output.put_line(n); -- prints 20 <<3>>
END;
新闻热点
疑难解答