Newbie question about moving thru table line by line 
Author Message
 Newbie question about moving thru table line by line

Well, I said it was late -- the SQL function you need is SUM
and it goes something like this

SELECT SUM(Number_Type-Column) FROM YourTable
WHERE
SomeBooleanColumn = TRUE;

Something like that, anyway. You can, of course join lotsa tables to
create this query.

Good luck,
DK



Wed, 18 Jun 1902 08:00:00 GMT  
 Newbie question about moving thru table line by line

Quote:
>I am new to Delphi and I am trying to write a small program that moves
>through a table record by record, starting and ending at date values
>specified by the user, and for each record checks if a field is set to true,
>in which case the value of another field is added to a running total. I have
>some programming knowledge in C and BASIC so I'm pretty sure I can figure out
>how to do the fairly simple if statement for each row, but what I need to
>know is how to move thru a table a record at a time and obtain the value of
>each field. I would appreciate any assistance. Thanks!

>Oh yeah, I'm using Delphi 4 Professional, and I have already got the table
>displayed in the program using DataSource, Table and DBGrid components.

If your table isn't that big then the best way to handle this is just to go
into a while loop:

while not Table1.Eof do
begin
     if (Table1.FieldByName('YourFieldNameHere').AsString = 'True') and
         (Table1.FieldByName('YourDateField').AsDate = YourDate) then
            do some stuff
     Table1.Next;
end;

If you have a large table the best thing to do is to use a Query object as{*filter*}
as already suggested.

********************************
Michael Glatz              


Accept that some days you're the pigeon,
some days you're the statue.



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Read file line per line

2. Can I turn 26 line mode to 50 line mode

3. Moving lines around the screen

4. Blank line between lines: HELP!

5. Trouble printing a BST line by line

6. total details max 10 datail lines in table

7. Starting a table search after inquiry line is entered

8. Newbie Question - Creating Access Table at Runtime

9. newbie question: printing tables

10. NEWBIE QUESTION: What table structure to use?

11. Newbie question on displaying tables from Interbase

12. How to read two lines of input in Pascal but treat it as one line?

 

 
Powered by phpBB® Forum Software