西西軟件園多重安全檢測(cè)下載網(wǎng)站、值得信賴的軟件下載站!
軟件
軟件
文章
搜索

首頁西西教程數(shù)據(jù)庫教程 → NHibernate儲(chǔ)存過程ORACLE時(shí)提示"ORA-00911: invalid character"

NHibernate儲(chǔ)存過程ORACLE時(shí)提示"ORA-00911: invalid character"

相關(guān)軟件相關(guān)文章發(fā)表評(píng)論 來源:本站整理時(shí)間:2010/12/17 9:36:11字體大。A-A+

作者:佚名點(diǎn)擊:520次評(píng)論:0次標(biāo)簽: ORACLE NHibernate

  • 類型:音頻處理大。1M語言:中文 評(píng)分:5.1
  • 標(biāo)簽:
立即下載

 我的hibernate.cfg.xml

代碼hibernate.cfg.xml
1 <?xml version="1.0" encoding="utf-8"?>
2 <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2" >
3 <session-factory>
4 <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
5 <property name="connection.driver_class"> NHibernate.Driver.OracleDataClientDriver</property>
6 <property name="connection.connection_string">
7 data source=GXLX193;user id=lxmis;password=lxmis
8 </property>
9 <property name="adonet.batch_size">10</property>
10 <property name="connection.release_mode">auto</property>
11 <property name="show_sql">true</property>
12 <property name="use_outer_join">true</property>
13 <property name="dialect"> NHibernate.Dialect.Oracle10gDialect</property>
14 <property name="command_timeout">10</property>
15 <property name="query.substitutions">true 1, false 0, yes 'Y', no 'N'</property>
16 <property name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property>
17 <property name="hbm2ddl.keywords">none</property>
18 <mapping assembly="Model" />
19 </session-factory>
20 </hibernate-configuration>


我的hbm.xml
.hbm.xml代碼
1<?xml version="1.0" encoding="utf-8"?>
2<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Model" namespace="Model">
3 <sql-query name="Dualsa">
4 {Call pro_GetAllA(:k)}
5 </sql-query>
6 <sql-query name="aaa">
7 select a.FID as id,
8 a.PARAM_VALUE as va
9 from T_PARAMS a
10 </sql-query>
11</hibernate-mapping>
12

我的錯(cuò)誤代碼
 
1 class Program
2 {
3 static void Main(string[] args)
4 {
5 ISession _ISeesion = new SessionManager().GetSession();
6 IQuery q = _ISeesion.GetNamedQuery("Dualsa");
7 IList list = q.SetInt32("k", 0).List();
8 }
9 }
錯(cuò)誤信息是:Message="could not execute query\r\n[ {call up_test (:p0,:p1) } ]\r\n Name:pInt - Value:100 Name:pString - Value:hello\r\n[SQL: {call up_test (:p0,:p1) }]"
ORA-00911: invalid character
為了說明我能執(zhí)行其他的,我試了調(diào)用aaa是正常的,可以執(zhí)行有結(jié)果


我的正確代碼

class Program
{
static void Main(string[] args)
{
ISession _ISeesion = new SessionManager().GetSession();
IQuery q = _ISeesion.GetNamedQuery("aaa");
IList list = q.List();//正確有結(jié)果的

}
}


我的儲(chǔ)存過程

1 create or replace procedure pro_GetAllA( my_cursor out sys_refcursor,k int ) as
2 begin
3 open my_cursor for select a.FID as id,
4 a.PARAM_VALUE as va
5 from T_PARAMS a;
6 end pro_GetAllA;

我改用另一種方法了,
<property name="connection.driver_class"> NHibernate.Driver.OracleDataClientDriver</property>
改回原來的OracleClientDriver
去掉Oracle.DataAccess.dll的引用
直接使用

ISession _ISeesion = new SessionManager().GetSession();
IDbCommand _cmd = _ISeesion.Connection.CreateCommand();
_cmd.CommandText = "pro_GetAllA";
_cmd.CommandType = CommandType.StoredProcedure;
System.Data.OracleClient.OracleCommandBuilder.DeriveParameters((System.Data.OracleClient.OracleCommand)_cmd);

IDataReader _IDReader = _cmd.ExecuteReader();
object[] _o = new object[_IDReader.FieldCount];
while (_IDReader.Read())
{
for (int i = 0; i < _IDReader.FieldCount; i++)
_o[i] = _IDReader[i];
}

    相關(guān)評(píng)論

    閱讀本文后您有什么感想? 已有人給出評(píng)價(jià)!

    • 8 喜歡喜歡
    • 3 頂
    • 1 難過難過
    • 5 囧
    • 3 圍觀圍觀
    • 2 無聊無聊

    熱門評(píng)論

    最新評(píng)論

    發(fā)表評(píng)論 查看所有評(píng)論(0)

    昵稱:
    表情: 高興 可 汗 我不要 害羞 好 下下下 送花 屎 親親
    字?jǐn)?shù): 0/500 (您的評(píng)論需要經(jīng)過審核才能顯示)