Skip Headers

Oracle Call Interface Programmer's Guide
Release 2 (9.2)

Part Number A96584-01
Go To Documentation Library
Home
Go To Product List
Book List
Go To Table Of Contents
Contents
Go To Index
Index

Master Index

Feedback

Go to previous page Go to beginning of chapter Go to next page

More OCI Relational Functions, 97 of 106


OCIErrorGet()

Purpose

Returns an error message in the buffer provided and an Oracle error.

Syntax

sword OCIErrorGet ( dvoid      *hndlp, 
                    ub4        recordno,
                    text       *sqlstate,
                    sb4        *errcodep, 
                    text       *bufp,
                    ub4        bufsiz,
                    ub4        type );

Parameters

hndlp (IN)

The error handle, in most cases, or the environment handle (for errors on OCIEnvCreate(), OCIHandleAlloc()).

recordno (IN)

Indicates the status record from which the application seeks info. Starts from 1.

sqlstate (OUT)

Not supported in release 8.x or later.

errcodep (OUT)

The error code returned.

bufp (OUT)

The error message text returned.

bufsiz (IN)

The size of the buffer provide to get the error message. In number of bytes.

type (IN)

The type of the handle (OCI_HTYPE_ERR or OCI_HTYPE_ENV).

Comments

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().

Example

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;
  }
}

Related Functions

OCIHandleAlloc()


Go to previous page Go to beginning of chapter Go to next page
Oracle
Copyright © 1996, 2002 Oracle Corporation.

All Rights Reserved.
Go To Documentation Library
Home
Go To Product List
Book List
Go To Table Of Contents
Contents
Go To Index
Index

Master Index

Feedback