[erlang-bugs] odbc module lacks in a mode after executing stored procedures

cymoon info@REDACTED
Tue Jul 26 18:29:50 CEST 2011


I am using Erlang together with an Oracle 11g database on a windows machine.
When I execute a stored procedure using param_query, the odbc module
executes further statements as if they where also stored procedures.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%
odbc:start(permanent),
{ok, Ref} = odbc:connect(ConnectStr, Options),

Result1 =odbc:param_query(Ref, "select ? from dual",[{ sql_integer,[1]}]),
io:format("~p~n",[Result1]),
% returns:  {selected,[":1"],[{1.0}]}

Result2 =odbc:param_query(Ref, "{ ? = call NVL (2,2)
}",[{sql_integer,out,[1]}]),
io:format("~p~n",[Result2]),
% returns:  {executed,1,[{2}]}

Result3 =odbc:param_query(Ref, "select ? from dual",[{ sql_integer,[3]}]),
io:format("~p~n",[Result3]),
% returns:  {executed,0,[{}]}  but should return  {selected,[":1"],[{3.0}]}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%


To make sure that it is a bug in erlang, I wrote the same test in C#. It
works as expected:

/////////////////////////////////////////
OdbcConnection con = new OdbcConnection();
con.ConnectionString = "DSN=flexdoc_dev;UID=nn2;PWD=nn2";
con.Open(); OdbcCommand cmd; OdbcDataReader dr;

cmd = new OdbcCommand("SELECT ? val FROM dual", con);
cmd.Parameters.AddWithValue("", 1);
dr = cmd.ExecuteReader(); dr.Read();
Console.WriteLine(dr["val"].ToString());
// returns 1

cmd = new OdbcCommand("{ ? = CALL NVL(2,2) }", con);
cmd.CommandType = CommandType.StoredProcedure;
OdbcParameter parameter = cmd.Parameters.Add("returnVal", OdbcType.Int);
parameter.Direction = ParameterDirection.ReturnValue;
dr = cmd.ExecuteReader(); dr.Close();
Console.WriteLine(cmd.Parameters["returnVal"].Value);
// returns 2

cmd = new OdbcCommand("SELECT ? val FROM dual", con);
cmd.Parameters.AddWithValue("", 3);
dr = cmd.ExecuteReader(); dr.Read();
Console.WriteLine(dr["val"].ToString());
// returns 3
/////////////////////////////////////////



--
View this message in context: http://erlang.2086793.n4.nabble.com/odbc-module-lacks-in-a-mode-after-executing-stored-procedures-tp3696283p3696283.html
Sent from the Erlang Bugs mailing list archive at Nabble.com.



More information about the erlang-bugs mailing list