use of bind variable

后端 未结 3 1674
刺人心
刺人心 2021-01-12 12:24

Can we use a bind variable in oracle inside a procedure or function ?

I\'m trying to update a bind variable inside my procedure. Can I do so in any case?

<         


        
3条回答
  •  清酒与你
    2021-01-12 13:14

    No, you cannot do what you are asking. Bind variables in plsql are handled transparently. You do not explicitly code bind variables unless you are going to use 'execute immediate' to run the code outside of plsql like this:

    declare
       v_bind number := 1;
    begin
       execute immediate 'select * from table where x = :v_bind';
    end;`
    

    The following code uses bind variables as well, but it is handled transparently by plsql:

    declare 
      v_bind number := 1
      y number;
    begin
      select count(*) into y from table where x = v_bind;
    end;
    

提交回复
热议问题