如下函数,但调用该函数时m_status总是返回OCI_INVALID_HANDLE,我确认m_svchp,m_errhp是有效的,在执行时,这些函数OCIStmtExecute、OCITransCommit、OCITransRollback中都能正常执行。OCISvcCtx *m_svchp;
OCIError *m_errhp;
sb4 m_status;
bool COCILink::transstart()
{
m_status = OCITransStart(m_svchp,
m_errhp, 
60,
OCI_TRANS_NEW);
if ( OCI_SUCCESS != m_status )
{
return false;
}
return true;
}
哪位能否告知是怎么回事。

解决方案 »

  1.   

    把参数OCI_TRANS_NEW 改为 OCI_TRANS_RESUME 试试。
      

  2.   

    luodx1021,你好,我用OCI_TRANS_RESUME试过了,还是不能正常执行。
      

  3.   

    我今天认真在看了一下oci文档,发现要加入如下代码,但是XID类型不知道哪里定义的。
    XID gxid;
    gxid.formatID = 1000; /* format id = 1000 */
    gxid.gtrid_length = 3; /* gtrid = 123 */
    gxid.data[0] = 1; gxid.data[1] = 2; gxid.data[2] = 3;
    gxid.bqual_length = 1; /* bqual = 1 */
    gxid.data[3] = 1;
    OCIAttrSet((dvoid *)txnhp1, OCI_HTYPE_TRANS, (dvoid *)&gxid, sizeof(XID),
    OCI_ATTR_XID, errhp);
      

  4.   

    oracle网站上有这么一段话,你看看可能有点帮助:
    http://www.oracle86.com/ora_doc/appdev.111/b28419/d_xa.htm?jdfwkey=zu16c#BABJDGGHDBMS_XA_XID Object Type
    The PL/SQL XA interface allows the PL/SQL application to define a global transaction branch id (XID) and associate/disassociate the current session with the transaction branch. XID is defined as a PL/SQL object type.See Also:For more information, see "Distributed Transaction Processing: The XA Specification" in the public XA Standard.
    SyntaxTYPE DBMS_XA_XID IS OBJECT(
      formatid      NUMBER,
      gtrid         RAW(64),
      bqual         RAW(64),
      constructor function DBMS_XA_XID(
           gtrid     IN   NUMBER)
        RETURN SELF AS RESULT,
      constructor function DBMS_XA_XID (
           gtrid     IN   RAW, 
           bqual     IN   RAW)
        RETURN SELF AS RESULT,
      constructor function DBMS_XA_XID(
           formatid  IN   NUMBER,
           gtrid     IN   RAW,
           bqual     IN   RAW DEFAULT HEXTORAW('00000000000000000000000000000001'))
        RETURN SELF AS RESULT)