create record on appserver - unique id from sequence

Posted by vrtik on 07-Dec-2010 03:59

Hi All

When i create a record on appserver i also need to create unique record id number. We use sequences to create this. Unfortunatelly the field with id is not populated in database trigger.

FOR EACH ttHeaderBefore TRANSACTION :
    FIND ttHeader WHERE ROWID(ttHeader) = BUFFER ttHeaderBefore:AFTER-ROWID EXCLUSIVE-LOCK NO-ERROR.


validation ...

    IF errorMessage = '' THEN
    DO:
    

      I think that the id number could be populated somewhere here or maybe after save-row-changes.


        BUFFER ttHeaderBefore:SAVE-ROW-CHANGES().
        IF BUFFER ttHeaderBefore:ERROR THEN DO:
            END.
       
        BUFFER ttHeaderBefore:ACCEPT-ROW-CHANGES ().
    END.
    ELSE
    DO:
        DATASET dsHeader:ERROR = TRUE.
        BUFFER ttHeader:ERROR = TRUE.
        BUFFER ttHeader:ERROR-STRING = errorMessage.
    END.
END.

Thank you

Peter

All Replies

Posted by Admin on 07-Dec-2010 05:00

I think that the id number could be populated somewhere here or maybe after save-row-changes.

You could populate it before save-row-changes in the temp-table (the after-table).

Posted by vrtik on 07-Dec-2010 06:37

Thank you Mike

I did try this but without success.

IF errorMessage = '' THEN
    DO:
   

        ttHeader.hdr_id = next-value (hdrnum).            


        BUFFER ttHeaderBefore:SAVE-ROW-CHANGES(1,"hdr_id").
        IF BUFFER ttHeaderBefore:ERROR THEN DO:
            END.
       
        BUFFER ttHeaderBefore:ACCEPT-ROW-CHANGES ().
    END.


Thanks

Peter

Posted by Admin on 07-Dec-2010 07:30

ttHeader.hdr_id = next-value (hdrnum).

>

>        BUFFER ttHeaderBefore:SAVE-ROW-CHANGES(1,"hdr_id").

Well, adding the field to the skipped field list of the SAVE-ROW-CHANGES method won't be to helpful when you want the field in the DB table to be populated from the temp-table field...

Posted by vrtik on 07-Dec-2010 08:02

Thanks a lot.

You opened my eyes. I did try too many variations so i confused myself .

Peter

This thread is closed