Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » DBISAM Technical Support » Support Forums » DBISAM General » View Thread |
Messages 1 to 8 of 8 total |
Edits over a filtered field |
Thu, Apr 23 2009 5:51 AM | Permanent Link |
Paul Baumann | Hi all,
in an older application i am using V2.12. now i am implemeting a function where user can initiate a batch edit, lets say write in the field "groups" the value "sponsor". the problem ocurrs, if one sets a filter right to the editing field, lets say "groups IS NULL". now in every batch editing job only the half of records is edited. in batch editing i use this code (simplyfied) Table1.First; while not Table1.EOF do begin Table1.Edit; Table1.FindField('Groups').AsString := 'Sponsor'; Table1.Post; Table1.Next; end; i know why only the half records are processed. to do it with a query is no way, cause as i wrote this code above is simplyfied. user is able to configure if he wants to replace the field value with a new value, add the new value to the current field value, or to delete value from current field value and to empty the field. also it should work with text and memo fields. i tried it with a second table, which doesnt belong to the same database. i stepp through Table1, locate and edit the record in Table2. but this didnt change anything. Any tipps for me? Thank you. |
Thu, Apr 23 2009 3:04 PM | Permanent Link |
"Jeff Cook" | Paul Baumann wrote:
> > Table1.First; > while not Table1.EOF do > begin > Table1.Edit; > Table1.FindField('Groups').AsString := 'Sponsor'; > Table1.Post; > Table1.Next; > end; > > i know why only the half records are processed. to do it with a query Kia Orana Paul The problem is that when you post the changed record to the table, it now doesn't satisfy the filter. This means the cursor must move to another record. Then you say "Next" which hops over that record. Simply change the .Next to .First and you should be fine. Kia Manuia Jeff -- Jeff Cook Aspect Systems Ltd www.aspect.co.nz + Joan and Jeff Cook The Cooks Oasis www.cookislandsoasis.com |
Fri, Apr 24 2009 2:38 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Jeff
>> Table1.First; >> while not Table1.EOF do >> begin >> Table1.Edit; >> Table1.FindField('Groups').AsString := 'Sponsor'; >> Table1.Post; >> Table1.Next; >> end; >> >> i know why only the half records are processed. to do it with a query > >Kia Orana Paul > >The problem is that when you post the changed record to the table, it >now doesn't satisfy the filter. This means the cursor must move to >another record. Then you say "Next" which hops over that record. > >Simply change the .Next to .First and you should be fine. That will only work if none of the records satisfy the filter, if you ever hit one that satisfies the filter after being altered you have an infinite loop. What's needed is something like: Table1.First; oldid := Table1.FieldByName(idfield).AsString; while not Table1.EOF do begin Table1.Edit; Table1.FindField('Groups').AsString := 'Sponsor'; Table1.Post; if Table1.FieldByName(idfield).AsString = oldid then Table1.Next; oldid := Table1.FieldByName(idfield).AsString; end; Roy Lambert [Team Elevate] |
Fri, Apr 24 2009 5:35 AM | Permanent Link |
Paul Baumann | Roy Lambert wrote:
That will only work if none of the records satisfy the filter, if you ever hit one that satisfies the filter after being altered you have an infinite loop. What's needed is something like: Table1.First; oldid := Table1.FieldByName(idfield).AsString; while not Table1.EOF do begin Table1.Edit; Table1.FindField('Groups').AsString := 'Sponsor'; Table1.Post; if Table1.FieldByName(idfield).AsString = oldid then Table1.Next; oldid := Table1.FieldByName(idfield).AsString; end; ---------------------- Thanks for answers. yeah, Roy, thats it sometimes you dont see the forest cause of all the trees |
Fri, Apr 24 2009 6:41 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Paul
>yeah, Roy, thats it >sometimes you dont see the forest cause of all the trees I have been lost in that particular forest many times for many hours Roy Lambert [Team Elevate] |
Fri, Apr 24 2009 3:58 PM | Permanent Link |
"Jeff Cook" | Roy Lambert wrote:
> > That will only work if none of the records satisfy the filter, if you > ever hit one that satisfies the filter after being altered you have > an infinite loop. What's needed is something like: > True, Roy But the original poster said there was a filter of "groups IS NULL", so setting groups to anything except NULL will ensure it doesn't satify the filter. Unless of course empty fields were treated as NULL, which reminds me of a debate somewhere -- Jeff Cook Aspect Systems Ltd www.aspect.co.nz + Joan and Jeff Cook The Cooks Oasis www.cookislandsoasis.com |
Sat, Apr 25 2009 4:00 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Jeff
>But the original poster said there was a filter of > >"groups IS NULL", > >so setting groups to anything except NULL will ensure it doesn't satify >the filter. Unless of course empty fields were treated as NULL, which >reminds me of a debate somewhere Forcing myself to ignore the deliberate provocation you're right and in that specialised case your solution would work. How much would you like to bet that the OP doesn't have other filters? Roy Lambert [Team Elevate] |
Mon, Apr 27 2009 3:19 PM | Permanent Link |
"Jeff Cook" | Roy Lambert wrote:
> > Forcing myself to ignore the deliberate provocation you're right > and in that specialised case your solution would work. How much would > you like to bet that the OP doesn't have other filters? > > Roy Lambert [Team Elevate] Deliberate provocation? Moi? -- Jeff Cook Aspect Systems Ltd www.aspect.co.nz + Joan and Jeff Cook The Cooks Oasis www.cookislandsoasis.com |
This web page was last updated on Tuesday, April 23, 2024 at 08:10 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |