Forums › Forums › SIMPOL Programming › when you delete a record
- This topic has 2 replies, 3 voices, and was last updated 11 years, 1 month ago by Michael.
- AuthorPosts
- March 21, 2013 at 7:49 pm #321Jean ValleeParticipant
when I delete a record, does the index pointer (the index that was used to select this record) automatically advance to the next record? I’m trying to read thru the records in one file and see if they exist in another. if not delete the record. In SB I did not have to do a select next after a delete but Simpol can’t seem to do a select next or selectcurrent after a delete. I get an error 907. What seems to work is to save the key in a variable, delete the record, then do another selectkey using the saved value and then the index pointer will advance although with a not exact match error. Am I understanding this correctly? Jean
March 21, 2013 at 11:01 pm #2204JD KromkowskiParticipantOn 03/21/13 3:49 PM, JV wrote:
> when I delete a record, does the index pointer (the index that was used
> to select this record) automatically advance to the next record?
>
> I'm trying to read thru the records in one file and see if they exist in
> another. if not delete the record.
>
> In SB I did not have to do a select next after a delete but Simpol can't
> seem to do a select next or selectcurrent after a delete. I get an error
> 907.
>
> What seems to work is to save the key in a variable, delete the record,
> then do another selectkey using the saved value and then the index
> pointer will advance although with a not exact match error.
>
> Am I understanding this correctly?
>
> Jean
>
>Neil and Jim will know but I think this is a case of "deleting a record"
does not actually delete the record until there is a commit.Is that correct?
JDK
March 25, 2013 at 10:24 pm #2205MichaelKeymasterOn 21/03/2013 19:49, JV wrote:
> when I delete a record, does the index pointer (the index that was used
> to select this record) automatically advance to the next record?
>
> I'm trying to read thru the records in one file and see if they exist in
> another. if not delete the record.
>
> In SB I did not have to do a select next after a delete but Simpol can't
> seem to do a select next or selectcurrent after a delete. I get an error
> 907.
>
> What seems to work is to save the key in a variable, delete the record,
> then do another selectkey using the saved value and then the index
> pointer will advance although with a not exact match error.
>
> Am I understanding this correctly?
>
> Jean
>
>The following is directly from the databaseforms.sma (which you have on your system as well). As you can see, you are responsible
for reading the next/previous record in the current index order to ensure that you have one after this one is deleted.Ciao, Neil
function dataform1record.delete(dataform1record me, integer error) information "[simpol::return::]"
integer e
type(db1record) r
boolean continuee = 0
if me.record =@= .nul
error = iERR_OBJECTNOTFOUND
me.isdirty = .false
else
continue = .true
if me.ondeleterecord.function !@= .nul
if me.ondeleterecord.reference =@= .nul
continue = me.ondeleterecord.function(me)
else
continue = me.ondeleterecord.function(me, me.ondeleterecord.reference)
end if
end ifif continue != .false
// Grab the next record so that there will be one when we are done
r =@ me.record.select(error=e)if e != 0 and (e == iERR_PPCSEOF or e == iERR_NORMALENDOFDATA)
e = 0
r =@ me.record.select(previousrecord=.true, error=e)
end ifme.record.delete(error=e)
if e != 0
error = e
else
me.isdirty = .false
// Assign the newly selected record in its place
me.record =@ r
end if
end if
end if
end function - AuthorPosts
- You must be logged in to reply to this topic.