oracle存儲過程:輸入輸出

--默認爲in
create or replace procedure TestPara(para varchar)
as
begin
  dbms_output.put_line(para);
end;
/
--內部賦值,會報錯
create or replace procedure TestPara2(para varchar)
as
begin
  para := '1234';
  dbms_output.put_line(para);
end;
/

create or replace procedure TestInPara(para in varchar)
as
begin
  dbms_output.put_line(para);
end;
/

--輸入參數不能賦值
create or replace procedure TestInPara2(para in varchar)
as
begin
  para := '1234';
  dbms_output.put_line(para);
end;
/

create or replace procedure TestOutPara(para out varchar)
as
begin
  dbms_output.put_line(para);
end;
/

--輸出內部能夠賦值
create or replace procedure TestOutPara2(para out varchar)
as
begin
  para := '1234';
  dbms_output.put_line(para);
end;
/

create or replace procedure TestInOutPara(para in out varchar)
as
begin
  dbms_output.put_line(para);
end;
/

--輸出內部能夠賦值
create or replace procedure TestInOutPara2(para in out varchar)
as
begin
  para := '1234';
  dbms_output.put_line(para);
end;
/

調用存儲過程:sql

--注意:聲明變量必須指定長度
declare
  inpara varchar(100);
begin
  inpara := ' ';
  TestInOutPara2(inpara);
  dbms_output.put_line(inpara);
end;
/
相關文章
相關標籤/搜索