K2InformaticsGmbH / erloci

Erlang Oracle native driver - DEPRECATED, see https://github.com/K2InformaticsGmbH/oranif instead
Apache License 2.0
37 stars 11 forks source link

Statements not reusable after transient error #22

Closed c-bik closed 7 years ago

c-bik commented 7 years ago

Current

application:stop(erloci).
application:start(erloci).
f().
InsSql = <<"insert into test values(:P_VALUE)">>.
InsBind = [{<<":P_VALUE">>, in,'SQLT_INT}].
OciPort = erloci:new([{env,[{"NLS_LANG","GERMAN_SWITZERLAND.AL32UTF8"}]}]).
Sess = OciPort:get_session(<<"(DESCRIPTION =(ENABLE=BROKEN)(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)
                              (HOST=1.1.1.1)(PORT = 1111)))(CONNECT_DATA=(SERVER=DEDICATED)
                              (SERVICE_NAME=XE)))">>, <<"user">>, <<"password">>).
InsStmt = Sess:prep_sql(InsSql).
ok = InsStmt:bind_vars(InsBind).

InsStmt:exec_stmt([{1}]).
{error,{1,
        <<"ORA-00001: unique constraint (SCOTT.TEST_UNIQUE) violated\n">>}}

InsStmt:exec_stmt([{1}]).
** exception error: no function clause matching
  oci_port:'-collect_grouped_bind_request/6-fun-0-'({error,0,<<"invalid statement handle">>},[])
                                                                    (src/oci_port.erl, line 180)
     in function  lists:foldl/3 (lists.erl, line 1262)
     in call from oci_port:collect_grouped_bind_request/6 (src/oci_port.erl, line 180)

Expected

...
InsStmt:exec_stmt([{1}]).
{error,{1,
        <<"ORA-00001: unique constraint (SCOTT.TEST_UNIQUE) violated\n">>}}
InsStmt:exec_stmt([{1}]).
{error,{1,
        <<"ORA-00001: unique constraint (SCOTT.TEST_UNIQUE) violated\n">>}}

InsStmt:exec_stmt([{2}]).
{rowids,[<<"AAAS66AABAAALLRAAA">>]}
InsStmt:exec_stmt([{2}]).
{error,{1,
        <<"ORA-00001: unique constraint (SCOTT.TEST_UNIQUE) violated\n">>}}