[ic] Database transaction?
Mike Heins
mike at perusion.com
Tue May 31 12:32:23 EDT 2005
Quoting T. Stoffels (tstoffels at gmail.com):
> I just was pointed towards a different, imho more simple approach:
> I just do the begin..query..query..commit/rollback stuff myself =)
> --
> [tmp mysqlresult_begin][query sql=|begin work|][/query][/tmp]
>
> [tmp mysqlresult_del1][query sql=|delete ...|][/query][/tmp]
>
> [tmp mysqlresult_del2][query sql=|delete ...|][/query][/tmp]
>
>
> [if type=explicit compare="
> $Scratch->{mysqlresult_begin} == 1 &&
> $Scratch->{mysqlresult_del1} == 1 &&
> $Scratch->{mysqlresult_del2} == 1
> "]
> [query sql=|commit|][/query]
> everything deleted
>
> [else]do rollbackhere [/else]
> [/if]
This won't work for a number of reasons.
First, you need to have [query row-count=1 ....] or [query list=1 ....][sql-
code][/query] to get a row count back.
Second, unless you set AutoCommit to 0 in the database configuration,
you won't be in transactions mode and your commit won't do anything.
IMHO, using the [query ...] ITL tag for setting database values is not
a good idea. It doesn't give you the kind of control you need. It is
better to either use DBI or to use Interchange's supplied methods
(set_slice, delete_record, etc.).
--
Mike Heins
Perusion -- Expert Interchange Consulting http://www.perusion.com/
phone +1.765.647.1295 tollfree 800-949-1889 <mike at perusion.com>
Being against torture ought to be sort of a bipartisan thing.
-- Karl Lehenbauer
More information about the interchange-users
mailing list