暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

Oracle 为存储过程绑定变量in out参数

ASKTOM 2018-11-28
1059

问题描述

我们可以在oracle存储过程中传递bind变量作为in和out参数吗?

我有一个查询如下

insert into table_na(col1,col2,col3) select parameter1,col_name,parameter2) from table2 where condition?
复制


如何在表格列中传递输入和退出参数 (参数1和参数2)?

在sybase中是可能的,如下所示

insert into table_na(col1,col2,col3) select @parameter1,col_name,@parametr2) from table2 where condition.
复制


请帮我这个查询。非常感谢!

专家解答

我真的不明白你想做什么。

但是,是的,您可以将参数传入一个过程。并在SQL语句中使用它们。如果您使用的是静态SQL,这些都是绑定变量。

create table t (
  c1 int not null, c2 int not null
);

create or replace procedure p ( 
  p1 in out int, p2 in out int 
) as
begin
  insert into t ( c1, c2 ) 
    values ( p1, p2 ); -- p1 & p2 are bind variables
  
  p1 := 2;
  p2 := 2;
end p;
/

declare
  v1 int := 1;
  v2 int := 1;
begin
  p ( v1, v2 );
  dbms_output.put_line ( 'v1 = ' || v1 || '; v2 = ' || v2 );
end;
/

v1 = 2; v2 = 2

select * from t;

C1   C2   
   1    1 
复制

文章转载自ASKTOM,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论