Execure oracle procedure using PetaPoco

157 views Asked by At

We use Oracle DB. We need to execute the following stored procedure, which has worked when we executed it directly on DB.

exec DWHCR.LANCEKING_PA.FORWARD_WF_PR(12345, 'WF_T02', 'Test123'); 

We tried the following method from PetaPoc to execute the procedure:

            _dataBase.ExecuteNonQueryProc("DWHCR.LANCEKING_PA.FORWARD_WF_PR", new
            {
                P_ID_WF = 12345,
                P_RECEIVER = "WF_T02",
                P_COMMENT = "Test123"
            });

Unfortunately, we are getting the error

Oracle.ManagedDataAccess.Client.OracleException
ORA-01008: Nicht allen Variablen ist ein Wert zugeordnet
   at OracleInternal.ServiceObjects.OracleConnectionImpl.VerifyExecution(Int32& cursorId, Boolean bThrowArrayBindRelatedErrors, SqlStatementType sqlStatementType, Int32 arrayBindCount, OracleException& exceptionForArrayBindDML, Boolean& hasMoreRowsInDB, Boolean bFirstIterationDone)

Could anyone please help us?

2

There are 2 answers

0
kk-dev11 On BEST ANSWER

We needed put "begin" and "end" between the statement as shown below:

 _dataBase.Execute("begin DWHCR.LANCEKING_PA.FORWARD_WF_PR (1234, 'WF_T02', 'Test123'); end;");
0
Eduardo Molteni On

You need to pass the parameters:

_dataBase.ExecuteNonQueryProc(";DWHCR.LANCEKING_PA.FORWARD_WF_PR( @P_ID_WF, @P_RECEIVER, @P_COMMENT)", 
new {
            P_ID_WF = 12345,
            P_RECEIVER = "WF_T02",
            P_COMMENT = "Test123"
        });

or

_dataBase.ExecuteNonQueryProc(";DWHCR.LANCEKING_PA.FORWARD_WF_PR( @0, @1, @2)", 12345,"WF_T02", "Test123");

Not sure if you need the parenthesis between the parameters