Q: Updating all rows in a table...

Q: Updating all rows in a table...

Post by J?rgen Aas » Sun, 31 Dec 1899 09:00:00



I'm writing a D2 app with paradox.

I won't to update a all fields called index in a table. But the values
must increment.
If I use a TQuery I can do this:

var
  i: Integer;
begin
  i := 1;
  mytable.First;        
  while not mytable.eof do begin
    mytable.Edit;
    mytable.FieldByName('Indeks').AsInteger := i;
    mytable.Post;
    mytable.Next;
    Inc(i);
  end;
end;

...but this is slow because the table is very big. Is there another way
to do this like:

update index increment by 1

or something (in my dreams)

Thanks!

--
J?rgen Aase    
Schleppegrellsgt 2B
0556 OSLO
22 71 44 28

 
 
 

Q: Updating all rows in a table...

Post by Marcai » Sun, 31 Dec 1899 09:00:00


I think I saw something like this in a book about SQL:

update table_1 set ff = ff + 1

So you should use:

Query.SQL.Add('UPDATE TABLE_1 SET FF = FF + 1');
Query.ExecSQL;

Yep, I just tested. I works.

Marco

 
 
 

Q: Updating all rows in a table...

Post by NNOO » Sun, 31 Dec 1899 09:00:00


You may wanna acquire an exclusive lock on the table. That will
help eliminate the extra over head attached with locking each
individual record.

Regards,
Nasir

 
 
 

1. update from another table row by row

David,

This looks like a homework assignment.  Forgive if it is not.  Anyway, I am
very confused as to what you are trying to do.  If this is not a homework
assignment please provide some example data and an understanding as to why
you want to create a table with the data column from table2 entered into the
table twice?  I must admit, looking at your SQL is very confusing.

Brian

2. deadlock issue..

3. Updating a Table by selecting row by row

4. automated email on trigger?

5. Updating a row column of a table using values from another row column

6. Execute an EXE File is Service Agent

7. Using a trigger to update a time field in a table when a row is updated

8. UPDATE MULTIPLE ROWS IN ONE TABLE OBTAINING SUMS FROM ANOTHER TABLE

9. How to Update rows in a table from fields in second table

10. newbie qs; examining databases and tables

11. SQL Server update error: row cannot be update for updating