The SQL statement strings passed to functions
mcosql_execute_query()andmcosql_execute_statement()allow application variable values to be substituted into the string according to rules similar to the standardprintf()format string substitution with some slight differences. Where a per cent "%"appears in the SQL statement string followed by a single character or an asterisk"*", the value of the associated variable in the argument list will be substituted according to the following type specifications:
%ba onebytevalue of 0 or 1
%fadoublevalue
%ia signed integer value (4 bytes)
%la signed integer value (8 bytes)
%pthe address of an 8 byte integer (for example anautoid)
%rastructmapped to the record (fields with type string must bechar* type)
%Rastructmapped to the record (fields with typechar<N>must bechar[N]type)
%sachar * value(associated with astringorchar<n>field)
%tatime_tvalue
%uan unsigned integer value (4 bytes)
%vaValue*(address of a variable of typeValue)
%wawchar_t*value (associated with anstringornchar<n>field)When pre-compiling a statement with function
mcosql_prepare_statement()the variable-length argument list is often intended to bind program variables to columns in the result set of a select statement. In this case what is needed is the address of the variable to receive the result set value. So, formcosql_prepare_statement(), the following additional substitution types are provided:
%*b- address of aboolvariable
%*faddress of adoublevariable
%*iaddress of anintvariable
%*laddress of anint64_tvariable%*p address of an
int64_tvariable (for example anautoid)%*s address of a
stringvariable (i.e.char**)
%*Sachar *value (indirect reference to astringorchar<n>field)
%*taddress of atime_tvariable
%*waddress of awchar_t*variable (i.e.wchar_t**)
%*Wawchar_t *value (indirect reference to anstringornchar<n>field)Mapping SQL Date and Time fields
In order to map C-language date or time data to the SQL data types, a C application should use an 8-byte
mco_datetimedata type (instead of themco_timeormco_date). The date and time types are represented via the 8-bytetpDatetimetype in SQL. (Use the%lor%*lsubstitution specifier as this is an 8-byteorint64_tvalue.)A note on using scientific notation for numeric values
When scientific notation is used for numeric types (eg.
7.5013e+006instead of7501301), the number must always begin with a digit. This means that such a number can’t be defined as ”.e1”, which is allowed by the standard.