mSQLBase API                               Klaus Thiele (kth@oblib.teuto.de)
----------------------------------------------------------------------------

This is the function reference of the currently supported functions.
(I hope you have the original book from Gupta available)

The functions are not implemented in every detail, but they may work 
in the most cases.

----------------------------------------------------------------------------



sqlbnd - BiNd Data by name

   SQLTAPI sqlbnd( cur, bnp, bnl, dap, dal, sca, pdt );

   SQLTCUR   cur	/* Cursor handle			*/
   SQLTBNP   bnp	/* Name of bind variable		*/
   SQLTBNL   bnl	/* Length of bind variable		*/
   SQLTDAP   dap	/* Bind data buffer			*/
   SQLTDAL   dal	/* Bind data length			*/
   SQLTSCA   sca	/* Scale of packed decimal data		*/
   SQLTPDT   pdt	/* Bind program data type		*/

Description
   This function associates an alphanumeric bind variable (such as
   :comments) for a column with a variable defined in the program.

   This function is called after sqlcom and before sqlexe.

Not used:
   sca



sqlbnn - BiNd data by Number

   SQLTAPI sqlbnn( cur, bnn, dap, dal, sca, pdt );

   SQLTCUR   cur	/* Cursor handle			*/
   SQLTBNN   bnn	/* Bind variable number			*/
   SQLTDAP   dap	/* Bind data buffer			*/
   SQLTDAL   dal	/* Bind data length			*/
   SQLTSCA   sca	/* Scale of packed decimal data		*/
   SQLTPDT   pdt	/* Bind program data type		*/

Description
   This function associates a numeric bind variable (such as :3) for a column
   with a variable defined in the program.

   This function is called after sqlcom and before sqlexe.

Not used:
   sca



sqlcbv - Clear Bind Variables

   SQLTAPI sqlcbv( cur );

   SQLTCUR   cur	/* Cursor handle			*/

Description
   This function clears all information stored for bind variables for a
   cursor.



sqlcex - Compile and EXecute

   SQLTAPI sqlcex( cur, dap, dal );

   SQLTCUR   cur	/* Cursor handle			*/
   SQLTDAP   dap	/* Command buffer			*/
   SQLTDAL   dal	/* Length of SQL command		*/

Description
   This function takes a SQL command as input, generates the compiled
   version of the command, and executes it. No data is bound.

   This function uses a SQL command that contains no bind variables and
   that is executed only once such as data definition and data control
   commands (CREATE, DROP) and data manipulation commands which meet 
   the above criteria.



sqlcmt - CoMmiT

   SQLTAPI sqlcmt( cur );

   SQLTCUR   cur	/* Cursor handle			*/

Description
   This function commits a database transaction and starts a new
   transaction.
   This function destroys all compiled commands for all cursors
   connected to the database.

Note:
   COMMIT is not supported by mSQL. This function only destroys all
   compiled commands.



sqlcnc - CoNnect Cursor

   SQLTAPI sqlcnc( curp, dbnamp, dbnaml, host );

   SQLTCUR PTR curp	/* Cursor handle			*/
   SQLTDAP     dbnamp	/* Connect string			*/
   SQLTDAL     dbnaml	/* Connect string length		*/
   SQLTDAP     host	/* Name of host				*/

Description
   This function connects a database.

   This function can connect to a new database or connect a new cursor to
   the current database.

Extra parameter:
   host - Name of the host to be contacted (see msqlConnect)



sqlcnr - Connect with No Recovery

   SQLTAPI sqlcnr( curp, dbnamp, dbnaml, host );

   SQLTCUR PTR curp	/* Cursor handle			*/
   SQLTDAP     dbnamp	/* Connect string			*/
   SQLTDAL     dbnaml	/* Connect string length		*/
   SQLTDAP     host	/* Name of host				*/

Description
   This function connects a database with recovery (transaction logging)
   turned off.

Note:
   same as sqlcnc.

Extra parameter:
   host - Name of the host to be contacted (see msqlConnect)



sqlcom - COMpile a SQL command

   SQLTAPI sqlcom( cur, cmdp, cmdl );

   SQLTCUR   cur	/* Cursor handle			*/
   SQLTDAP   cmdp	/* SQL command				*/
   SQLTDAL   cmdl	/* Length of SQL command		*/

Description
   This function compiles a SQL command.
   No data is bound.
   After a SQL command has been compiled, it can be executed.



sqlcrs - Close ReStriction and Result Set mode

   SQLTAPI sqlcrs( cur, rsp, rsl );

   SQLTCUR   cur	/* Cursor handle			*/
   SQLTDAP   rsp	/* Result set name			*/
   SQLTDAP   rsl	/* Result set name length               */

Description
   This function turns off both result set mode and restriction mode.

Not used:
   rsp, rsl



sqlcty - Command TYpe

   SQLTAPI sqlcty( cur, cty );

   SQLTCUR     cur	/* Cursor handle			*/
   SQLTCTY PTR rsp	/* Variable				*/

Description
   This function returns the command type of the SQL command
   currently being processed. The command type is set after
   sqlcom or sqlexe.
   


