Oracle “ORA-01008: not all variables bound” Error w/ Parameters

前端 未结 3 1514
渐次进展
渐次进展 2020-12-14 16:01

This is the first time I\'ve dealt with Oracle, and I\'m having a hard time understanding why I\'m receiving this error.

I\'m using Oracle\'s ODT.NET w/ C# with the

3条回答
  •  时光取名叫无心
    2020-12-14 16:03

    It seems daft, but I think when you use the same bind variable twice you have to set it twice:

    cmd.Parameters.Add("VarA", "24");
    cmd.Parameters.Add("VarB", "test");
    cmd.Parameters.Add("VarB", "test");
    cmd.Parameters.Add("VarC", "1234");
    cmd.Parameters.Add("VarC", "1234");
    

    Certainly that's true with Native Dynamic SQL in PL/SQL:

    SQL> begin
      2     execute immediate 'select * from emp where ename=:name and ename=:name'
      3     using 'KING';
      4  end;
      5  /
    begin
    *
    ERROR at line 1:
    ORA-01008: not all variables bound
    
    
    SQL> begin
      2     execute immediate 'select * from emp where ename=:name and ename=:name' 
      3     using 'KING', 'KING';
      4  end;
      5  /
    
    PL/SQL procedure successfully completed.
    

提交回复
热议问题