Syntax
#include "sqlbase.h"
SQLTAPI sqlbna (cur, bnp, bnl, dap, dal, sca, pdt, nli); SQLTCUR cur; /* Cursor handle */
SQLTBNP bnp; /* Name of bind variable */
SQLTBNL bnl; /* Length of bind variable name */ 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 an alphanumeric bind variable (such as :comments) for a column with a variable defined in the program.
Sqlbase SQL Application Programming Interface Reference Page 134 The sqlbna function is identical to sqlbnd with one exception: sqlbna 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. bnp
A pointer to the string that contains the bind variable name. Bind variable names must be unique in SQL commands.
bnl
The length of the string pointed to by bnp. If the string pointed to by bnp is null- terminated, specify zero and the system will compute the length.
dap
A pointer to the 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.
The program data types are shown below. These are defined in sqlbase.h.
Program Data Type Description SQLPBUF Character buffer SQLPDAT Internal datetime
Sqlbase SQL Application Programming Interface Reference Page 135
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
nli
Null indicator. Before calling sqlbna, set this argument to indicate whether or not the value being bound is null, where -1 means the data being bound is null, and 0 means the data being bound is NOT 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 sqlbnn sqlcbv sqlbln sqlbnu sqlnbv Sqlbnd
Sqlbase SQL Application Programming Interface Reference Page 136
sqlbnd - BiNd Data by name
Syntax
#include "sqlbase.h"
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 name */ 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.
Call this function after sqlcom and before sqlexe.
Parameters
cur
The cursor handle associated with this function. bnp
A pointer to the string that contains the bind variable name. Bind variable names must be unique in SQL commands.
bnl
The length of the string pointed to by bnp. If the string pointed to by bnp is null- terminated, specify zero and the system will compute the length.
dap
A pointer to the variable that will be associated to the bind variable. dal
Sqlbase SQL Application Programming Interface Reference Page 137 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.
The program data types are shown below. These are defined in sqlbase.h. 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
Sqlbase SQL Application Programming Interface Reference Page 138
Return value
If this function returns zero, it was successful. If this function returns a non-zero value, it was unsuccessful.
Example
static char insitem = "insert into item values (:item, :name)"; int item; /* item number */
char name[25]; /* item name */ short ret; /* return code */ /* Bind integer data */
ret = sqlbnd(cur,"item",0,&item,sizeof(item),0,SQLPUIN); /* Use defaults for pdt and bnl */
ret = sqlbnd(cur,"name",0,name,25,0,SQLPBUF);
Related functions
sqlbld sqlbnn sqlcbv sqlbln sqlbnu sqlnbv sqlbna