Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » DBISAM Technical Support » Support Forums » DBISAM General » View Thread |
Messages 1 to 3 of 3 total |
Indexing bug? |
Sun, Jul 6 2008 2:04 PM | Permanent Link |
Kai Peters | Hi ~
this should be simple - I wonder if this is a bug or am I missing something? In the scenario below, I select a number of rows from the JOBS table into the PRINTQUERY table. I then want to go through all records in the PRINTQUEY table to advance the dates in their WORKDATE field by 7. When my code runs, only one of the records in PRINTQUERY gets updated (the last one). Does anyone have a clue as to how that's possible? (When I inspect PRINTQUERY's primary index, it correctly says 'WorkDate;RecordID' Thanks Kai // ---------------------------- snip ---------------------------- sql := 'SELECT * INTO PrintQuery FROM JOBS WHERE WORKDATE BETWEEN ' + QueryDateStr( Monday ) + ' AND ' + QueryDateStr( Monday + 6 ) + ' ORDER BY WorkDate'; try query := TDBIsamQuery.Create( Self ); query.DatabaseName := DM.dbisamdatabase.DatabaseName; query.SQL.Text := sql; // if _DebugMode then MessageDialog( query.SQL.Text ); // query.ExecSQL; query.Close; // OpenTable( DM.dbisamtable_PrintQuery, '', True, False, True ); // parameters: table, index, excl., readonly, autorepair // // now change their workdates to same day next week DM.dbisamtable_PrintQuery.First; while not DM.dbisamtable_PrintQuery.EOF do begin DM.dbisamtable_PrintQuery.Edit; DM.dbisamtable_PrintQuery.FieldByName( 'WorkDate' ).Value := DM.dbisamtable_PrintQuery.FieldByName( 'WorkDate' ).Value + 7; DM.dbisamtable_PrintQuery.Post; // DM.dbisamtable_PrintQuery.Next; end; // ---------------------------- snip ---------------------------- |
Sun, Jul 6 2008 2:46 PM | Permanent Link |
"Robert" | "Kai Peters" <platysternon@hotmail.com> wrote in message news:C88BE186-1C41-418D-8010-EAAF1E9DF014@news.elevatesoft.com... > Hi ~ > > Does anyone have a clue as to how that's possible? > > (When I inspect PRINTQUERY's primary index, it correctly says > 'WorkDate;RecordID' > It's not only possible, it is highly predictable once you change the key of the current record to make it the last one. Just SELECT WorkDate + 7, and you can skip the loop altogether. Or do the update with SQL "update PrintQuery set workdate = workdate + 7"; Or if you want to keep the loop use another index that does not contain the date (or any other field that you are changing). Robert |
Sun, Jul 6 2008 3:41 PM | Permanent Link |
Kai Peters | Thanks Robert ~
feel like Homer Simpson - duh! K |
This web page was last updated on Friday, March 29, 2024 at 03:30 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |