Sophie

Sophie

distrib > Fedora > 14 > x86_64 > media > updates > by-pkgid > 71d40963b505df4524269198e237b3e3 > files > 1006

virtuoso-opensource-doc-6.1.4-2.fc14.noarch.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
 <head profile="http://internetalchemy.org/2003/02/profile">
  <link rel="foaf" type="application/rdf+xml" title="FOAF" href="http://www.openlinksw.com/dataspace/uda/about.rdf" />
  <link rel="schema.dc" href="http://purl.org/dc/elements/1.1/" />
  <meta name="dc.title" content="20. Using Virtuoso with Tuxedo" />
  <meta name="dc.subject" content="20. Using Virtuoso with Tuxedo" />
  <meta name="dc.creator" content="OpenLink Software Documentation Team ;&#10;" />
  <meta name="dc.copyright" content="OpenLink Software, 1999 - 2009" />
  <link rel="top" href="index.html" title="OpenLink Virtuoso Universal Server: Documentation" />
  <link rel="search" href="/doc/adv_search.vspx" title="Search OpenLink Virtuoso Universal Server: Documentation" />
  <link rel="parent" href="xa.html" title="Chapter Contents" />
  <link rel="prev" href="xaClients.html" title="Clients" />
  <link rel="next" href="contents.html" title="Contents" />
  <link rel="shortcut icon" href="../images/misc/favicon.ico" type="image/x-icon" />
  <link rel="stylesheet" type="text/css" href="doc.css" />
  <link rel="stylesheet" type="text/css" href="/doc/translation.css" />
  <title>20. Using Virtuoso with Tuxedo</title>
  <meta http-equiv="Content-Type" content="text/xhtml; charset=UTF-8" />
  <meta name="author" content="OpenLink Software Documentation Team ;&#10;" />
  <meta name="copyright" content="OpenLink Software, 1999 - 2009" />
  <meta name="keywords" content="" />
  <meta name="GENERATOR" content="OpenLink XSLT Team" />
 </head>
 <body>
  <div id="header">
    <a name="xaServExample" />
    <img src="../images/misc/logo.jpg" alt="" />
    <h1>20. Using Virtuoso with Tuxedo</h1>
  </div>
  <div id="navbartop">
   <div>
      <a class="link" href="xa.html">Chapter Contents</a> | <a class="link" href="xaClients.html" title="Clients">Prev</a> | <a class="link" href="appendixa.html" title="Appendix">Next</a>
   </div>
  </div>
  <div id="currenttoc">
   <form method="post" action="/doc/adv_search.vspx">
    <div class="search">Keyword Search: <br />
        <input type="text" name="q" /> <input type="submit" name="go" value="Go" />
    </div>
   </form>
   <div>
      <a href="http://www.openlinksw.com/">www.openlinksw.com</a>
   </div>
   <div>
      <a href="http://docs.openlinksw.com/">docs.openlinksw.com</a>
   </div>
    <br />
   <div>
      <a href="index.html">Book Home</a>
   </div>
    <br />
   <div>
      <a href="contents.html">Contents</a>
   </div>
   <div>
      <a href="preface.html">Preface</a>
   </div>
    <br />
   <div class="selected">
      <a href="xa.html">Using Virtuoso with Tuxedo</a>
   </div>
    <br />
   <div>
      <a href="xaBuildTMS.html">Building the Transaction Manager Server</a>
   </div>
   <div>
      <a href="xaUBBconf.html">Configuration</a>
   </div>
   <div>
      <a href="xaServices.html">Services</a>
   </div>
   <div>
      <a href="xaClients.html">Clients</a>
   </div>
   <div class="selected">
      <a href="xaServExample.html">Service example</a>
   </div>
    <br />
  </div>
  <div id="text">
	<a name="xaServExample" />
    <h2>20.5. Service example</h2>
<div>
      <pre class="programlisting">#include &lt;stdio.h&gt;
#include &lt;time.h&gt;


#include &lt;xa.h&gt;
#include &lt;atmi.h&gt;
#include &lt;userlog.h&gt;

#include &quot;vql_client.h&quot;

#include &lt;libudbc.h&gt;
#ifndef SQL_SUCCEEDED
#define SQL_SUCCEEDED(rc) (((rc)&amp;(~1))==0)
#endif

#define MAXNAME SQL_MAX_DSN_LENGTH

int sql_exec (HDBC hdbc, char* text);


/* VirtRM test service */
int
tpsvrinit(int argc, char *argv[])
{
  if (tpopen () == -1)
    {
      userlog (&quot;tpsrvinit: could not open RM, %s\n&quot;, tpstrerror (tperrno));
      return -1;
    }
  /* userlog writes to the central TUXEDO message log */
  userlog(&quot;Welcome to the VirtRMtest server&quot;);
  return 0;
}

int
tpsrvdone()
{
  if (tpclose () == -1)
    {
      userlog (&quot;tpsrvinit: could not close RM, %s\n&quot;, tpstrerror (tperrno));
      return -1;
    }
  /* userlog writes to the central TUXEDO message log */
  userlog(&quot;By!! the VirtRMtest server&quot;);
  return 0;
}

