Board index » delphi » TIBScript and Committing Transaction

TIBScript and Committing Transaction


2006-08-17 02:06:35 AM
delphi129
I have the following code:
sc := TIBScript.Create(self);
sc.Database := dm.db;
sc.Transaction := dm.str;
for I := 0 to saves.Count - 1 do
begin
ic := TIC(saves.Objects[i]);
sc.Script.Add('Update Inventory Set UPCCODE = ''' + ic.UPCCode +
''' where KTLCODE = ''' + ic.KTLCode + ''' and KTLTYPE = ''' +
ic.KTLType + ''';');
end;
sc.Transaction.StartTransaction;
sc.ExecuteScript;
sc.Transaction.Commit;
sc.Free;
while produces and executes the following sql.
Update Inventory Set UPCCODE = '084948333338' where KTLCODE = '5865001' and
KTLTYPE = '10';
Update Inventory Set UPCCODE = '084948222229' where KTLCODE = '5865001' and
KTLTYPE = '13';
After executing with no error the data is not committed until I close the
program. (i.e.) attempts to read the changed data recall the original
values. After closing and reopening the program I get the correct values.
Any Ideas?
The transaction.Params is set to:
read_committed
rec_version
nowait
write
Delphi 2006 and Interbase Express 10.10
Farley
 
 

Re:TIBScript and Committing Transaction

Quote
I have the following code:

sc := TIBScript.Create(self);
sc.Database := dm.db;
sc.Transaction := dm.str;
...
sc.Script.Add('Update Inventory Set UPCCODE = ''' + ic.UPCCode +
''' where KTLCODE = ''' + ic.KTLCode + ''' and KTLTYPE = ''' +
ic.KTLType + ''';');
...
sc.Transaction.StartTransaction;
sc.ExecuteScript;
sc.Transaction.Commit;
sc.Free;
After executing with no error the data is not committed until I close the
program. (i.e.) attempts to read the changed data recall the original
values. After closing and reopening the program I get the correct values.
This condition has existed for a while. When used with DML statements (no
dataset), the script component is not using the transaction specified in
its' Transaction property; it is using the default transaction from its'
Database property. My guess is that the transaction you specified is not the
default transaction for the Database specified.
You could try:
sc := TIBScript.Create(self);
sc.Database := dm.db;
sc.Transaction := dm.str;
sc.Database.DefaultTransaction := dm.str;
hth...
 

Re:TIBScript and Committing Transaction

Thanks that did it...
Farley
"Don Siders" <XXXX@XXXXX.COM>writes
Quote
>I have the following code:
>
>sc := TIBScript.Create(self);
>sc.Database := dm.db;
>sc.Transaction := dm.str;
...
>sc.Script.Add('Update Inventory Set UPCCODE = ''' + ic.UPCCode +
>''' where KTLCODE = ''' + ic.KTLCode + ''' and KTLTYPE = ''' +
>ic.KTLType + ''';');
...
>sc.Transaction.StartTransaction;
>sc.ExecuteScript;
>sc.Transaction.Commit;
>sc.Free;

>After executing with no error the data is not committed until I close the
>program. (i.e.) attempts to read the changed data recall the original
>values. After closing and reopening the program I get the correct values.

This condition has existed for a while. When used with DML statements (no
dataset), the script component is not using the transaction specified in
its' Transaction property; it is using the default transaction from its'
Database property. My guess is that the transaction you specified is not
the default transaction for the Database specified.

You could try:

sc := TIBScript.Create(self);
sc.Database := dm.db;
sc.Transaction := dm.str;
sc.Database.DefaultTransaction := dm.str;

hth...