Skip to content

when you delete a record

Forums Forums SIMPOL Programming when you delete a record

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #321
    Jean Vallee
    Participant

    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

    #2204
    JD Kromkowski
    Participant

    On 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

    #2205
    Michael
    Keymaster

    On 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 continue

    e = 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 if

    if 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 if

    me.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

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.