• No results found

Syntax

#include "sqlbase.h"

SQLTAPI sqlclf (shandle, logfile, startflag) SQLTSVH shandle; /* Server handle */

SQLTDAP logfile; /* Log file name to open */ SQLTFMD startflag; /* Start activity log flag */

Sqlbase SQL Application Programming Interface Reference Page 154 This function opens a new process activity log file for the database server. Use this function to write the messages that appear on the Process Activity server display to a file. This function is useful for multi-user servers.

Instead of using the sqlclf function, you could use the sqlset function and the SQLPALG parameter. To turn on logging, specify a file name and set startflag to 1. To turn off logging, specify a null filename or set startflag to 0.

Note: SQLBase supports filenames up to 256 characters including the terminating null character.

Parameters

shandle

The server handle returned by sqlcsv. logfile

A pointer to the null-terminated string that contains the name of the log file. If null, logging is turned off. startflag

Indicates whether to start or stop writing to the log file:

0 Stop logging

1 Start logging

Return value

If this function returns zero, it was successful. If this function returns a non-zero value, it was unsuccessful.

Example

void main() { SQLTSVH shandle; SQLTDAP srvname; char *password; char *logfile; int startflag;

srvname = "SERVER1"; password = 0; startflag = 1; logfile = "ACTIVITY.LOG";

/* CONNECT TO THE SERVER */

if (rcd = sqlcsv(&shandle,srvname,password)) apierr("SQLCSV");

else

printf("Connection Established to Server \n"); /* CHANGE ACTIVITY LOG FILE */

Sqlbase SQL Application Programming Interface Reference Page 155

if (rcd = sqlclf(shandle,logfile,startflag)) apierr("SQLCLF");

else

printf("Successful change and start of server activity log file\n"); /* DISCONNECT FROM THE SERVER */

if (rcd = sqldsv(shandle)) apierr("SQLDSV");

else

printf("Disconnected from Server \n"); }

Related functions

sqlcsv sqlset

sqlcmt - CoMmiT

Syntax

#include "sqlbase.h" SQLTAPI sqlcmt(cur);

SQLTCUR cur; /* Cursor handle */

Description

This function commits a database transaction and starts a new transaction. All changes to the database since the last commit are made permanent and cannot be undone.

Before a commit, all changes made since the start of the transaction can be rolled back.

A commit releases all locks held by a transaction except when cursor-context preservation is on. This function commits the work of all cursors that an application has connected to the database or connection handle.

Connecting to a database or connection handle causes an implicit commit of a transaction. After

establishing this connection to the database, SQLBase issues a COMMIT to establish the starting point of the first transaction in the logging system. However, subsequent connections to other cursors are not specifically database connections, and do not cause SQLBase to issue a COMMIT or activate any transaction control devices. Also, they do not alter the flow of the current transaction and destroy compiled commands.

This function destroys all compiled commands for all cursors and connection handles connected to the database except when cursor-context preservation is on.

Sqlbase SQL Application Programming Interface Reference Page 156 The database can also be committed by executing a SQL COMMIT command.

Parameters

cur

The cursor handle associated with this function.

Return value

If this function returns zero, it was successful. If this function returns a non-zero value, it was unsuccessful.

Example

ret = sqlcmt(cur);

Related functions

sqlrbk

sqlcnc - CoNnect Cursor

Syntax

#include "sqlbase.h"

SQLTAPI sqlcnc (curp, dbnamp, dbnaml) SQLTCUR PTR curp; /* Cursor handle */ SQLTDAP dbnamp; /* Connect string */ SQLTDAL dbnaml; /* Connect string length */

Description

This function applies to applications in which you are connecting cursors to a specific database that belong to a single transaction.

This function connects to a database and issues a cursor handle that identifies an implicit connection to a specific database. All cursors that you connect to this database belong to a single transaction and to the same implicit connection handle.

This function can connect to a new database or connect a new cursor to the current database. Note: To create multiple, independent connections, SQLBase allows you to explicitly create multiple connection handles. You can use connection handles for multiple transactions to the same database within an application, or for creating multi-threaded Win32 applications. For details on creating connection handles, read the section on connection handles in Chapter 3.

Sqlbase SQL Application Programming Interface Reference Page 157

Parameters

curp

A pointer to the variable where this function returns the cursor handle. dbnamp

A pointer to the connect string that contains the database name, username, and password separated by forward slashes:

database/username/password

These rules are used:

• The characters before the first forward slash are the database name.

• Any characters after the first forward slash and before the second forward slash are the username.

• Any characters after the second forward slash are the password.

If the database name, username, or password is not specified, then the system uses the current default. For example, you can specify the following connect string in which the default database name and username are used:

//password

The default database name, username, and password are determined by:

• The defaultdatabase, defaultuser, and defaultpassword keywords in sql.ini. • The default of DEMO/SYSADM/SYSADM.

For external (Windows) authentication, use "database/*/". dbnaml

The length of the string pointed to by dbnamp. If the string pointed to by dbnamp is null-terminated, specify zero and the system will compute the length.

Return value

If this function returns zero, it was successful. If this function returns a non-zero value, it was unsuccessful.

Example

Sqlbase SQL Application Programming Interface Reference Page 158 SQLTRCD rcd; /* Return code */ if (rcd = sqlcnc(&cur, "PAYROLL/BOSS/SECRET", 0)) { printf("Failure on connect (rcd = %d)\n",rcd); exit(0); } else printf("Connection established\n");

Related functions

sqlcnr sqldis