For example, these lines declare variables to hold the values for the department
ID, department name, and manager ID, as well as for the statement string itself. Then,
they bind parameters to the first, second, and third parameters of a statement executed
using the “stmt” statement handle:
#defined DEPT_NAME_LEN 20
SQLLEN cbDeptID = 0,
cbDeptName = SQL_NTS, cbManagerID = 0;
SQLCHAR deptname[ DEPT_NAME_LEN ];
SQLSMALLINT deptID, managerID;
SQLCHAR *insertstmt =
"INSERT INTO department "
"( dept_id, dept_name, dept_head_id )"
"VALUES (?, ?, ?,)";
SQLBindParameter( stmt, 1, SQL_PARAM_INPUT,
SQL_C_SSHORT, SQL_INTEGER, 0, 0,
&deptID, 0, &cbDeptID);
SQLBindParameter( stmt, 2, SQL_PARAM_INPUT,
SQL_C_CHAR, SQL_CHAR, DEPT_NAME_LEN, 0,
deptname, 0,&cbDeptName);
SQLBindParameter( stmt, 3, SQL_PARAM_INPUT,
SQL_C_SSHORT, SQL_INTEGER, 0, 0,
&managerID, 0, &cbManagerID);