Oracle Call Interface Programmer's Guide Release 2 (9.2) Part Number A96584-01 |
|
More OCI Relational Functions, 97 of 106
Returns an error message in the buffer provided and an Oracle error.
sword OCIErrorGet ( dvoid *hndlp, ub4 recordno, text *sqlstate, sb4 *errcodep, text *bufp, ub4 bufsiz, ub4 type );
The error handle, in most cases, or the environment handle (for errors on OCIEnvCreate()
, OCIHandleAlloc()
).
Indicates the status record from which the application seeks info. Starts from 1.
Not supported in release 8.x or later.
The error code returned.
The error message text returned.
The size of the buffer provide to get the error message. In number of bytes.
The type of the handle (OCI_HTYPE_ERR or OCI_HTYPE_ENV).
Returns an error message in the buffer provided and an ORACLE error code. This function does not support SQL statements. In most cases, hndlp
is actually the error handle, or the environment handle. You should always get the message in the encoding that was set in the environment handle.This function can be called multiple times if there are more than one diagnostic record for an error.
The error handle is originally allocated with a call to OCIHandleAlloc()
.
The following sample code demonstrates how you can use OCIErrorGet()
in an error-handling routine. This routine prints out the type of status code returned by an OCI function, and if an error occurred, OCIErrorGet()
retrieves the text of the message, which is printed.
static void checkerr(errhp, status) OCIError *errhp; sword status; { text errbuf[512]; ub4 buflen; ub4 errcode; switch (status) { case OCI_SUCCESS: break; case OCI_SUCCESS_WITH_INFO: printf("ErrorOCI_SUCCESS_WITH_INFO\n"); break; case OCI_NEED_DATA: printf("ErrorOCI_NEED_DATA\n"); break; case OCI_NO_DATA: printf("ErrorOCI_NO_DATA\n"); break; case OCI_ERROR: OCIErrorGet ((dvoid *) errhp, (ub4) 1, (text *) NULL, &errcode, errbuf, (ub4) sizeof(errbuf), (ub4) OCI_HTYPE_ERROR); printf("Error%s\n", errbuf); break; case OCI_INVALID_HANDLE: printf("ErrorOCI_INVALID_HANDLE\n"); break; case OCI_STILL_EXECUTING: printf("ErrorOCI_STILL_EXECUTE\n"); break; case OCI_CONTINUE: printf("ErrorOCI_CONTINUE\n"); break; default: break; } }
|
Copyright © 1996, 2002 Oracle Corporation. All Rights Reserved. |
|