Skip to Content.
Sympa Menu

freetds - RE: Problem with Transaction

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Nelson David" <ndavid AT audiomedia.pt>
  • To: "TDS Development Group" <freetds AT franklin.oit.unc.edu>
  • Subject: RE: Problem with Transaction
  • Date: Tue, 12 Nov 2002 11:36:28 -0000


It doesn't work because you are trying to execute an
sql command (delete ...) inside an open recordset (select ...)
In transaction mode you can only work with one open recordset at a time.

The solution provided by freddy77 solves your problem, but if you need
to do this kind of code i suggest you put the resultset of select into an
array and then inside a for loop of this result array do the delete command.

Bye,
Nelson

>
> I have MS SQL 6.5 server on Win NT and FreeTDS 0.60 with
> Apache and PHP. I
> try use transaction but I didnĀ“t work.
> I try this (ex.):
>
> //connect to DB
> mssql_query("BEGIN TRAN",$db);
> $res=mssql_query("select USER_ID from USERS where USER_ID >
> 10 and USER_ID
> <15);
> while ($rows=mssql_fetch_array($res)){
> mssql_query("delete from USERS where USER_ID = $rows[USER_ID]);
> }
> mssql_query("COMMIT",$db);
> mssql_close();
>
> but It don't work.
>

I suppose you do not use this code... ("DELETE FROM USERS WHERE USER_ID > 10
AND USER_ID < 15" is better...).
Some information are useful:
- operating system and version
- programs versions (php, apache)

Why transaction do not work as expected?

freddy77

=================================
"STRICTLY PERSONAL AND CONFIDENTIAL

This message may contain confidential and proprietary material for the sole
use of the intended recipient. Any review or distribution by others is
strictly prohibited. If you are not the intended recipient please contact
the sender and delete all copies.
The contents of this message that do not relate to the official business of
our company shall be understood as neither given nor endorsed by it."

=================================

---
You are currently subscribed to freetds as: [ndavid AT audiomedia.pt]
To unsubscribe, forward this message to
$subst('Email.Unsub')





Archive powered by MHonArc 2.6.24.

Top of Page