[unixODBC-support] SQLBindParameter problem

Martin J. Evans martin.evans at easysoft.com
Thu Jun 15 20:18:50 BST 2006


If you are executing  "simple select statement" then there are no
output bound parameters so you are probably just seeing
random data - what was in memory at blob_Buff, before you
called execute.

Output bound parameters are for the calling of procedures which
set output parameters as in

create procedure fred (x out integer)

If you are simply doing a select then you either call SQLGetData
to retrieve the column data in the result-set or bind the columns
before calling SQLFetch.

Be careful using SQLBindCol for retrieving long column data as
it will be truncated if your buffers are not long enough.

Martin

Nagesh Sharvari-A21337 wrote:
> Hello,
> 	I am facing a strange problem with SQLBindParameter.
> I am trying to execute a simple select statement which gets a string and
> a blob value from a mySQL DB.
> 
> If I use SQLBindCol the statement works fine. But if I use
> SQLBindParameter, some junk value is returned for both character array
> and blob value.
> But I am using same SQLBindParameter function for inserting these
> values. That is working fine.
> Here are the Bind statements.
> 
> 
> erg = SQLBindParameter(hstmt, 1, SQL_PARAM_OUTPUT, SQL_C_CHAR, SQL_CHAR,
> 15, 0, ms_min, 20, &ms_len);
> erg = SQLBindParameter(hstmt, 2, SQL_PARAM_OUTPUT, SQL_C_BINARY,
> SQL_LONGVARBINARY, 65000, 0, blob_Buff, 0, &blob_len);
> 
> 
> 
> The following SQLBindCol function works fine:
> 
> SQLBindCol(hstmt,1,SQL_C_CHAR, ms_min,20,&erg);
> SQLBindCol(hstmt,2,SQL_C_BINARY,blob_Buff,sizeof(blob_Buff),&erg);
> 
> What's wrong with the first 2 Bind statements?
> 
> Following INPUT parameter binding is working fine:
>      erg = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR,
> SQL_CHAR, 15, 0, ms_min, 20, NULL);
>      erg = SQLBindParameter(hstmt, 2, SQL_PARAM_INPUT, SQL_C_BINARY,
> SQL_LONGVARBINARY, bytesread, 0, blob_Buff, 0, (long*)&bytesread);
> 
> Please help me solve this
> 
> Thanks and regards
> shar
> 
> 
> _______________________________________________
> unixODBC-support mailing list
> unixODBC-support at easysoft.com
> http://mail.easysoft.com/mailman/listinfo/unixodbc-support
> 
> 
> 
> 




More information about the unixODBC-support mailing list