简体   繁体   中英

Progress 4GL BUFFER-COPY FAILS

DO ON ENDKEY UNDO, LEAVE:
    FIND FIRST STUDENT NO-LOCK WHERE ST-ID = "TEST" NO-ERROR.
    IF AVAILABLE STUDENT THEN    
    DO:
       CREATE SCHOOL no-error.
       BUFFER-COPY STUDENT EXCEPT STUDENT.Location
       SCHOOL ASSIGN SCHOOL.Location = "MY LOCATION" NO-ERROR.
       IF ERROR-STATUS:ERROR THEN 
       DO:
           DO i = 1 TO ERROR-STATUS:NUM-MESSAGES:   
              MESSAGE 
                " Error no " ERROR-STATUS:GET-NUMBER(i) 
               " txt: " ERROR-STATUS:GET-MESSAGE(i) VIEW-AS ALERT-BOX.
               STOP.
          END.
       END.
   END.

END.

This query is working fine but some time it was creating Empty Record. buffer-copy through some error that why it create empty record but i am not able verify the error because code was happen in LIVE. please help me how to FIX the problem. what type of error buffer-copy will through. 1000 times working fine 1 time it will FAIL. i know this is data defect but how to FIX. otherwise what type of errors BUFFER-COPY through.

Since you really don't know what errors occur - you need to start there.

To track general errors after a NO-ERROR statement you can do something like:

IF ERROR-STATUS:ERROR THEN DO:
  DO i = 1 TO ERROR-STATUS:NUM-MESSAGES:
    /* Replace MESSAGE with some kind of logging */
    MESSAGE 
      "Error number " i 
      " error no " ERROR-STATUS:GET-NUMBER(i) 
      " txt: " ERROR-STATUS:GET-MESSAGE(i) VIEW-AS ALERT-BOX.
  END.
END.

Once you have the specific error number(s) you can search the Progress Knowledge Base for more information.

I would write the code as follow. If you use no-error always handle the error. When assigning/buffer copy check if no error then do a validate to confirm that triggers fire correctly. The error handling code can be put in its own procedure and then just called every time you wish to process error messages. (amended it a bit as I would write it, I do not always trap all errors, but error handling depends on various things, but it is a good way during testing to make sure code is setup correctly. Afterwards can remove error handling where not needed before deploying.)

FIND FIRST STUDENT NO-LOCK WHERE ST-ID = "TEST" NO-ERROR.
IF AVAILABLE STUDENT THEN    
DO:
  CREATE SCHOOL.
  BUFFER-COPY STUDENT EXCEPT STUDENT.Location
           TO SCHOOL ASSIGN   SCHOOL.Location = "MY LOCATION" 
  NO-ERROR.
  IF ERROR-STATUS:ERROR THEN 
  DO:
    /* insert error handling - for example as as per @Jensd */
    /* this is in case there is something wrong with buffer copy */
    /* maybe a required field is left empty? */
  END.
  ELSE DO:
      VALIDATE SCHOOL NO-ERROR. /* good idea as it raises any issues with triggers */
      IF ERROR-STATUS:ERROR THEN 
      DO:
        /* insert error handling - for example as as per @Jensd */
      END.
  END.
END.    

I will not make a buffer-copy from one to other table stright, you might have index issues as i think you are having.

Better define a temp-table like the target table.

Then make a buffer copy to the temp-table.

Set the rigth key into the temp-table.

Then make a buffer copy from the temp table with the right key fields to the target table.

Try as follow:

Define temp-table t-school like school.

find first student no-lock and so on.

buffer-copy student to t-school.

Assign t-school.location = "whatever".

buffer-copy t-school to school.

Voila!

调试问题的一种可能方法是使用AppBuilder的“帮助”下的“最近的消息”,前提是您可以直接从中运行代码。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM