ページの先頭行へ戻る
Interstage Application Server アプリケーション作成ガイド(データベース連携サービス編)

G.6.3 複数のメソッドをもつアプリケーションの注意事項

  1つのアプリケーションで複数のメソッドを定義し、それらの各メソッドでSQL Serverのリソースと連携する場合、各メソッドで異なるコネクションハンドルを使用してください。
  サーバアプリケーション例を以下に示します。

HDBC hdbc1, hdbc2;
        
        int
        main(){
          SQLAllocConnect(gHenv, &hdbc1); /* method A用 */
          SQLConnect(hdbc1, ...);
        
          SQLAllocConnect(gHenv, &hdbc2); /* method B用 */
          SQLConnect(hdbc2, ...);
        }
        
        methodA(){
          SQLSetConnectOption (hdbc1, SQL_COPT_SS_ENLIST_IN_XA, TRUE);
          SQLAllocStmt(hdbc1, &htmt1);
          SQLExecDirect(htmt1, ...);
        }
        methodB(){
          SQLSetConnectOption (hdbc2, SQL_COPT_SS_ENLIST_IN_XA, TRUE);
          SQLAllocStmt(hdbc2, &htmt1);
          SQLExecDirect(htmt2, ...);
        
        }