Oracle and ODBC erlang driver

Yvan Godin yvan.godin@REDACTED
Wed Jun 4 11:46:03 CEST 2003


Le Mercredi 28 Mai 2003 18:25, vous avez écrit :

First of all .. thank for your answer

> The erlang ODBC application consists of an erlang part and a C-part.
> The C-part delivered for the W2K platform is compiled to work with
> sqlserver. Have you recompiled it to link with your oracle driver?
Really needed ??? seem to me ODBC here to be indépendant from database drivers 
;-)


> Please let me know how it goes.

I have made some new tests and below the result

With new erlang ODBC functions (odbc:connect(..))
and setting  LOG on ODBC visual studio analyser

I get a pop up with 
APPLICATION ERROR
l'instruction 0x1f95f26d emploi l'adresse memoire 0x1f95f26d
MEMORY CAN'T BE READ



Then I made some test with the deprecated fonctions
(modifed version of basic.erl in odbc example see code below)
and seem be better

here are the result (give me an answer ... the error msg may be due of bad  
code ...see below)


yoldbc:init().

sqlConnect returns 1
sqlExecDirect returns 0
Select: Number of columns: 6
sqlBindColumn returns 0
sqlBindColumn returns 0
sqlFetch returns 0
Select: Column 1 data:"11"
Select: Column 2 data:"CLIENT"

=ERROR REPORT==== 3-Jun-2003::17:36:44 ===
Error in process <0.72.0> with exit value: 
{{badmatch,0},[{yoldbc,select,0},{yol
dbc,init,0},{erl_eval,expr,3},{erl_eval,exprs,4},{shell,eval_loop,2}]}
** exited: {{badmatch,0},
            [{yoldbc,select,0},
             {yoldbc,init,0},
             {erl_eval,expr,3},
             {erl_eval,exprs,4},
             {shell,eval_loop,2}]} **

=ERROR REPORT==== 3-Jun-2003::17:36:44 ===
** Generic server odbc1 terminating
** Last message in was {'DOWN',#Ref<0.0.0.288>,
                               process,
                               <0.72.0>,
                               {{badmatch,0},
                                [{yoldbc,select,0},
                                 {yoldbc,init,0},
                                 {erl_eval,expr,3},
                                 {erl_eval,exprs,4},
                                 {shell,eval_loop,2}]}}
** When Server state == {state,#Port<0.85>,
                               undefined,
                               <0.72.0>,
                               undefined,
                               on,
                               undefined,
                               undefined,
                               undefined,
                               connected,
                               undefined,
                               0,
                               true,
                               true,
                               [{#Ref<0.0.0.303>,2},{#Ref<0.0.0.302>,1}]}
** Reason for termination ==
** {stopped,{'EXIT',<0.72.0>,
                    {{badmatch,0},
                     [{yoldbc,select,0},
                      {yoldbc,init,0},
                      {erl_eval,expr,3},
                      {erl_eval,exprs,4},
                      {shell,eval_loop,2}]}}}




**************MODIFIED VERSION of BASIC.ERL *************
-module(yoldbc).
-export([init/0,stop/0]).
-include("odbc.hrl").

-def.... here my connection macros

init() ->
    % Start a new ODBC server. The application must already be started.
    {ok, Pid} = odbc:start_link({local, ?SERV},[], []),
    % Connect to the database (also loads the Driver).
    Ret =  odbc:sqlConnect(?SERV, ?DSN, ?UID, ?PWD, infinity),
    io:format("sqlConnect returns ~p~n",[Ret]),
    select(),
    stop().

select() ->
    SelectStmt = "SELECT * FROM GROUPES",
    Ret1 = odbc:sqlExecDirect(?SERV, SelectStmt, infinity),
    io:format("sqlExecDirect returns ~p~n",[Ret1]),
    {?SQL_SUCCESS, NSelectedCols} =
      odbc:sqlNumResultCols(?SERV, infinity),
    io:format("Select: Number of columns: ~p~n", [NSelectedCols]),
    {ok,Ref1} = odbc:columnRef(),
    {ok,Ref2} = odbc:columnRef(),
    Ret6 = odbc:sqlBindColumn(?SERV, 1, Ref1, infinity),
    io:format("sqlBindColumn returns ~p~n",[Ret6]),
    Ret7 = odbc:sqlBindColumn(?SERV, 2, Ref2, infinity),
    io:format("sqlBindColumn returns ~p~n",[Ret7]),
    % Fetch the first row of selected rows.
    Ret8 = odbc:sqlFetch(?SERV, infinity),
    io:format("sqlFetch returns ~p~n",[Ret1]),
    {ok, ColValue1} =
	odbc:readData(?SERV, Ref1, infinity),
    io:format("Select: Column 1 data:~p~n",[ColValue1]),
    {ok, ColValue2} =
      odbc:readData(?SERV, Ref2, infinity),
    io:format("Select: Column 2 data:~p~n",[ColValue2]),
    ?SQL_NO_DATA = odbc:sqlFetch(?SERV, infinity),
    Ret12 = odbc:sqlCloseHandle(?SERV, infinity),
    io:format("sqlCloseHandle returns ~p~n",[Ret12]).
stop() ->
    Ret = odbc:sqlDisConnect(?SERV, infinity),
    odbc:stop(?SERV).



-- 
Cordialement

Yvan GODIN
WITBE/DSIC

http://www.witbe.net




More information about the erlang-questions mailing list