⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ocilib.h

📁 ORACLE编程的好东西,纯C写的OCI封装.很好用,支持数据池.
💻 H
📖 第 1 页 / 共 5 页
字号:
#define OCI_ERR_NOT_COMPATIBLE          16
#define OCI_ERR_STMT_STATE              17
#define OCI_ERR_STMT_NOT_SCROLLABLE     18

/* 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 

/* unkown 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

/* 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

/* lLob 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 browing mode */

#define OCI_SEEK_SET            1
#define OCI_SEEK_END            2
#define OCI_SEEK_CUR            3

/* schema types */

#define OCI_SCHEMA_TABLE        1
#define OCI_SCHEMA_VIEW         2
#define OCI_SCHEMA_TYPE         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

/* hash tables support */

#define OCI_HASH_STRING         1
#define OCI_HASH_INTEGER        2
#define OCI_HASH_POINTER        3

#define OCI_HASH_DEFAULT_SIZE   256

/* Trancsaction 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 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")

/**
 * @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
 *
 * @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         - Environnement 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 
 * environnement 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 differents 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 differents ways
 * - with runtime loading buid option, the version determined from the symbols 
 *   dynamically loaded.
 *
 */

OCI_EXPORT unsigned int OCI_API OCI_GetOCIRuntimeVersion(void);

/**
 * @}
 */

/**
 * @defgroup g_error Error handling
 * @{
 *
 * OCILIB provides two mechanisms for error handling :
 *
 * - Global error handling through callback.
 * - 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 retrived 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 callback
 * @include err.c
 *
 * @par Example with thread context
 * @include err_ctx.c
 *
 */

/**
 * @brief 
 * Retrieve the last error occured 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 occured
 *
 * @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 occured out of a statement context, it returns NULL
 *
 */

OCI_EXPORT OCI_Statement * OCI_API OCI_ErrorGetStatement
(   
    OCI_Error *err
);

/**
 * @}
 */

/**
 * @defgroup g_connect Connecting to Database
 * @{
 *
 * Connecting to a database server is done with one call to
 * OCI_ConnectionCreate().
 * 
 * OCI_ConnectionFree() closes the established connection.
 *
 * Connection properties are accessible through a set of functions
 *
 * @par Example
 * @include conn.c
 *
 */

/**
 * @brief 
 * Create a physical connection to an Oracle database server
 *
 * @param db   - Oracle Service Name
 * @param user - Oracle User name
 * @param pwd  - Oracle User password
 * @param mode - Session mode
 * 
 * Possible values for parameter mode :
 * - OCI_SESSION_DEFAULT
 * - OCI_SESSION_SYSDBA
 * - OCI_SESSION_SYSOPER
 * 
 * @note
 * On success, a transaction is automatically created and started
 *
 * @return 
 * Connection handle on succes or NULL on failure
 *
 */

OCI_EXPORT OCI_Connection * OCI_API OCI_ConnectionCreate
(
    const mtext *db, 
    const mtext *user, 
    const mtext *pwd,
    unsigned int mode
);

/**
 * @brief 
 * Close a physical connection to an Oracle database server
 *
 * @param con - Connection handle
 * 
 * @return 
 * TRUE on success otherwise FALSE
 *
 */

OCI_EXPORT boolean OCI_API OCI_ConnectionFree
(
    OCI_Connection *con
);

/**
 * @brief 
 * Returns TRUE is the given connection is still connected otherwise FALSE
 *
 * @param con - Connection handle
 * 
 */

OCI_EXPORT boolean OCI_API OCI_IsConnected
(
    OCI_Connection *con
);

/**
 * @brief 
 * Return the previously pointer to user data associated with the connection
 *
 * @param con - Connection handle
 * 
 */

OCI_EXPORT void * OCI_API OCI_GetUserData
(
    OCI_Connection *con
);

/**
 * @brief 
 * Associate to the given connection a pointer to user data
 *
 * @param con  - Connection handle
 * @param data - user data pointer
 *
 * @return 
 * TRUE on success otherwise FALSE
 *
 */

OCI_EXPORT boolean OCI_API OCI_SetUserData
(
    OCI_Connection *con,
    void * data
);

/**
 * @brief 
 * Return the name of the connected database/service name
 *
 * @param con - Connection handle
 * 
 */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -