C# Oracle Stored Procedure Parameter Order

后端 未结 3 1586
别跟我提以往
别跟我提以往 2021-01-11 10:15

With this

PROCEDURE \"ADD_BOOKMARK_GROUP\" (
  \"NAME\" IN VARCHAR2, 
  \"BOOKMARK_GROUP_ID\" IN NUMBER, 
  \"STAFF_ID\" IN VARCHAR2,
  \"MAX_NO\" IN INT,
          


        
相关标签:
3条回答
  • 2021-01-11 10:44

    Not an answer to the question but you can use 'insert ... returning ... into ' in stead of select bgt_sequence.currval from dual, for example:

    begin
      insert into test (id)
      values(test_seq.nextval)
      returning id into p_id;
    end;
    

    See http://www.adp-gmbh.ch/ora/sql/insert_into_x_returning_y.html

    0 讨论(0)
  • 2021-01-11 10:47

    I'm not an Oracle buff, so I can't verify - but it sounds like they are being passed by position (rather than passed by name). The moral equivelent to:

    EXEC SomeProc 'Foo', 'Bar'
    

    instead of:

    EXEC SomeProc @arg1='Foo', @arg2='Bar'
    

    This isn't hugely uncommon - for years (in the COM days) a lot of my code had to work with a pass-by-position ADODB driver.

    In this case, the name that you give serves only as a local key to lookup the value from the collection collection. You can verify easily by inventing a name:

    cmd.Parameters.Add(new    OracleParameter("BANANA", ...
    cmd.Parameters.Add(new    OracleParameter("GUITAR", ...
    ...
    cmd.Parameters["BANANA"].Value.ToString()
    cmd.Parameters["GUITAR"].Value.ToString()
    

    If the above runs without error, it is passing by position. And it they are passed by position... then simply add them in the right order ;-p And never add new parameters except at the end...

    0 讨论(0)
  • 2021-01-11 10:55

    You can probably set the BindByName parameter on the OracleCommand object. This works for straight SQL queries with parameters, I've not tried it with stored procedures but it would be logical...

    cmd.BindByName = true;
    
    0 讨论(0)
提交回复
热议问题