2012-10-26 38 views
0

好,我嘗試在C#中執行這個腳本:腳本PLSQL不會在C#中執行,但在Oracle

declare 

    NEW_PAP_OPERATOR_ID number; 

    cursor cu_records_a_traiter is 
    select *  
     from operator_dossier   d, 
      pap_operator_verandering ov, 
      pap_verandering   v 
    where d.operator_id = ov.operator_id 
    and v.cr_info = :v_cr_info; 

begin 

    for rec_cu in cu_records_a_traiter loop 

    /* insert new record */ 

    INSERT INTO BOOD.PAP_OPERATOR 
     (HOOFD_OF_NEVENACTIVITEIT) 
    VALUES 
     (rec_cu.HOOFD_OF_NEVENACTIVITEIT); 

    SELECT BOOD.SEQ_PAP_OPERATOR_ID.CURRVAL 
     into NEW_PAP_OPERATOR_ID 
     FROM dual; 

    /* update with new record*/ 

    UPDATE Bood.Pap_Operator_Verandering 
     SET pap_operator_doel_id = NEW_PAP_OPERATOR_ID, 
      datum_wijziging  = Sysdate, 
      gebruiker_wijziging_id = '-549' 
    WHERE pap_operator_verandering_id = rec_cu.PAP_OPERATOR_VERANDERING_ID; 
    end loop; 
end; 

無異常,但劇本沒有運行。 如果我不用C#執行sql腳本,它就可以工作。 我認爲有一個currval的問題NEW_PAP_OPERATOR_ID 現在我沒有什麼特別的它在c#中。

C#代碼:

try 
{ 
    OracleCommand command = new OracleCommand("myScript", Connection); 

    command.Parameters.Add("v_cr_info", OracleDbType.VarChar, changeRequest, ParameterDirection.Input); 
    command.ExecuteNonQuery(); 

    transaction.Commit(); 
} 
catch (Exception) 
{ 
    transaction.Rollback(); 
    throw; 
} 
finally 
{ 
    Connection.Close(); 
} 

回答

0

你沒有顯示PROC參數,也沒有指定你的命令是PROC

OracleCommand command = new OracleCommand("myScript", Connection); 
command.CommandType = CommandType.StoredProcedure; 
相關問題