Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » DBISAM Technical Support » Support Forums » DBISAM General » View Thread |
Messages 1 to 5 of 5 total |
Using .Next with queries |
Mon, Aug 18 2008 10:42 PM | Permanent Link |
Pat | Hi all,
I have 5 records in table tblBins and a query qryBins as follows: tblBins.Refresh; with qryBins do begin qryBins.Close; SQL.Clear; SQL.Add('SELECT BinCode, LastOrderNumber, Available '); SQL.Add('FROM Bins'); SQL.Add('WHERE LastOrderNumber= :TheOrderNumber'); ParamByName('TheOrderNumber').AsString := InitialOrderNumber; qryBins.ExecSQL; end; qryBins.First; while not qryBins.Eof do begin qryBins.Edit; qryBinsAvailable.Value:=True; qryBins.Post; qryBins.Next; end; With qryBins.Next; as is, only the 1st, 3rd, 5th records get edited BUT if I // out that line, all the table records are edited. Also, in other code I have I use qrySomeName.Next and it processes all the records. Is there a reason for this? Using v4.21 Build 11 Regards, Pat |
Tue, Aug 19 2008 1:46 AM | Permanent Link |
Pat | > ParamByName('TheOrderNumber').AsString := InitialOrderNumber;
I now figure out that I need the qryBins.Next; ONLY if the value of InitialOrderNumber = '' The following works OK qryBins.First; while not qryBins.Eof do begin qryBins.Edit; qryBinsAvailable.Value:=True; qryBins.Post; if InitialOrderNumber = '' then qryBins.Next; end; |
Tue, Aug 19 2008 2:09 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Pat
Normally when you see that sort of behaviour its because the new value breaks a filter condition. This would apply with a sensitive result set as well, but in your case, from the code shown this doesn't seem to be the case. The "fix" you've applied is exactly what you need to do - test if the filter condition is broken so I'm guessing setting Available affects LastOrderNumber. I'd recommend that, unless the code you've shown is simplified, or you need qryBins elsewhere, that you switch to just using an sql UPDATE statement eg UPDATEBins SET Available = TRUE WHERE LastOrderNumber= :TheOrderNumber Roy Lambert |
Tue, Aug 19 2008 11:02 AM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Pat,
<< With qryBins.Next; as is, only the 1st, 3rd, 5th records get edited BUT if I // out that line, all the table records are edited. >> Is the query returning a live result set ? If so, then the primary key for the table will be used to order the result set, and any edits will be subject to that ordering/repositioning if you modify one of the fields that comprise the primary key. -- Tim Young Elevate Software www.elevatesoft.com |
Tue, Aug 19 2008 9:16 PM | Permanent Link |
Pat | Thanks Roy and Tim for the info, it makes more sense now
|
This web page was last updated on Tuesday, May 7, 2024 at 06:25 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |