[Monetdb-developers] specifying NULL when using ODBC param_query

Sjoerd Mullender sjoerd at acm.org
Sun Jun 20 23:46:41 CEST 2010


On 2010-06-20 17:10, kss ram wrote:
> Hello Everyone,
> 
> Is there any way to specify a null value when using ODBC param_query, in
> case of SQL_Query we do not really end up facing this problem as we
> build our own query string and then execute sql_query, sql_query is
> potentially unsafe of sql injection attacks, and thus using param_query
> makes alot of sense, but param query makes it hard to specify the data
> type nuetral NULL value, if we try specifying blank values like 0 in
> case of number and "" in case of string, these blank values will end up
> taking space in the database and thus would be expensive in terms of
> memory consumption, a database specific NULL value would leave the field
> null with no memory consumption.
> 
> Thank you everyone in advance.

I guess you're talking about using SQLPrepare/SQLExecute and using
SQLBindParameter to specify the values of the parameters.  The final
argument of SQLBindParameter is a pointer which can point to a
SQLINTERGER buffer whose value can be SQL_NULL_DATA at the time of the
call the SQLExecute.  If that is the case, this indicates that the
parameter value is NULL.  This is supported by the driver, and I hope it
works.  This is, as far as I know, the way to do it with ODBC.

Having said that, NULL values in MonetDB take up the same amount of
space as non-NULL values, so there is no reason to use NULLs to save space.

-- 
Sjoerd Mullender




More information about the developers-list mailing list