Re: Method to determine if in a transaction?
Posted in 2006
Topics: Stored Procedures & SPL
In IDS, you can do this without writing an C code.
The function f() below returns the values returned by
mi_transaction_state.
0 -- Not in a transaction.
1 -- in a multi-statement transaction [started with begin work]
2 -- in an implicitly started transaction.
Non-zero value indicates you're in a transaction.
cheers,
Keshav.
create database foo with log;
> create function f() returns int> external name '(mi_transaction_state)' language c;
Routine created.
> execute function f();
(expression)
0
1 row(s) retrieved.
>
> begin work;
Started transaction.
> execute function f();
(expression)
1
1 row(s) retrieved.
> commit work;
Data committed.
> select f() from systables where tabid = 1;
(expression)
2
1 row(s) retrieved.
>
Thanks! It hadn't occurred to me that one could simply create a function
that maps to an existing C DataBlade routine, that could be useful for
other things too, I suspect.
- Matt
keshava.news@gmail.com wrote:
> In IDS, you can do this without writing an C code.
>
> The function f() below returns the values returned by
> mi_transaction_state.
> 0 -- Not in a transaction.
> 1 -- in a multi-statement transaction [started with begin work]
> 2 -- in an implicitly started transaction.
>
> Non-zero value indicates you're in a transaction.
>
> cheers,
>
> Keshav.
>
> create database foo with log;>
>
>>create function f() returns int>>external name '(mi_transaction_state)' language c;
>
>
> Routine created.
>
>
>>execute function f();>
>
>
> (expression)
>
> 0
>
> 1 row(s) retrieved.
>
>
>>begin work;
>
>
> Started transaction.
>
>
>>execute function f();>
>
>
> (expression)
>
> 1
>
> 1 row(s) retrieved.
>
>
>>commit work;
>
>
> Data committed.
>
>
>
>>select f() from systables where tabid = 1;
>
>
>
> (expression)
>
> 2
>
> 1 row(s) retrieved.
>
>
>