• No results found

Syntax

#include "sqlbase.h"

SQLTAPI sqlbnn (cur, bnn, dap, dal, sca, pdt, nli); 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.

Sqlbase SQL Application Programming Interface Reference Page 139

Parameters

cur

The cursor handle associated with this function. bnn

The number of the bind variable in the SQL command. Bind variable numbers must be unique in SQL commands.

dap

A pointer to the program variable that will be associated to the bind variable. dal

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

In all other cases, a calculated length of zero or a specified length of zero causes the column to contain a null value.

sca

The scale (number of decimal places) for a packed-decimal data type. This argument is ignored for other data types. If you are not using a packed-decimal data type, specify zero.

pdt

The program data type of the program variable being bound. Data is converted to the program data type if the SQL data is compatible.

Sqlbase SQL Application Programming Interface Reference Page 140 Program Data Type Description

SQLPBUF Character buffer SQLPDAT Internal datetime

SQLPDOU Double

SQLPDTE Date only

SQLPEBC EBCDIC buffer

SQLPFLT Float

SQLPLON Long text string SQLPLBI Long binary buffer SQLPLVR Char/long varchar >254 SQLPNBU Numeric buffer

SQLPNST Numeric string SQLPNUM Internal numeric

SQLPSCH Character

SQLPSIN Integer

SQLPSLO Long

SQLPSPD Signed packed decimal

SQLPSSH Short

SQLPSTR String (null-terminated)

SQLPTIM Time only

SQLPUCH Unsigned character SQLPUIN Unsigned integer SQLPULO Unsigned long

SQLPUPD Unsigned packed decimal SQLPUSH Unsigned short

Sqlbase SQL Application Programming Interface Reference Page 141

Related functions

sqlbld sqlbnd sqlcbv sqlbln sqlbnu sqlnbv sqlbna sqlbnn2

sqlbnu - Bind data by NUmber

Syntax

#include "sqlbase.h"

SQLTAPI sqlbnu (cur, bnn, dap, dal, sca, pdt, nli); 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 */

SQLTNUL nli /* Null indicator */

Description

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

The sqlbnu function is identical to sqlbnn with one exception: sqlbnu has an additional argument for the null indicator. This function is used with SQLNetwork routers and gateways to bind null values for non- SQLBase databases. You can use this function with SQLBase databases, but SQLBase ignores the nli argument.

Call this function after sqlcom and before sqlexe.

Parameters

cur

The cursor handle associated with this function. bnn

The number of the bind variable in the SQL command. Bind variable numbers must be unique in SQL commands.

dap

A pointer to the program variable that will be associated to the bind variable. dal

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

In all other cases, a calculated length of zero or a specified length of zero causes the column to contain a null value.

Sqlbase SQL Application Programming Interface Reference Page 143 sca

The scale (number of decimal places) for a packed-decimal data type. This argument is ignored for other data types. If you are not using a packed-decimal data type, specify zero.

pdt

The program data type of the program variable being bound. Data is converted to the program data type if the SQL data is compatible.

Sqlbase SQL Application Programming Interface Reference Page 144 Program Data Type Description

SQLPBUF Character buffer SQLPDAT Internal datetime

SQLPDOU Double

SQLPDTE Date only

SQLPEBC EBCDIC buffer

SQLPFLT Float

SQLPLON Long text string SQLPLBI Long binary buffer SQLPLVR Char/long varchar >254

SQLPNBU Numeric buffer

SQLPNST Numeric string SQLPNUM Internal numeric

SQLPSCH Character

SQLPSIN Integer

SQLPSLO Long

SQLPSPD Signed packed decimal

SQLPSSH Short

SQLPSTR String (null-terminated)

SQLPTIM Time only

SQLPUCH Unsigned character SQLPUIN Unsigned integer

SQLPULO Unsigned long

SQLPUPD Unsigned packed decimal

Sqlbase SQL Application Programming Interface Reference Page 145 nli

Null indicator. Before calling sqlbnu, set this argument to indicate whether or not the value being bound is null:

Return value

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

Related functions

sqlbld sqlbnd sqlcbv sqlbln sqlbnn sqlnbv sqlbna sqlbnu2

sqlbss - Backup SnapShot

Syntax

#include "sqlbase.h"

SQLTAPI sqlbss (shandle, dbname, dbnamel, bkpdir, bkpdirl, local, over) SQLTSVH shandle; /* Server handle */

SQLTDAP dbname; /* Database name */

SQLTDAL dbnamel; /* Database name length */ SQLTFNP bkpdir; /* Backup directory */

SQLTFNL bkpdirl; /* Backup directory length */

SQLTBOO local; /* True: backup directory on local (client) node */ SQLTBOO over; /* True: overwrite existing file */

Description

This function copies a database and its associated transaction log files to the specified directory.

The sqlbss function is the recommended way to backup a database and its log files because there is only one step (sqlrss) needed to bring a database and its log files to a consistent state.

Transactions that are committed when the backup is started are included in the backup. Active transactions are not included.

This function call forces a log rollover (sqlrlf) automatically.

-1 The data being bound is null. The SQLNetwork router or gateway will generate the native null character for the 0 The data being bound is not null.

Sqlbase SQL Application Programming Interface Reference Page 146 Once a database and its transaction log files are backed up to a directory, you can transfer the copies to archival media and then delete them from the hard disk.

You cannot call sqlbss while in Read-Only (RO) isolation level.

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

Parameters

shandle

The server handle returned by sqlcsv. dbname

A pointer to the string that contains the database name. dbnamel

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

bkpdir

A pointer to the string that contains the backup directory name. bkpdirl

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

local

Destination of backup:

0 Backup directory on server.

1 Backup directory on local (client) node. over

Overwrite indicator:

0 Do not overwrite existing file. 1 Overwrite existing file.

Return value

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

Sqlbase SQL Application Programming Interface Reference Page 147

Example

SQLTSVH shandle; char* password; SQLTDPV lbmset; SQLTFNP bkpdir; SQLTFNL bkpdirl; SQLTRFM mode=SQLMEOL; SQLTLNG lognum; SQLTBOO local,over;

/* default database name */

static char dbname1[] = "island"; /* server name */

static char srvname[] = "SERVER1"; password = 0; local=1; over=1;

/* CONNECT TO SERVER */

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

/* MAKE BACKUP DIRECTORIES */

system("mkdir \\backup\\snapshot"); bkpdir = "\\BACKUP\\SNAPSHOT"; bkpdirl = strlen(bkpdir); /* BACKUP SNAPSHOT */ if (rcd = sqlbss(shandle,dbname1,0,bkpdir,bkpdirl,local,over)) apierr("SQLBSS"); else

printf("Backup Snapshot Database \n");

Related functions

sqlbdb sqlenr sqlrlf sqlblf sqlgnl sqlrof sqlcrf sqlrdb sqlrss sqlcsv sqlrel