Ora8HandleAlloc Function

Action

Allocates and initializes a handle of the specified type.

Include file

Ora8.bdh

Syntax

Ora8HandleAlloc( in  hEnv     : number,
                 out hHandle  : number,
                 in  nType    : number): boolean;

Return value

  • true if successful

  • false otherwise

Parameter Description
hEnv An initialized environment handle. This is used as parent handle.
hHandle Variable receiving the handle to be allocated.
nType

Specifies the type of handle to be allocated.

The allowed types are:

  • OCI_HTYPE_ERROR

  • OCI_HTYPE_SVCCTX

  • OCI_HTYPE_STMT

  • OCI_HTYPE_SERVER

  • OCI_HTYPE_SESSION

  • OCI_HTYPE_TRANS

Example

var
  ghEnv0        : number;
  ghError0      : number;
  ghStmt0       : number;
  ghSvcCtx0     : number;

dcltrans
  transaction TMain
  const
    PUBLIC_KEY := "\h59b20094...";
  begin
    Ora8Init(ghEnv0, OCI_DEFAULT);
    Ora8HandleAlloc(ghEnv0, ghError0, OCI_HTYPE_ERROR);
    Ora8Logon(ghEnv0, ghSvcCtx0, "user", "password", "orclnet2");

    Ora8HandleAlloc(ghEnv0, ghStmt0, OCI_HTYPE_STMT);
    Ora8StmtPrepare(ghStmt0, sqlInsert, OCI_NTV_SYNTAX);

    Ora8Bind(ghStmt0, ":name", SQLT_CHR, 32);
    Ora8Bind(ghStmt0, ":key", SQLT_BIN, 64);

    Ora8SetString(ghStmt0, ":name", "Michael");
    Ora8SetBinary(ghStmt0, ":key",  PUBLIC_KEY, STRING_COMPLETE);

    Ora8StmtExecute(ghSvcCtx0, ghStmt0);

    Ora8HandleFree(ghStmt0, OCI_HTYPE_STMT);
    Ora8Logoff(ghSvcCtx0);
    Ora8HandleFree(ghError0, OCI_HTYPE_ERROR);
    Ora8HandleFree(ghEnv0, OCI_HTYPE_ENV);
  end TMain;

dclsql
  sqlInsert:
    INSERT INTO keys (name, key) VALUES (:name, :key);

See also

Oracle's Programmer's Guide to Oracle Call Interface for Wrapped Oracle functions: OCIHandleAlloc