static void
DoSQLError (HDBC hdbc, HSTMT hstmt);

#define CHECK_RC(rc) \
	if (!SQL_SUCCEEDED (rc)) { DoSQLError (hdbc, stmt); return -1; };

int sql_exec (HDBC hdbc, char* text)
{
  RETCODE rc;
  HSTMT stmt;

  rc = SQLAllocStmt (hdbc, &amp;stmt);
  CHECK_RC(rc);

  rc = SQLExecDirect (stmt, text, SQL_NTS);
  CHECK_RC(rc);
  
  SQLFreeStmt (stmt, SQL_DROP);
  return 0;
}


void
VRMTEST(TPSVCINFO *rqst)
{
  HDBC hdbc;
  int rc;

  rc = vql_get_connection (&amp;hdbc, VQL_CTX_TYPE);
  if (rc != VQL_SUCCESS)
    {
#ifdef TMS_TRACE
      userlog (&quot;AP[%d]: vql_get_connection error %d\n&quot;, getpid(), rc);
#endif
      goto _fail;
    }
  rc = sql_exec (hdbc, &quot;UPDATE sal set amount = amount + 10 where name = &#39;jfk&#39;&quot;);
  if (rc == -1)
    {
#ifdef TMS_TRACE
      userlog (&quot;AP[%d]: vql_get_connection error %d\n&quot;, getpid(), rc);
#endif
      goto _fail;
    }

  userlog (&quot;AP[%d]: exec sql succ.\n&quot;, getpid());
  
  tpreturn(TPSUCCESS, 0, rqst-&gt;data, 0L, 0);
  return;

 _fail:
  userlog (&quot;FAILED: exec sql.\n&quot;);
  tpreturn(TPFAIL, 0, rqst-&gt;data, 0L, 0);
  return;
}


void
VRMTEST2(TPSVCINFO *rqst)
{
  HDBC hdbc;
  int rc;


  rc = vql_get_connection (&amp;hdbc, VQL_CTX_TYPE);
  if (rc != VQL_SUCCESS)
    goto _fail;

  rc = sql_exec (hdbc, &quot;UPDATE sal set amount = amount - 10 where name = &#39;jfk&#39;&quot;);
  if (rc == -1)
    goto _fail;

  userlog (&quot;AP[%d]: exec sql succ.\n&quot;, getpid());
  
  tpreturn(TPSUCCESS, 0, rqst-&gt;data, 0L, 0);
  return;

 _fail:
  userlog (&quot;AP[%d]: service #2 error %d\n&quot;, getpid(), rc);
  tpreturn(TPFAIL, 0, rqst-&gt;data, 0L, 0);
  return;


  tpreturn(TPSUCCESS, 0, rqst-&gt;data, 0L, 0);
}


#define MSG_BUF_SIZE 300

static void
DoSQLError (HDBC hdbc, HSTMT hstmt)
{
  UCHAR szSqlState[MSG_BUF_SIZE];
  UCHAR szErrorMsg[MSG_BUF_SIZE];

  SQLINTEGER fNativeError = 0;
  SWORD cbErrorMsg = MSG_BUF_SIZE;
  RETCODE rc;
  HENV env;
  
#ifndef TMS_TRACE
  return;
#else
  vql_get_env (&amp;env);

  rc = SQLError (env,
      hdbc,
      hstmt,
      szSqlState, &amp;fNativeError, szErrorMsg, MSG_BUF_SIZE, &amp;cbErrorMsg);

  if (rc != SQL_NO_DATA_FOUND || rc != SQL_ERROR)
    {
      if (fNativeError != 0x1645)	// ignore change database to master context message
	{
	  userlog (&quot;SqlState: %s, fNativeError: %x m=%s\n&quot;, szSqlState,
		   fNativeError, szErrorMsg);
	}
    }
  else
    {
      userlog (&quot;SQLError() failed: %x, NO_DATA_FOUND OR SQL_ERROR\n&quot;, rc);
    }
  return;
#endif
}
</pre>
    </div>
<table border="0" width="90%" id="navbarbottom">
    <tr>
        <td align="left" width="33%">
          <a href="xaClients.html" title="Clients">Previous</a>
          <br />Clients</td>
     <td align="center" width="34%">
          <a href="xa.html">Chapter Contents</a>
     </td>
        <td align="right" width="33%">
          <a href="appendixa.html" title="Appendix">Next</a>
          <br />Contents of Appendix</td>
    </tr>
    </table>
  </div>
  <div id="footer">
    <div>Copyright© 1999 - 2009 OpenLink Software All rights reserved.</div>
   <div id="validation">
    <a href="http://validator.w3.org/check/referer">
        <img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0!" height="31" width="88" />
    </a>
    <a href="http://jigsaw.w3.org/css-validator/">
        <img src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!" height="31" width="88" />
    </a>
   </div>
  </div>
 </body>
</html>