sqldbn - Database Names

   SQLTAPI sqldbn( serverid, buffer, length )

   SQLTDAP serverid	/* Server identifier			*/
   SQLTDAP buffer	/* Directory list			*/
   SQLTDAL length	/* Buffer length			*/

Description
   This function returns a list of the databases on the specified
   server.

   serverid
   A pointer to a null-terminated string that contains the name of
   the server. Specifiy a null server name to get a directory of
   local databases.

   buffer
   A pointer to the variable where this function returns the database
   names. Each name is null-terminated. The end of the list is marked
   by an extra null-terminator.

   length
   The length of the area pointed to by buffer.



sqldbt - Database Tables

   SQLTAPI sqldbt( cur, buffer, length )

   SQLTCUR cur		/* Cursor handle			*/
   SQLTDAP buffer	/* Table list				*/
   SQLTDAL length	/* Buffer length			*/

Description
   This function returns a list of the tables of the database to
   which the cursor was connected.

   buffer
   A pointer to the variable where this function returns the database
   names. Each name is null-terminated. The end of the list is marked
   by an extra null-terminator.

   length
   The length of the area pointed to by buffer.

Note:
   NOT a SQLBase function, but nice to have.




sqldes - DEScribe items in a SELECT list

   SQLTAPI sqldsc( cur, slc, ddt, ddl, chp, chlp, prep, scap );

   SQLTCUR     cur	/* Cursor handle			*/
   SQLTSLC     slc	/* Select column number			*/
   SQLTDDT PTR ddt	/* Database data type			*/
   SQLTDDL PTR ddl	/* Database data length			*/
   SQLTCHP     chp	/* Column heading buffer		*/
   SQLTCHL     chlp	/* Column heading length		*/
   SQLTPRE PTR prep	/* Numeric precision			*/
   SQLTSCA PTR scap	/* Numeric scale			*/

Description
   This function returns database data type and length for a column in a
   SELECT list.

Not used:
   prep, scap



sqldis - DISconnect from cursor

   SQLTAPI sqldis( cur );

   SQLTCUR   cur	/* Cursor handle			*/

Description
   This function disconnects the cursor.



sqldon - DONe

   SQLTAPI sqldon( )

Description
   This function does a rollback and disconnects all open cursors.



sqldsc - DeSCribe items in a SELECT command

   SQLTAPI sqldsc( cur, slc, edt, edl, chp, chlp, prep, scap );

   SQLTCUR     cur	/* Cursor handle			*/
   SQLTSLC     slc	/* Select column number			*/
   SQLTDDT PTR edt	/* External data type			*/
   SQLTDDL PTR edl	/* External data length			*/
   SQLTCHP     chp	/* Column heading buffer		*/
   SQLTCHL     chlp	/* Column heading length		*/
   SQLTPRE PTR prep	/* Numeric precision			*/
   SQLTSCA PTR scap	/* Numeric scale			*/

Description
   This function returns external data type and length for a column in a
   SELECT list.

Not used:
   prep, scap



sqlepo - Error POsition

   SQLTAPI sqlepo( cur, epo );

   SQLTCUR     cur	/* Cursor handle			*/
   SQLTEPO PTR epo	/* Error position			*/

Description
   This function returns the error position in the SQL command now being
   processed by the specified cursor.

Note:
   This function always return 0 as error position :-|



sqlerr - ERRor message

   SQLTAPI sqlerr( error, msg );

   SQLTCUR   error	/* Error code				*/
   SQLTDAP   msg	/* Message text				*/

Description
   This function returns the text of the error message associated with the
   error code.

   Each C/API function returns a code. You can retrieve the most recent
   code with the sqlrcd function.



sqlexe - EXEcute a SQL command

   SQLTAPI sqlexe( cur );

   SQLTCUR   cur	/* Cursor handle			*/

Description
   This function executes a previously compiled command.

   The command executed can be one compiled earlier in the current
   application.

   If the command contains bind variables, data must bound before
   execution.



sqlfet - FETch next row from result

   SQLTAPI sqlfet( cur );

   SQLTCUR   cur	/* Cursor handle			*/

Description
   This function fetches the next row resulting from a query. A successful
   sqlexe or sqlcex must come before this function. This function returns an
   end of fetch value (1) when there are no more rows to fetch.



sqlget - GET parameter

   SQLTAPI sqlget( cur, parm, pbuf, len );

   SQLTCUR     cur	/* Cursor handle			*/
   SQLTPTY     parm	/* Parameter type			*/
   SQLTDAP     pbuf	/* Information buffer			*/
   SQLTDAL PTR len	/* Information length			*/

Description
   This function retrieves individual database parameters

Note:
   Parm SQLPNIE returns the value of the "Null Indicator Error",
   Parm SQLPBRN returns SQLBSQB - "Database SQLBase" - in pbuf.
   Requesting other parm's does not change pbuf/len.

Not used:
   len



sqlnbv - # of Bind Variables

   SQLTAPI sqlnbv( cur, nbv );

   SQLTCUR     cur	/* Cursor handle			*/
   SQLTNBV PTR nbv	/* Number of bind variables		*/

