C# Oracle Stored Procedure Parameter Order

后端 未结 3 1608
别跟我提以往
别跟我提以往 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: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...

提交回复
热议问题