Re: How to get full error message?
Posted in 1994
Topics: Error Codes & Troubleshooting, Connectivity: ESQL/C, 4GL & Embedded SQL, Migration, Import/Export & Data Conversion
>
> 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?
>
> Thanks,
> Richard
> --
> +----------------------------+-------------------------------------------+
> | Dr. Richard Spitz | INTERNET: spitz@ana.med.uni-muenchen.de |
> | EDV-Gruppe Anaesthesie | Tel : +49-89-7095-3421 |
> | Klinikum Grosshadern | FAX : +49-89-7095-8886 |
> | 81366 Munich, Germany | |
> +----------------------------+-------------------------------------------+
>
I have include a error function which resolves %s using sqlca.sqlerrm
/* ###################### error function (ESQL-C) ####################### */
#include <stdio.h>
$include sqlca;
static sql_errlog (in_str,line)
char *in_str; /* String to include in error message */
int line; /* line # */
{
static FILE *errfp = NULL;
char tmpbuf[200];
if (!errfp) { /* if file already not opened */
if ((errfp = fopen ("errlog","w")) == NULL) {
fprintf (stderr,"Cannot open error file");
return (0);
}
}
fprintf (errfp ,"ERROR:%d:line %d:%s\\n",sqlca.sqlcode,line,in_str);
rgetmsg (sqlca.sqlcode,tmpbuf,199);
if (sqlca.sqlerrd[4])
fprintf (errfp ,"position:%d\\n",sqlca.sqlerrd[4]);
fprintf (errfp ,tmpbuf,sqlca.sqlerrm); /* %s resolutions */
fflush(errfp);
}
+---------------------------+--------------------------+
| G.T.Madavan, | e-mail: gtmad@smi.mn.org |
| Systems Migration Inc., | Phone : (612) 890-0040 |
| Burnsville, MN, U.S.A | Fax : (612) 890-0966 |
+---------------------------+--------------------------+