NHibernate Oracle stored procedure problem
------Using VS2008, ASP.Net with C#, Oracle, NHibernate---- I have tested my stored procedure. It's working but not with NHibernate. Here are the codes:
Procedure :
create or replace procedure ThanaDelete (id number) as
begin
delete from thana_tbl where thana_code = id;
end
Mapping File:
<?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="TRANS开发者_如何学GoACTION_TIME" type="string" not-null="false"/>
<sql-delete>exec THANADELETE ? </sql-delete>
</class>
</hibernate-mapping>
error:
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
I just had an ORA-00900 with an sql-query. Rewriting your SQL as
begin exec THANADELETE ?; end;
might solve the problem
Try using CALL instead of EXEC.
These tests all use CALL.
http://nhibernate.svn.sourceforge.net/viewvc/nhibernate/trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/Oracle/StoredProcedures.hbm.xml?view=markup
精彩评论