BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

second problem sum

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (SQL Servers)
View previous topic :: View next topic  
Author Message
Kostas Liatifis
Guest





PostPosted: Thu Mar 10, 2005 7:58 pm    Post subject: second problem sum Reply with quote



Dear sir

I have this statement

Function TMasterDataDC.ExecIBSQL ( aTable:TIBTable; aSQL:TIBSQL ): Boolean ;
begin
try
with MasterDataDC do
begin
aSQL.Prepare;
aSQL.ExecQuery;
TransDC.Commit;
Result := True;
end;
except
MasterDataDC.TransDC.Rollback;
Result := False;
end;
aTable.Open;
if Assigned ( aTable ) then aTable.Refresh;
aTable.Close;
end ;

after this i have this statement

IBQuery.SQL.Add('Select Sum(SumField) AS Sum_Field from IBTable where
(Field=:Field)');
IBQuery.ParamByName('Field').AsInteger:=AInteger;
IBQuery.Open;
I:=IBQuery.FieldByName('Sum_Field').asInteger;

after this the value of sum is 0
but if i closed the application and i opened again then i have the result
why?
where is the problem?

Thank you



Back to top
Barak zabari
Guest





PostPosted: Sun Mar 13, 2005 4:51 pm    Post subject: Re: second problem sum Reply with quote



I have some problem understanding your code.
I see that you pass the Table and Query as parmeters then you use a
Component called TransDC ( i assume this ia TIBTransaction).
Why not use aSQL.transaction.commit?
that way you know you commit the right object.
I am not sure what value AInteger got (i assume it's something you insert
with aSQL) and since you get a Zero as a return value i think your problem
is with the commit;



"Kostas Liatifis" <texilia (AT) otenet (DOT) gr> wrote

Quote:
Dear sir

I have this statement

Function TMasterDataDC.ExecIBSQL ( aTable:TIBTable; aSQL:TIBSQL ): Boolean
;
begin
try
with MasterDataDC do
begin
aSQL.Prepare;
aSQL.ExecQuery;
TransDC.Commit;
Result := True;
end;
except
MasterDataDC.TransDC.Rollback;
Result := False;
end;
aTable.Open;
if Assigned ( aTable ) then aTable.Refresh;
aTable.Close;
end ;

after this i have this statement

IBQuery.SQL.Add('Select Sum(SumField) AS Sum_Field from IBTable where
(Field=:Field)');
IBQuery.ParamByName('Field').AsInteger:=AInteger;
IBQuery.Open;
I:=IBQuery.FieldByName('Sum_Field').asInteger;

after this the value of sum is 0
but if i closed the application and i opened again then i have the result
why?
where is the problem?

Thank you






Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (SQL Servers) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.