n_settx(), n_runtx() - SQL interface

SYNOPSIS

TX  *n_settx(SERVER *se,TX *tx,char *queryformat,...);
int  n_runtx(SERVER *se,TX *tx);


DESCRIPTION
These functions perform SQL statement setup and execution for databases opened with n_opentx(). n_settx() takes a TX pointer from n_opentx(), a printf style format string, and the arguments to fill in that format string with.

The query will be constructed using the format string and arguments, parsed, and prepared for execution. n_settx() will return the same TX passed to it on success. It will return TXPN on error.

n_runtx() will execute the statement prepared with n_settx(). At this point what you said will begin to happen and your callback will be called as appropriate. When this function returns execution is complete and another n_settx() should be performed before running again. It will return zero on error and non-zero on success.


EXAMPLE

SERVER *se;
TX *tx;

   ...
   if((tx=n_opentx())!=TXPN)      /* initialize database connection */
   {
      ...
                                                     /* setup query */
      if(n_settx(se,tx,
                 "select NAME from SYSTABLES where CREATOR!='texis';"
                )!=TXPN)
         n_runtx(se,tx);                           /* execute query */
      ...
                                             /* setup another query */
      if(n_settx(se,tx,
                "select NAME,TYPE from SYSCOLUMNS where TBNAME='image';"
                )!=TXPN)
         n_runtx(se,tx);                         /* execute a query */
      ...
      n_closetx(tx);                   /* close database connection */
   }
   ...


SEE ALSO

n_opentx(), n_gettx()


Copyright © Thunderstone Software     Last updated: Oct 5 2023
Copyright © 2024 Thunderstone Software LLC. All rights reserved.