[erlang-questions] Null parameter for ODBC param_query

Andy Richards andy.richards.iit@REDACTED
Fri Apr 20 12:14:54 CEST 2012


Hi Avinash,

That's useful thanks and gives me food for thought. We have many stored procs so I wouldn't know the param types before hand so I would need to dynamically construct our Format string with the appropriate types...

E.g. lists:flatten(io_lib:fwrite("exec User_Read ~w, ~s, ~f", [Param, "some string", 0.1])

I'm not sure what the overhead would be but I could cache the string once constructed the first time. Do you find fwrite performant enough replacing parameters? I think we going to build a custom approach which will handle bits and sqlserver default values and perhaps your approach as you suggest.

Many thanks,

Andy.

Sent from my iPad

On 20 Apr 2012, at 07:24, "Avinash Dhumane" <avinash@REDACTED> wrote:

> I use the ODBC application of Erlang (presently, on R14B02) quite heavily
> and with proprietary drivers like AS400 and Netezza.
> 
> I rely on odbc:sql_query() - even with parameters - more than on
> odbc:param_query(). I use the latter only when to submit a batch of
> INSERTs. With former, I construct the SQL string by duly substituting all
> the parameter values and submit. So, the submission through ODBC becomes
> exactly same as I would do on the SQL command-line interface tool provided
> by the DBMS. Applying to your case, I would have done as follows:
> 
> lists:flatten(io_lib:fwrite("exec User_Read ~w", [Param])
> 
> On Thu, 19 Apr 2012 18:54:16 +0530, Andy Richards
> <andy.richards.iit@REDACTED> wrote:
> 
>> Hi all,
>> 
>> I found this previous unanswered post to the mailing list and I now face the same problem....
>> 
>> http://erlang.2086793.n4.nabble.com/NULL-parameter-for-ODBC-param-query-td3226735.html
>> 
>>> "Is it possible to use null values in a parameterised odbc param_query?
>>> 
>>> example: odbc:param_query("exec User_Read ?", [{sql_integer, Param}]).  %
>>> Param is either an integer or null
>>> 
>>> The odbc driver returns the 'null' atom when selecting rows, but I haven't
>>> found a value that allows me to specify a null parameter ('null', 'NULL',
>>> <<"null">>, etc...)"
>> 
>> 
>> According to the documentation value = null | term() however an exception is thrown if the atom null is used?
>> 
>> Has anyone come across this or are there any workarounds to this issue ?
>> 
>> I've already patched the c portion of the odbc driver to resolve a socket issue under Linux so I'm wondering if this module is used much in the Erlang world?
>> 
>> Many thanks,
>> 
>> Andy.
>> 
>> 
>> 
> 
> 
> -- 
> Using Opera's revolutionary email client: http://www.opera.com/mail/



More information about the erlang-questions mailing list