📄 ocilib.h
字号:
typedef unsigned int big_uint;
#endif
/* boolean balues */
#ifndef TRUE
#define TRUE 1
#define FALSE 0
#endif
#ifndef boolean
#define boolean int
#endif
/* oracle versions*/
#define OCI_UNKNOWN 0
#define OCI_8 8
#define OCI_9 9
#define OCI_10 10
#define OCI_11 11
/* OCILIB Error types */
#define OCI_ERR_ORACLE 1
#define OCI_ERR_OCILIB 2
/* OCILIB Error codes */
#define OCI_ERR_NONE 0
#define OCI_ERR_NOT_INITIALIZED 1
#define OCI_ERR_LOADING_SHARED_LIB 2
#define OCI_ERR_LOADING_SYMBOLS 3
#define OCI_ERR_MULTITHREADED 4
#define OCI_ERR_MEMORY 5
#define OCI_ERR_NOT_AVAILABLE 6
#define OCI_ERR_NULL_POINTER 7
#define OCI_ERR_DATATYPE_NOT_SUPPORTED 8
#define OCI_ERR_PARSE_TOKEN 9
#define OCI_ERR_MAP_ARGUMENT 10
#define OCI_ERR_OUT_OF_BOUNDS 11
#define OCI_ERR_UNFREED_DATA 12
#define OCI_ERR_MAX_BIND 13
#define OCI_ERR_ATTR_NOT_FOUND 14
#define OCI_ERR_MIN_VALUE 15
#define OCI_ERR_NOT_COMPATIBLE 16
#define OCI_ERR_STMT_STATE 17
#define OCI_ERR_STMT_NOT_SCROLLABLE 18
#define OCI_ERR_BIND_ALREADY_USED 19
#define OCI_ERR_BIND_ARRAY_SIZE 20
#define OCI_ERR_COLUMN_NOT_FOUND 21
#define OCI_ERR_DIRPATH_STATE 22
/* binding */
#define OCI_BIND_BY_POS 0
#define OCI_BIND_BY_NAME 1
#define OCI_BIND_SIZE 6
#define OCI_BIND_MAX 512
/* fetching */
#define OCI_FETCH_SIZE 20
#define OCI_PREFETCH_SIZE 20
#define OCI_LONG_EXPLICIT 1
#define OCI_LONG_IMPLICIT 2
/* unknown value */
#define OCI_UNKNOWN 0
/* C Data Type mapping */
#define OCI_CDT_NUMERIC 1
#define OCI_CDT_DATETIME 3
#define OCI_CDT_TEXT 4
#define OCI_CDT_LONG 5
#define OCI_CDT_CURSOR 6
#define OCI_CDT_LOB 7
#define OCI_CDT_FILE 8
#define OCI_CDT_TIMESTAMP 9
#define OCI_CDT_INTERVAL 10
#define OCI_CDT_RAW 11
#define OCI_CDT_OBJECT 12
#define OCI_CDT_COLLECTION 13
#define OCI_CDT_REF 14
/* Data Type codes for OCI_ImmediateXXX() calls */
#define OCI_ARG_SHORT 1
#define OCI_ARG_USHORT 2
#define OCI_ARG_INT 3
#define OCI_ARG_UINT 4
#define OCI_ARG_BIGINT 5
#define OCI_ARG_BIGUINT 6
#define OCI_ARG_DOUBLE 7
#define OCI_ARG_DATETIME 8
#define OCI_ARG_TEXT 9
#define OCI_ARG_LOB 10
#define OCI_ARG_FILE 11
#define OCI_ARG_TIMESTAMP 12
#define OCI_ARG_INTERVAL 13
#define OCI_ARG_RAW 14
/* statement types */
#define OCI_CST_SELECT 1
#define OCI_CST_UPDATE 2
#define OCI_CST_DELETE 3
#define OCI_CST_INSERT 4
#define OCI_CST_CREATE 5
#define OCI_CST_DROP 6
#define OCI_CST_ALTER 7
#define OCI_CST_BEGIN 8
#define OCI_CST_DECLARE 9
/* environnement modes */
#define OCI_ENV_DEFAULT 0
#define OCI_ENV_THREADED 1
#define OCI_ENV_CONTEXT 2
/* sessions modes */
#define OCI_SESSION_DEFAULT 0
#define OCI_SESSION_SYSDBA 2
#define OCI_SESSION_SYSOPER 4
/* charsetform types */
#define OCI_CSF_NONE 0
#define OCI_CSF_CHARSET 1
#define OCI_CSF_NATIONAL 2
/* statement fetch mode */
#define OCI_SFM_DEFAULT 0
#define OCI_SFM_SCROLLABLE 0x08
/* statement fetch direction */
#define OCI_SFD_ABSOLUTE 0x20
#define OCI_SFD_RELATIVE 0x40
/* timestamp types */
#define OCI_TIMESTAMP 1
#define OCI_TIMESTAMP_TZ 2
#define OCI_TIMESTAMP_LTZ 3
/* interval types */
#define OCI_INTERVAL_YM 1
#define OCI_INTERVAL_DS 2
/* long types */
#define OCI_BLONG 1
#define OCI_CLONG 2
/* lob types */
#define OCI_BLOB 1
#define OCI_CLOB 2
#define OCI_NCLOB 3
/* lob opening mode */
#define OCI_LOB_READONLY 1
#define OCI_LOB_READWRITE 2
/* file types */
#define OCI_BFILE 1
#define OCI_CFILE 2
/* lob browsing mode */
#define OCI_SEEK_SET 1
#define OCI_SEEK_END 2
#define OCI_SEEK_CUR 3
/* type info types */
#define OCI_TIF_TABLE 1
#define OCI_TIF_VIEW 2
#define OCI_TIF_TYPE 3
/* object type */
#define OCI_OBJ_PERSISTENT 1
#define OCI_OBJ_TRANSIENT 2
#define OCI_OBJ_VALUE 3
/* Collection types */
#define OCI_COLL_VARRAY 1
#define OCI_COLL_NESTED_TABLE 2
/* size constants */
#define OCI_SIZE_FORMAT 64
#define OCI_SIZE_BUFFER 512
#define OCI_SIZE_LONG (64*1024)-1
#define OCI_SIZE_DATE 44
#define OCI_SIZE_TIMESTAMP 60
#define OCI_SIZE_FORMAT_TODATE 14
#define OCI_SIZE_NULL 4
#define OCI_SIZE_PRECISION 10
#define OCI_SIZE_ROWID 23
#define OCI_SIZE_DIRECTORY 30
#define OCI_SIZE_FILENAME 255
#define OCI_SIZE_FORMAT_NUMS 40
#define OCI_SIZE_FORMAT_NUML 65
#define OCI_SIZE_OBJ_NAME 30
/* Direct path processing return status */
#define OCI_DPR_COMPLETE 1
#define OCI_DPR_ERROR 2
#define OCI_DPR_FULL 3
#define OCI_DPR_PARTIAL 4
#define OCI_DPR_EMPTY 5
/* trace size constants */
#define OCI_SIZE_TRACE_ID 64
#define OCI_SIZE_TRACE_MODULE 48
#define OCI_SIZE_TRACE_ACTION 32
#define OCI_SIZE_TRACE_INF0 64
/* trace types */
#define OCI_TRC_IDENTITY 1
#define OCI_TRC_MODULE 2
#define OCI_TRC_ACTION 3
#define OCI_TRC_DETAIL 4
/* hash tables support */
#define OCI_HASH_STRING 1
#define OCI_HASH_INTEGER 2
#define OCI_HASH_POINTER 3
#define OCI_HASH_DEFAULT_SIZE 256
/* Transaction types */
#define OCI_TRS_NEW 0x00000001
#define OCI_TRS_READONLY 0x00000100
#define OCI_TRS_READWRITE 0x00000200
#define OCI_TRS_SERIALIZABLE 0x00000400
#define OCI_TRS_LOOSE 0x00010000
#define OCI_TRS_TIGHT 0x00020000
/* string constants */
#define OCILIB_DRIVER_NAME MT("OCILIB")
#define OCI_STRING_NULL MT("NULL")
#define OCI_STRING_FORMAT_DATE MT("YYYY-MM-DD")
#define OCI_STRING_DEFAULT_PREC 3
#define OCI_STRING_FORMAT_NUM \
MT("FM99999999999999999999999999999999999990.999999999999999999999999")
#ifdef _WINDOWS
#define OCI_CHAR_SLASH '\\'
#else
#define OCI_CHAR_SLASH '/'
#endif
/**
* @defgroup g_init Initializing the library
* @{
*
* To use OCILIB, it first needs to be initialized through a call to
* OCI_Initialize().
*
* Then, the application connects to server, executes queries, ....
*
* Finally, OCILIB resources must be released by OCI_Cleanup()
*
* @note
* The following objects are automatically freed by the library :
* - Connections
* - Connection pools
* - Statements
* - Type info objects
* - Thread keys
*
* @warning
* All other standalone object instances (mutexes, threads, dates, lobs, ...)
* <b>ARE NOT</b> freed.
*
* @par Example
* @include init.c
*
*/
/**
* @brief
* Initializes the library
*
* @param err_handler - Pointer to error handler procedure (optional)
* @param home - Oracle home path (optional)
* @param mode - Environment mode
*
* Possible values for parameter mode:
*
* - OCI_ENV_DEFAULT : default mode
* - OCI_ENV_THREADED : multithreading support
* - OCI_ENV_CONTEXT : thread contextual error handling
*
* @note
* This function must be called before any OCILIB library function.
*
* - It installs the error handler
* - It loads the Oracle shared library located in the path pointed by 'home'
*
* @warning
* If the parameter 'home' is NULL, the Oracle library is loaded from system
* environment variables
*
* @return
* TRUE on success otherwise FALSE (only with Oracle runtime loading mode
* if the oracle shared libraries can't be loaded)
*
*/
OCI_EXPORT boolean OCI_API OCI_Initialize
(
POCI_ERROR err_handler,
const mtext *home,
unsigned int mode
);
/**
* @brief
* Clean up all resources allocated by the library
*
* @note
* This function must be the last OCILIB library function call.
*
* - It deallocates objects not explicitly freed by the program (connections,
* statements, ...)
* - It unloads the Oracle shared library
*
* @return TRUE
*/
OCI_EXPORT boolean OCI_API OCI_Cleanup(void);
/**
* @brief
* Return the major version of OCI used for compilation
*
* @note
* - with linkage build option, the version is determined from the oci.h header
* through different ways
* - with runtime loading buid option, the version is set to the highest version
* of OCI needed by OCILIB, not necessarily the real OCI version
*
*/
OCI_EXPORT unsigned int OCI_API OCI_GetOCICompileVersion(void);
/**
* @brief
* Return the major version of OCI used for compilation
*
* @note
* - with linkage build option, the version is determined from the oci.h header
* through different ways
* - with runtime loading build option, the version determined from the symbols
* dynamically loaded.
*
*/
OCI_EXPORT unsigned int OCI_API OCI_GetOCIRuntimeVersion(void);
/**
* @brief
* Return the Oracle shared library import mode
*
* @note
* Possible values are:
*
* - OCI_IMPORT_MODE_LINKAGE
* - OCI_IMPORT_MODE_RUNTIME
*
*/
OCI_EXPORT unsigned int OCI_API OCI_GetImportMode(void);
/**
* @brief
* Return the metadata charset type
*
* @note
* Possible values are :
*
* - OCI_CHAR_ANSI
* - OCI_CHAR_UNICODE
*
*/
OCI_EXPORT unsigned int OCI_API OCI_GetCharsetMetaData(void);
/**
* @brief
* Return the user data charset type
*
* @note
* Possible values are :
*
* - OCI_CHAR_ANSI
* - OCI_CHAR_UNICODE
*
*/
OCI_EXPORT unsigned int OCI_API OCI_GetCharsetUserData(void);
/**
* @}
*/
/**
* @defgroup g_error Error handling
* @{
*
* OCILIB provides two mechanisms for error handling:
*
* - Global error handling through callbacks.
* - Contextual thread error handling
*
* Exceptions are raised:
*
* - On Oracle OCI API call error
* - On Oracle SQL statement error
* - On Internal OCILIB error (type checking, memory allocations, ...)
*
* If an error handler was provided to OCI_Initialize(), when an error occurs, the
* library generates an OCI_Error handle and pass it to the error handler.
*
* In order to use the thread contextual error handling, you must call
* OCI_Initialize() with the flag OCI_ENV_CONTEXT for the mode parameter. When
* activated, error handles are stored per thread and the last error within a
* thread can be retrieved with OCI_GetLastError()
*
* Exception properties are accessible through a set of functions
*
* @note
* The two ways to handle errors are not exclusive and can be mixed.
*
* @note
* Thread contextual error is also available for single thread based applications
*
* @par Example with callbacks
* @include err.c
*
* @par Example with thread context
* @include err_ctx.c
*
*/
/**
* @brief
* Retrieve the last error occurred within the last OCILIB call
*
* @note
* OCI_GetLastError() is based on thread context and thus OCILIB must be
* initialized with the flag OCI_ENV_CONTEXT
*
*/
OCI_EXPORT OCI_Error * OCI_API OCI_GetLastError(void);
/**
* @brief
* Retrieve error message from error handle
*
* @param err * error handle
*
*/
OCI_EXPORT const mtext * OCI_API OCI_ErrorGetString
(
OCI_Error *err
);
/**
* @brief
* Retrieve the type of error from error handle
*
* @param err * error handle
*
* @note
* Returns one of the following values :
*
* - OCI_ERR_ORACLE
* - OCI_ERR_OCILIB
*
* @return
* Object type or OCI_UNKNOWN the input handle is NULL
*
*/
OCI_EXPORT unsigned int OCI_API OCI_ErrorGetType
(
OCI_Error *err
);
/**
* @brief
* Retrieve Oracle Error code from error handle
*
* @param err * error handle
*
*/
OCI_EXPORT int OCI_API OCI_ErrorGetOCICode
(
OCI_Error *err
);
/**
* @brief
* Retrieve Internal Error code from error handle
*
* @param err * error handle
*
*/
OCI_EXPORT int OCI_API OCI_ErrorGetInternalCode
(
OCI_Error *err
);
/**
* @brief
* Retrieve connection handle within the error occurred
*
* @param err * error handle
*
*/
OCI_EXPORT OCI_Connection * OCI_API OCI_ErrorGetConnection
(
OCI_Error *err
);
/**
* @brief
* Retrieve statement handle within the error occured
*
* @param err * error handle
*
* @note
* If the error occurred outside of a statement context, it returns NULL
*
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -