Skip to content

SQLAllocEnv

SQLAllocEnv#

SQLAllocEnv allocates the resources related to the environment handles.

SQLAllocEnv() can be replaced by SQLAllocHandle().

Syntax#

SQLRETURN  SQLAllocEnv ( 
    SQLHENV *   env );

Argument#

Data Type Argumenft In/Output Description
SQLHENV * env Output Environment handle pointer

Return Values#

SQL_SUCCESS
SQL_ERROR

Description#

One application can use various environment variables.

To use resources of the Altibase CLI, the program that called SQLAllocEnv() must not terminate or get out of the stack. Otherwise, an application may lose the statement handles and other allocated resources.

Before calling SQLAllocConnect() or other Altibase CLI functions, an application must call this function. Then, the env value will be sent to all functions that require the environment handles as input values.

SQLAllocConnect
SQLAllocStmt
SQLFreeEnv

Example#

< Refer to: $ALTIBASE_HOME/sample/SQLCLI/demo_ex1.cpp >

/* Memory allocation for the environment */
if (SQLAllocEnv (&env) != SQL_SUCCESS)
{
    printf("SQLAllocEnv error!!\n");
    return SQL_ERROR;
}