ORA-01453 SET TRANSACTION must be first statement of transactionCause: A transaction was not processed properly because the SET TRANSACTION statement was not the first statement.Action: Commit or roll back the current transaction before using the statement SET TRANSACTION.

解决方案 »

  1.   

    conn.Open(); 
    OracleTransaction trans = conn.BeginTransaction(IsolationLevel.ReadCommitted);
    try
    {
        for( int i = 0; i < inSQL.Length; i++ )
        {
    SQLRowIndex = i;
    DBErrorSQL  = inSQL[i];
    if ( inSQL[ i ].CompareTo( "" ) > 0 )
             {
        OracleCommand OracleCommand = new OracleCommand();
        OracleCommand.Connection = conn;
        OracleCommand.Transaction = trans;     OracleCommand.CommandText = inSQL[i];     OracleCommand.ExecuteNonQuery();
    }
        }
        trans.Commit();
        rtn = true;
    }
    catch( Exception e )
    .......
    --写的好.出现错误我想可能与你传递的sql有关系.
      

  2.   

    哈哈,我同样在今天遇到了这个问题,把存储过程中的 SET TRANSACTION ...删除,只留下begincommit;exception
      when others then
       ....
    end;
    这样就好了!
      

  3.   

    zhpsam109(孤寂无边) :谢谢回复。现在问题是没有使用存储过程,这个事务是通过ado.net来实现的。
      

  4.   

    在open之前建立transaction
    应该是这样:

    OracleConnection conn = new OracleConnection( inConnString );
    OracleTransaction trans = conn.BeginTransaction(IsolationLevel.ReadCommitted);
    try
    {}

      

  5.   

    hanychun(HANHAN) :
    谢谢!
    为什么要在open之前创建 transaction?