create or replace procedure test(x in number) is
begin
if x > 0 then
begin
x := 0 - x;
dbms_output.put_line(x);
end;
end if;
if x = 0 then
begin
x := 1;
dbms_output.put_line(x);
end;
end if;
end test;declare
x integer ;
begin
X := 3;
test(X);
dbms_output.put_line(x);
end;
begin
if x > 0 then
begin
x := 0 - x;
dbms_output.put_line(x);
end;
end if;
if x = 0 then
begin
x := 1;
dbms_output.put_line(x);
end;
end if;
end test;declare
x integer ;
begin
X := 3;
test(X);
dbms_output.put_line(x);
end;
我给您说说细节:
我用的是PL/SQL,打开的是文件下面的(测试窗口),这些程序就是这个窗口中的所有代码了,按您的意思是把 (x in number) 替换成 (x in out number)就应该能正常运行是吗?麻烦您了,我是新手,您见谅啊!
1、新建sql窗口,执行如下代码,以创建存储过程test:
create or replace procedure test(x in out number) is
begin
if x > 0 then
begin
x := 0 - x;
dbms_output.put_line(x);
end;
end if;
if x = 0 then
begin
x := 1;
dbms_output.put_line(x);
end;
end if;
end test;2、新建sql窗口,执行如下代码,查看输出:
declare
x integer ;
begin
X := 3;
test(X);
dbms_output.put_line(x);
end;
begin
if x > 0 then
begin
x := 0 - x;
dbms_output.put_line(x);
end;
end if;
if x = 0 then
begin
x := 1;
dbms_output.put_line(x);
end;
end if;
end test;
--上面是创建存储过程的 随便找一个SQL window执行--下面的代码是执行存储过程的,你随便找一个sql window或者test window执行。--不能粘到一起执行。
declare
x integer ;
begin
X := 3;
test(X);
dbms_output.put_line(x);
end;