Board index » off-topic » add table totals

add table totals


2006-03-23 03:29:37 PM
off-topic3
I would like to thank the forum moderators and all the participants for helping me out in this forum. Great job guys!
now to bug you again:
I have this table and its got a field name called value.
I would like to add up all the values and then purge it from the database.
any suggestions?
Thank you
werner
 
 

Re:add table totals

"Werner" < XXXX@XXXXX.COM >wrote
Quote
now to bug you again:
I have this table and its got a field name called value.
I would like to add up all the values and then purge it
from the database. any suggestions?
Yes. Just the standard suggestions:
(1) Tell us what type of table you are working with.
(2) Tell us whether it is the field that you want
removed the table or the table that you want
removed from the database.
--JohnH
 

Re:add table totals

Quote
Yes. Just the standard suggestions:
(1) Tell us what type of table you are working with.
(2) Tell us whether it is the field that you want
removed the table or the table that you want
removed from the database.
--JohnH
Hi
1. its a .dbf file
2. i want to clear the contents of the field int that database, maybe even purge it to another backup database?
3. i want to add the total value of all the integers in that field before i purge it.
 

{smallsort}

Re:add table totals

"Werner" < XXXX@XXXXX.COM >wrote
Quote
1. its a .dbf file
3. i want to add the total value of all the integers in that field
before i purge it.
2. i want to clear the contents of the field int that database,
maybe even purge it to another backup database?
Werner, Assuming that your table has persistant fields
defined and is open, then you could probably use something
like the following (untested) code. Rgds, JohnH
MyInt64 := 0;
MyTable.First;
While not MyTable.EOF do begin
MyInt64 := MyInt64 + MyTableMyIntField.AsInteger;
MyTable.Next;
end;
MyTable.First;
While not MyTable.EOF do begin
MyTableMyIntField.Clear;
MyTable.Next;
end;
 

Re:add table totals

Quote
Werner, Assuming that your table has persistant fields
defined and is open, then you could probably use something
like the following (untested) code. Rgds, JohnH
MyInt64 := 0;
MyTable.First;
While not MyTable.EOF do begin
MyInt64 := MyInt64 + MyTableMyIntField.AsInteger;
MyTable.Next;
end;
MyTable.First;
While not MyTable.EOF do begin
MyTableMyIntField.Clear;
MyTable.Next;
end;
Thank you for your help. Tell me... Would this code add all the
records in my database within that field?
I am still a novice in Delphi so can
you please explain to me what MyInt64 := 0 means?
And also what EOF means. i know it might sound silly to you but i love Delphi i just get stuck some times. I also love
to try figuring it out myself but this time i am a bit stuck.
Thank you
Regards Werner
 

Re:add table totals

Quote
>MyInt64 := 0;
>MyTable.First;
>While not MyTable.EOF do begin
>MyInt64 := MyInt64 + MyTableMyIntField.AsInteger;
>MyTable.Next;
>end;
>MyTable.First;
>While not MyTable.EOF do begin
>MyTableMyIntField.Clear;
>MyTable.Next;
>end;
Werner wrote
Would this code add all the records in my database within
that field?
A "database" may have any number of "tables". The code
above will sum one column of one of the tables.
Quote
please explain to me what MyInt64 := 0 means?
I should have indicated that by "MyInt64" meant that I was
assuming that you would define a local variable "MyInt64"
of type Int64 in your code, before its begin statement.
var MyInt64: Int64;
Quote
And also what EOF means.
EOF (End Of File) is a "method" of the table object MyTable
that returns true when the table's cursor is pointing just past
the end of the table.
If you are new to all of this, you should not be using the BDE
because it is becoming obsolete. Look up posts by Bill Todd
in this newsgroup; to find good suggestions for alternatives.
Regards, JohnH
 

Re:add table totals

Thank you very much for your response and paitence.
i love programing in Delphi.
Is paradox maybe a better route to go? i do not know much about other formats and i do not know where to look for free
online hepl guides. i have a book that you can teach
yourself delphi in 21 days but it does not feature much
bout the other table formats. Also in paradox i found that
i cant make an index field like in dbf. Please could
you advice of what format to use.
Thank you very much
Werner