2010-01-30 145 views
0

------使用VS2008,ASP.Net與C#,Oracle,NHibernate ---- 我測試了我的存儲過程。它的工作,但不與NHibernate。下面是代碼:NHibernate Oracle存儲過程問題

步驟:

create or replace procedure ThanaDelete (id number) as 
begin 
delete from thana_tbl where thana_code = id; 
end 

映射文件:

<?xml version="1.0" encoding="utf-8" ?> 
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="DataTransfer" namespace="DataTransfer"> 
    <class name="DataTransfer.Models.Thana, DataTransfer" table="THANA_TBL"> 
    <id name="THANA_CODE" column="THANA_CODE" type="Int32" unsaved-value="0"> 
     <generator class="native"> 
     <param name="sequence"> 
      SEQ_TEST 
     </param> 
     </generator> 
    </id> 
    <property name="THANA_NAME" column="THANA_NAME" type="string" not-null="false"/> 
    <property name="DISTRICT_CODE" column="DISTRICT_CODE" type="Int32" not-null="false"/> 
    <property name="USER_ID" column="USER_ID" type="string" not-null="false"/> 
    <property name="TRANSACTION_DATE" column="TRANSACTION_DATE" type="Date" not-null="false"/> 
    <property name="TRANSACTION_TIME" column="TRANSACTION_TIME" type="string" not-null="false"/> 

    <sql-delete>exec THANADELETE ? </sql-delete> 
    </class> 
</hibernate-mapping> 

錯誤:

Message: could not delete: [DataTransfer.Models.Thana#10][SQL: exec THANADELETE ?] 
Source: NHibernate 
Inner Exception 
    System.Data.OracleClient.OracleException 
    Message: ORA-00900: invalid SQL statement 

回答

1

我只是有一個ORA-00900與SQL查詢。重寫你的SQL作爲

begin exec THANADELETE ?; end; 

可能會解決這個問題