error handling in write trigger not working

Author: lalitpct@gmail.com (lalitpct)

 

Hi All,

Not sure why  in uniface 8.4 ,errror handling in write trigger is not showing expected behaviour.

as shown in the below logs

xI/O function: W, mode: 0, on file/table: mis_postings length: 69              x
xERROR 60093: Country/Branch Closed in static..branches_extra                  x
x(User raiserror Error=60095)                                                  x
x                                                                              x
x(WRIT) WRIT:4  [-3] if ($status < 0)                                          x
x(WRIT) WRIT:5  [-3] putmess "value is %%$status "                             x
xvalue is -3                                                                   x
x(WRIT) WRIT:6  [-3] message "Store error; see message frame" 

 

database has some error ((User raiserror Error=60095)) while storing which returns [-3] , which i have captured as well.

value captured in $status is -3 but the message is not prompted on the screen.

also the log also seems bit weird meaning normally the logs should be as below

(WRIT) WRIT:4  if ($status < 0)   and not  (WRIT) WRIT:4  [-3] if ($status < 0)  

It seems [-3] disables the normal functioning of the code

Does anyone have an idea about it ?

 

 

7 Comments

  1. ... please read the documentation:

    putmess

    Append text to the message frame.


    Author: ulrich-merkel (ulrichmerkel@web.de)
  2. i know putmess doesnt prompt anything ,but message should have prompted .

    I used putmess just to check whether $status is less than 0 or not

    message "Store error; see message frame" 


    Author: lalitpct (lalitpct@gmail.com)
  3. Hello, in fact, "message" just puts a message in the message area (and you can see it in its history and the bottom of Uniface window). If you want some kind of prompt, that is some interaction from user, you can use "message/error", for example (or "askmess" of course). Zdenek


    Author: sochaz (zdenek.socha@fullsys.cz)
  4. This is a question about Uniface 8.4. Why post this in Uniface 9 Bugs Errors? about the [-3] in your file: are you sure you are looking at a normal log and not a proc trace?


    Author: Theo Neeskens (tneeskens@itblockz.nl)
  5. Hi I think it is still a bug ,but if it is not i will try to move it to the section you mentioned , apology if it caused inconvenience

    I am debugging in the application it self and hence i feel the [-3] should not have been displayed , I have put more elaborate logs now.

    (WRIT) WRIT:1  UPDATE_USER_ID.MIS_POSTINGS = $$SYS_USER_ID                    x
    x(WRIT) WRIT:2  UPDATE_DATE.MIS_POSTINGS = $datim                              x
    x(WRIT) WRIT:3  write                                                          x                                                           ------------------------> here it is normal
    xI/O function: W, mode: 0, on file/table: mis_postings length: 69              x
    xif (@@trancount = 0) begin transaction                                        x
    xinsert into mis_postings (reference, template, year, month, eop_amount,       x
    xavg_amount, rev_amount, pool_amount, update_user_id, update_date,             x
    xu_version)                                                                    x
    xvalues (4283.0, 101.0, 2010, 10, 0.0,                                         x
    x10000000.0, 0.0, 0.0, 39, '04/04/2011 03:46:34.00',                           x
    x'!')                                                                          x
    x                                                                              x
    xERROR 60093: Country/Branch Closed in static..branches_extra                  x

    (User raiserror Error=60095)                                                  x
    x                                                                              x
    x(WRIT) WRIT:4  [-3] if ($status < 0)                                          x                                ---------------------------------> here returned value is in bracket
    x(WRIT) WRIT:5  [-3] putmess "value is %%$status "                             x
    xvalue is -3                                                                   x
    x(WRIT) WRIT:6  [-3] message "Store error; see message frame"                  x
    x(WRIT) WRIT:7  [-3] return (-1)                                               x
    x(STOR) CHANGES1:30  [-35] if ($status < 0)                                    x
    x(STOR) CHANGES1:31  [-35] message "Store error; see message frame"            x
    x(STOR) CHANGES1:32  [-35] return (-1)                                         x
    x(STOR) PROPAGATE:41  endif                                                                                       ------------->here returned value is not in bracket
     

     

     

     

     

     

     


    Author: lalitpct (lalitpct@gmail.com)
  6. Hi

    There is no wrong behavior at all :-)


    (WRIT) WRIT:4 [-3] if ($status < 0)
    The [-3] behind the line number shows the current value of $STATUS (if not 0)


    (WRIT) WRIT:5 [-3] putmess "value is %%$status "
    PUTMESS write the string to the logfile and do not prompt anything


    Suggenstion:

    variables
    numeric v_STATUS
    string v_PEC
    endvariables
    ...
    write
    IF($status<0)
    v_STATUS=$status
    v_PEC=$procerrorcontext
    call SE_ERROR(v_STATUS,v_PEC,"")
    RETURN(v_STATUS)
    ENDIF
    ...


    ENTRY SE_ERROR ;(could be a global procedure)
    params
    numeric v_STATUS:IN ; $status will set to 0 on entering entry
    string v_PEC:IN ; $procerrorcontext will set to "" on entering entry
    string v_PARA:IN
    endparams
    variables
    string v_DBERROR
    endvariables
    v_DBERROR=$dberror ; Save other internal values

    putmess "error %%v_status%%% on writing"
    putmess " PEC= '%%v_PEC%%%'"
    putmess " DBERROR='%%vDBERROR%%%'"
    message/error "error %%v_status%%% on writing%%^(see message frame)","Ok"
    END


    Author: istiller (i2stiller@gmx.de)
  7. i know putmess doesnt prompt anything ,but message should have prompted .

    I used putmess just to check whether $status is less than 0 or not .

    But after that I have mentioned below statement , which seems to be executed but it doesnt propmpt on the screen.

    It seems like it is not effective

    message "Store error; see message frame" 


    Author: lalitpct (lalitpct@gmail.com)