As it turns out I confused the order in which the functions are run, the correct order is:
SQLBindParameter
SQLExecDirect
SQLBindCol
For SQLBindParameter
(at least for input parameters) the lengths are already known before the statement is executed.
After SQLExecDirect
you can use the SQLNumResultCols
and SQLGetDescField
functions to determine the number of columns, their data types, lengths, etc.
The SQL92/CLI (call level interface) documentation has an example in appendix B.2 Interactive Query
that uses SQLDescribeCol
to get the length.