How to use SQLGLM in Pro*C?
Date: 16 Dec 1994 03:50:07 GMT
Message-ID: <3cr2pf$eah_at_nuscc.nus.sg>
Hi,
I read in the Programmer's Guide to the Oracle Precompilers (ver 1.5)
and came across a section "Getting the Full Text of Error Messages"
(pg 7-11). I failed to get sqlglm(0 to work and will like to seek
help from the net.
Thanks in advance for any help,
Choon Long
(email: cllim_at_maxtor.com)
#include <stdio.h>
EXEC SQL BEGIN DECLARE SECTION;
VARCHAR username[20]; VARCHAR password[20]; EXEC SQL END DECLARE SECTION;
EXEC SQL INCLUDE sqlca;
void sqlerror(); /* handles unrecoverable errors */
main()
{
strcpy(username.arr, "wronguser"); /* copy the username */ username.len = strlen(username.arr); strcpy(password.arr, "wrongpw"); /* copy the password */ password.len = strlen(password.arr);
EXEC SQL WHENEVER SQLERROR DO sqlerror();
EXEC SQL CONNECT :username IDENTIFIED BY :password; printf("\nConnected to ORACLE as user: %s\n", username.arr);
EXEC SQL COMMIT WORK RELEASE; /* logoff database */
exit(0);
}
void sqlerror()
{
char errmsg[100];
int errlength;
EXEC SQL WHENEVER SQLERROR CONTINUE;
printf("\nORACLE error detected:\n");
printf("\n% .70s \n", sqlca.sqlerrm.sqlerrmc);
sqlglm(errmsg, 100, &errlength);
EXEC SQL ROLLBACK RELEASE;
exit(1);
}
Received on Fri Dec 16 1994 - 04:50:07 CET