Add parametrized exec's (esqlite3:exec/3 and esqlite3:exec/4)
This commit is contained in:
@@ -198,7 +198,18 @@ exec(Sql, Connection) ->
|
|||||||
exec(Sql, {connection, _Ref, Connection}, Timeout) ->
|
exec(Sql, {connection, _Ref, Connection}, Timeout) ->
|
||||||
Ref = make_ref(),
|
Ref = make_ref(),
|
||||||
ok = esqlite3_nif:exec(Connection, Ref, self(), Sql),
|
ok = esqlite3_nif:exec(Connection, Ref, self(), Sql),
|
||||||
receive_answer(Ref, Timeout).
|
receive_answer(Ref, Timeout);
|
||||||
|
|
||||||
|
%% @spec exec(iolist(), list(term()), connection()) -> integer() | {error, error_message()}
|
||||||
|
exec(Sql, Params, {connection, _, _}=Connection) when is_list(Params) ->
|
||||||
|
exec(Sql, Params, Connection, ?DEFAULT_TIMEOUT).
|
||||||
|
|
||||||
|
%% @spec exec(iolist(), list(term()), connection(), timeout()) -> integer() | {error, error_message()}
|
||||||
|
exec(Sql, Params, {connection, _, _}=Connection, Timeout) when is_list(Params) ->
|
||||||
|
{ok, Statement} = prepare(Sql, Connection, Timeout),
|
||||||
|
bind(Statement, Params),
|
||||||
|
step(Statement, Timeout).
|
||||||
|
|
||||||
|
|
||||||
%% @doc Insert records, returns the last rowid.
|
%% @doc Insert records, returns the last rowid.
|
||||||
%%
|
%%
|
||||||
|
|||||||
Reference in New Issue
Block a user