Rowstate for an array in OpenRoad Ingres

In article <408lpm$6d4@lynx.unm.edu>, rfalanga@numex.unm.edu (Rod Falanga) says:
>
>I have a frame with a tablefield on it.  I wanted to use control
>button to the upper right of the table field as a means by which
>someone could add new rows, delete rows, etc.  I thought that I could
>query the row's _RowState attribute to determine what had happened to
>that row (if it had been added, or deleted, or whatever), and thus I
>could do the appropriate action to the table from which the data had
>come from.
>
>So then, I executed the frame (from within OpenROAD) and deleted a
>couple of the rows at the beginning of the table.  Then my script
>entered a loop in which it checked each row's _RowState.  I was very
>surprised to find that the rows that I had deleted on the tablefield
>were marked with the rowstate setting of RS_UNCHANGED?!
>
>What's going on here?  Am I misunderstanding what the RowState
>settings are supposed to be?  How can I determine if a row has been
>deleted or not from a tablefield (if I cannot use the _RowState
>attribute)?
>
>Rod
>
>
hi

I've just be doing the same thing.  
Rows with state RS_CHANGED should go to RS_DELETED if you delete them.

i used the following line:

    array.SetRowDeleted(RowNumber = FIELD(array).CurRow);

This changed the state to RS_DELETED.
The following code to delete.
 
    FOR i = array.FirstRow TO array.LastRow DO
        IF array[i]._ROWSTATE = RS_DELETED THEN
            DELETE ...;
        ENDIF;
    ENDFOR; 

Make sure you start your loop from array.FirstRow not 1. As all
deleted rows become 'non-positive'.

See also the fence diagram 6-14 openroad programming guide. This explains
the mysteries of _ROWSTATE. They've gone to alot of trouble here.

ps. I recommend that you delete the row from the database immediately
rather than looping. As if you allow the user to change key 
values and the new inserted row is before the deleted row
both rows has the same key value you will get a duplicate key error.
Alternatively delete all RS_DELETED rows in a separate loop
before you do any INSERTs or Updates. 

I hope that helps. 

grassom@dpi.qld.gov.au
Ingres Q & A
To William's Home Page

© William Yuan 2000

Email William