Re: How to get full error message?
Posted in 1994
In article 2immpvINNaj8@emory.mathcs.emory.edu, rob@dssmktg.com (Robert Minter) writes: >From Richard Spitz: >* >* Hi folks, >* >* just a couple of weeks ago, there was a thread in this group about how >* to get the full error message in an ESQL/C program, using the rgetmsg() >* function. At that point, I was SURE I'd NEVER have to use this. Well,... >* >* This function works fine, however, the output is like: >* -217: Column (%s) not found in any table in the query. >* >* Could somebody please re-post or preferably mail me the solution on how >* to get the "%s" resolved? > >From what I've found playing around with the err_get in 4gl is that >when an error occurs, the replacable parameters to be put into the >string returned by err_get() ( rgetmsg() for ESQL/C ) are found in the >sqlca.sqlerrm variable. > >Hope this helps, > > Robert Minter |Data Systems Support| \\\\\\_/// >Programmer, Software Development | Orange, CA | ( _ _ ) >internet: rob@dssmktg.com | Tel: 714.771.0454 | (| ^ |) >bangpath: uunet.uu.net!dssmktg!rob| Fax: 714.771.3028 | \\`-'/ > I used to not know, now I know I don't know. \\_/ This is true in the RDS version. In the compiled version the "%S" will be replaced for you. I do not think you can comlain to Informix since it is not officially supported. Try the following in your code - it works nice.... Use the statement "WHENEVER ERROR CALL err_rtn" (this function). It will not replace the "%S" but it pops up a window and records the error the the errorlog (Informix errorlog / startlog) -----------------------------------------CUT HERE--------------------------------- ############################################################################## # Routine : err_rtn # # Purpose : This function is called "WHENEVER ERROR" error is encountered # It will record the error, notify the user and exit gracefully # # Arguments : none # # Returns : NEVER!! ############################################################################## function err_rtn() define sql_err smallint define str char(255) define ans char(1) define x smallint define p_err array[4] of char(70) define y smallint define z smallint define strx char(80) define errm char(80) WHENEVER ERROR STOP #THIS MUST BE STOP - as it cannot call itself!!! let sql_err = status for x = 1 to 4 initialize p_err[x] to NULL end for call err_get(sql_err) returning str let y = 1 let z = 1 for x = 1 to length(str) if (str[x,x] < ascii 15 ) then let p_err[y] = str[z,x-1] let z = x + 1 let y = y + 1 end if end for let p_err[y] = str[z,x] #get the last line open window w_err at 5,3 with 8 rows, 75 columns attribute (border, prompt line last, form line first) display " INFORMIX ERROR # ", sql_err at 4,25 attribute(REVERSE, BOLD) let errm = sqlca.sqlerrm let y = length(sqlca.sqlerrm) for x = 1 to y if (errm[x,x] < ascii 15 ) then let errm = errm[1,x-1] end if end for for z = 1 to 4 let y = length(p_err[z]) let str = p_err[z] for x = 1 to y if (str[x,x+1]= "%s") then let strx = str[x+2,y] let str = str[1,x-1], errm clipped let p_err[z] = str clipped, strx clipped exit for end if end for end for let strx = arg_val(0) let strx = "Error occured running: ", strx clipped call errorlog(strx) let strx = "===END ERROR=^^===========================================" call errorlog(strx) display p_err[1] at 5,2 display p_err[2] at 6,2 display p_err[3] at 7,2 display p_err[4] at 8,2 prompt "Press any key to continue ..." for char ans close window w_err exit program 1 end function