Description
   This function returns the number of bind variables in the current SQL
   command being processed for the specified cursor. The number of bind
   variables is set after compile.



sqlnrr - # of Rows in Result Set

   SQLTAPI sqlnrr( cur, rcountp );

   SQLTCUR     cur	/* Cursor handle			*/
   SQLTROW PTR rcountp	/* Number of rows			*/

Description
   This function retrieves the number of rows in a result set.
   (only available in result set mode)



sqlnsi - # of Select Items

   SQLTAPI sqlnsi( cur, nsi );

   SQLTCUR     cur	/* Cursor handle			*/
   SQLTNSI PTR nsi	/* Number of SELECT items		*/

Description
   This function returns the number of items in the SELECT list of a SQL
   command now being processed by the specified cursor. The number of
   SELECT items is set after sqlcom or sqlcex.



sqlprs - Position in Result Set

   SQLTAPI sqlprs( cur, row );

   SQLTCUR   cur	/* Cursor handle			*/
   SQLTROW   row	/* Row number wanted			*/

Description
   When in result set mode, this function sets a row position in the
   current result set. A later sqlfet returns the row at the position
   indicated by row. The first row is row zero.



sqlrbf - Roll BacK Flag

   SQLTAPI sqlrbf( cur, rbk );

   SQLTCUR     cur	/* Cursor handle			*/
   SQLTRBF PTR cur	/* Roll Back Flag			*/

Description
   This function returns the system rollback flag for the current transaktion.

Note:
   This function always return 0 in rbk.



sqlrbk - RollBacK

   SQLTAPI sqlrbk( cur );

   SQLTCUR   cur	/* Cursor handle			*/

Description
   This function rolls back the database to the state it was at the
   completion of the last implicit or explicit COMMIT.
   This function destroys all compiled commands for all cursors that 
   the program has connected to the database.

Note:
   ROLLBACK is not supported by mSQL. This function only destroys all
   compiled commands.



sqlrcd - Return CoDe

   SQLTAPI sqlrcd( cur, rcd );

   SQLTCUR     cur	/* Cursor handle			*/
   SQLTRCD PTR rcd	/* Return code				*/

Description
   This function gets the return code for the most recent C/API function.
   The same code is also returned directly from the function call.

   Call the sqlerr function to get the text associated with the return
   code.



sqlrow - number of ROWs

   SQLTAPI sqlrow( cur, row );

   SQLTCUR     cur	/* Cursor handle			*/
   SQLTROW PTR row	/* Variable				*/

Description
   This function gets the number of rows affectes by the most recent
   UPDATE, DELETE, INSERT or sqlfet. This function is most useful for
   counting the number of rows affected by an UPDATE or DELETE.

Note:
   Only a dummy-function, it returns always 0 :-|



sqlset - SET parameter

   SQLTAPI sqlset( cur, parm, pbuf, len );

   SQLTCUR   cur	/* Cursor handle			*/
   SQLTPTY   parm	/* Parameter type			*/
   SQLTDAP   pbuf	/* Pointer to value			*/
   SQLTDAL   len	/* Length of value			*/

Description
   This function sets a database parameter.

Note:
   only SQLPNIE "Null Indicator Error" can be set.

Not used:
   len



sqlsil - Set Isolation Level

   SQLTAPI sqlsil( cur, isol );

   SQLTCUR   cur	/* Cursor handle			*/
   SQLTCUR   isol	/* Parameter type			*/

Description
   This function sets the isolation level at which the application will
   operate in a multi-user environment.

Note:
   Only a dummy-function.

Not used:
   isol



sqlspr - StoP Restriction modes

   SQLTAPI sqlspr( cur );

   SQLTCUR     cur	/* Cursor handle			*/

Description
   This function turns off restriction mode.



sqlsrs - Start Restriction Set and Result Set modes

   SQLTAPI sqlsrs( cur );

   SQLTCUR     cur	/* Cursor handle			*/

Description
   This function starts restriction mode and result set mode.

Note:
   In result set mode sqlnrr and sqlprs can be use.



sqlssb - Set SELECT Buffer

   SQLTAPI sqlssb( cur, slc, pdt, pbp, pdl, sca, cvl, pfc);

   SQLTCUR     cur	/* Cursor handle			*/
   SQLTSLC     slc	/* Column number			*/
   SQLTPDT     pdt	/* Program data type			*/
   SQLTDAP     pbp	/* Program buffer			*/
   SQLTPDL     pdl	/* Program buffer length		*/
   SQLTSCA     sca	/* Scale of packed decimal data		*/
   SQLTCDL PTR cvl	/* Current value length			*/
   SQLTFSC PTR pfc	/* Fetch status code			*/

Description
   This function sets up buffers that receive data from a sqlfet. This function
   associates an item in the SELECT list with a data buffer where the data is
   fetched.

   This function tells the system where to put fetched data, the size of the
   receiving area, and the application program data type.


Not used:
   sca



sqlxdp - eXtended convert Date to Picture

Note:
   Makes just a strncpy from Ip to Op.



sqlxpd - eXtended convert Picture to Date

Note:
   Makes just a strncpy from Ip to Op and sets olp to strlen(op).

