1 ! Copyright (C) 2007 Elie CHAFTARI
2 ! See http://factorcode.org/license.txt for BSD license.
4 ! Adapted from oci.h and ociap.h
5 ! Tested with Oracle version - 10.1.0.3 Instant Client
7 ! DYLD_LIBRARY_PATH="/usr/local/oracle/instantclient10_1"
8 ! export DYLD_LIBRARY_PATH
10 USING: alien alien.syntax combinators kernel system ;
15 { [ os winnt? ] [ "oci.dll" "stdcall" ] }
16 { [ os macosx? ] [ "$DYLD_LIBRARY_PATH/libclntsh.dylib" "cdecl" ] }
17 { [ os unix? ] [ "$DYLD_LIBRARY_PATH/libclntsh.so.10.1" "cdecl" ] }
20 ! ===============================================
22 ! ===============================================
24 : OCI_ATTR_USERNAME 22 ; inline ! username attribute
25 : OCI_ATTR_PASSWORD 23 ; inline ! password attribute
27 ! ===============================================
29 ! ===============================================
31 : OCI_DEFAULT HEX: 00 ; inline ! default value for parameters and attributes
32 : OCI_THREADED HEX: 01 ; inline ! appl. in threaded environment
33 : OCI_OBJECT HEX: 02 ; inline ! application in object environment
35 ! ===============================================
37 ! ===============================================
39 : OCI_DESCRIBE_ONLY HEX: 10 ; inline ! only describe the statement
41 ! ===============================================
43 ! ===============================================
45 : OCI_CRED_RDBMS 1 ; inline ! database username/password
46 : OCI_CRED_EXT 2 ; inline ! externally provided credentials
47 : OCI_CRED_PROXY 3 ; inline ! proxy authentication
49 ! ===============================================
51 ! ===============================================
53 : OCI_SUCCESS 0 ; inline ! maps to SQL_SUCCESS of SAG CLI
54 : OCI_SUCCESS_WITH_INFO 1 ; inline ! maps to SQL_SUCCESS_WITH_INFO
55 : OCI_RESERVED_FOR_INT_USE 200 ; inline ! reserved
56 : OCI_NO_DATA 100 ; inline ! maps to SQL_NO_DATA
57 : OCI_ERROR -1 ; inline ! maps to SQL_ERROR
58 : OCI_INVALID_HANDLE -2 ; inline ! maps to SQL_INVALID_HANDLE
59 : OCI_NEED_DATA 99 ; inline ! maps to SQL_NEED_DATA
60 : OCI_STILL_EXECUTING -3123 ; inline ! OCI would block error
62 ! ===============================================
63 ! Parsing Syntax Types
64 ! ===============================================
66 : OCI_V7_SYNTAX 2 ; inline ! V815 language - for backwards compatibility
67 : OCI_V8_SYNTAX 3 ; inline ! V815 language - for backwards compatibility
68 : OCI_NTV_SYNTAX 1 ; inline ! Use what so ever is the native lang of server
70 ! ===============================================
71 ! Scrollable Cursor Fetch Options
72 ! For non-scrollable cursor, the only valid
73 ! (and default) orientation is OCI_FETCH_NEXT
74 ! ===============================================
76 : OCI_FETCH_CURRENT HEX: 01 ; inline ! refetching current position
77 : OCI_FETCH_NEXT HEX: 02 ; inline ! next row
78 : OCI_FETCH_FIRST HEX: 04 ; inline ! first row of the result set
79 : OCI_FETCH_LAST HEX: 08 ; inline ! the last row of the result set
80 : OCI_FETCH_PRIOR HEX: 10 ; inline ! the previous row relative to current
81 : OCI_FETCH_ABSOLUTE HEX: 20 ; inline ! absolute offset from first
82 : OCI_FETCH_RELATIVE HEX: 40 ; inline ! offset relative to current
83 : OCI_FETCH_RESERVED_1 HEX: 80 ; inline ! reserved
85 ! ===============================================
87 ! ===============================================
89 : OCI_HTYPE_ENV 1 ; inline ! environment handle
90 : OCI_HTYPE_ERROR 2 ; inline ! error handle
91 : OCI_HTYPE_SVCCTX 3 ; inline ! service handle
92 : OCI_HTYPE_STMT 4 ; inline ! statement handle
93 : OCI_HTYPE_BIND 5 ; inline ! bind handle
94 : OCI_HTYPE_DEFINE 6 ; inline ! define handle
95 : OCI_HTYPE_DESCRIBE 7 ; inline ! describe handle
96 : OCI_HTYPE_SERVER 8 ; inline ! server handle
97 : OCI_HTYPE_SESSION 9 ; inline ! authentication handle
99 ! ===============================================
101 ! ===============================================
103 : OCI_ATTR_FNCODE 1 ; inline ! the OCI function code
104 : OCI_ATTR_OBJECT 2 ; inline ! is the environment initialized in object mode
105 : OCI_ATTR_NONBLOCKING_MODE 3 ; inline ! non blocking mode
106 : OCI_ATTR_SQLCODE 4 ; inline ! the SQL verb
107 : OCI_ATTR_ENV 5 ; inline ! the environment handle
108 : OCI_ATTR_SERVER 6 ; inline ! the server handle
109 : OCI_ATTR_SESSION 7 ; inline ! the user session handle
110 : OCI_ATTR_TRANS 8 ; inline ! the transaction handle
111 : OCI_ATTR_ROW_COUNT 9 ; inline ! the rows processed so far
112 : OCI_ATTR_SQLFNCODE 10 ; inline ! the SQL verb of the statement
113 : OCI_ATTR_PREFETCH_ROWS 11 ; inline ! sets the number of rows to prefetch
114 : OCI_ATTR_NESTED_PREFETCH_ROWS 12 ; inline ! the prefetch rows of nested table
115 : OCI_ATTR_PREFETCH_MEMORY 13 ; inline ! memory limit for rows fetched
116 : OCI_ATTR_NESTED_PREFETCH_MEMORY 14 ; inline ! memory limit for nested rows
117 : OCI_ATTR_CHAR_COUNT 15 ; inline ! this specifies the bind and define size in characters
119 ! ===============================================
121 ! ===============================================
128 ! ===============================================
129 ! Input data types (ocidfn.h)
130 ! ===============================================
132 : SQLT_CHR 1 ; inline ! (ORANET TYPE) character string
133 : SQLT_NUM 2 ; inline ! (ORANET TYPE) oracle numeric
134 : SQLT_INT 3 ; inline ! (ORANET TYPE) integer
135 : SQLT_FLT 4 ; inline ! (ORANET TYPE) Floating point number
136 : SQLT_STR 5 ; inline ! zero terminated string
137 : SQLT_ODT 156 ; inline ! OCIDate type
139 ! ===============================================
140 ! Input datetimes and intervals (ocidfn.h)
141 ! ===============================================
143 : SQLT_DATE 184 ; inline ! ANSI Date
144 : SQLT_TIME 185 ; inline ! TIME
145 : SQLT_TIME_TZ 186 ; inline ! TIME WITH TIME ZONE
146 : SQLT_TIMESTAMP 187 ; inline ! TIMESTAMP
147 : SQLT_TIMESTAMP_TZ 188 ; inline ! TIMESTAMP WITH TIME ZONE
148 : SQLT_INTERVAL_YM 189 ; inline ! INTERVAL YEAR TO MONTH
149 : SQLT_INTERVAL_DS 190 ; inline ! INTERVAL DAY TO SECOND
150 : SQLT_TIMESTAMP_LTZ 232 ; inline ! TIMESTAMP WITH LOCAL TZ
152 ! ===============================================
153 ! Opaque pointer types
154 ! ===============================================
157 TYPEDEF: void oci_env
158 TYPEDEF: void oci_server
159 TYPEDEF: void oci_error
160 TYPEDEF: void oci_svc_ctx
161 TYPEDEF: void oci_session
162 TYPEDEF: void oci_stmt
166 ! ===============================================
168 ! ===============================================
170 FUNCTION: int OCIInitialize ( ub4 mode, void* ctxp, void* malocfp, void* ralocfp, dvoid* mfreefp ) ;
171 FUNCTION: int OCITerminate ( ub4 mode ) ;
172 FUNCTION: int OCIEnvInit ( void* envhpp, ub4 mode, size_t xtramem_sz, dvoid* usrmempp ) ;
173 FUNCTION: int OCIEnvCreate ( dvoid* envhpp, ub4 mode, void* ctxp, void* malocfp, void* ralocfp, void* mfreefp, size_t xtramemz, dvoid* usrmempp ) ;
174 FUNCTION: int OCIHandleAlloc ( void* parenth, dvoid* hndlpp, ub4 type, size_t xtramem_sz, dvoid* usrmempp ) ;
175 FUNCTION: int OCIServerAttach ( void* srvhp, void* errhp, char* dblink, sb4 dblink_len, ub4 mode ) ;
176 FUNCTION: int OCIServerDetach ( void* srvhp, void* errhp, ub4 mode ) ;
177 FUNCTION: int OCIHandleFree ( dvoid* p0, ub4 p1 ) ;
178 FUNCTION: int OCILogon ( void* envhp, void* errhp, dvoid* svchpp, uchar* username, ub4 uname_len, uchar* passwd, ub4 password_len, uchar* dsn, ub4 dsn_len ) ;
179 FUNCTION: int OCILogoff ( void* p0, void* p1 ) ;
180 FUNCTION: void OCIErrorGet ( void* handlp, ub4 recordno, char* sqlstate, sb4* errcodep, uchar* bufp, ub4 bufsize, ub4 type ) ;
181 FUNCTION: int OCIStmtPrepare ( void* stmtp, void* errhp, uchar* stmt, ub4 stmt_len, ub4 language, ub4 mode ) ;
182 FUNCTION: int OCIStmtExecute ( void* svchp, void* stmtp1, void* errhp, ub4 iters, ub4 rowoff, void* snap_in, void* snap_out, ub4 mode ) ;
183 FUNCTION: int OCIParamGet ( void* hndlp, ub4 htype, void* errhp, dvoid* parmdpp, ub4 pos ) ;
184 FUNCTION: int OCIAttrGet ( void* trgthndlp, ub4 trghndltyp, void* attributep, ub4* sizep, ub4 attrtype, void* errhp ) ;
185 FUNCTION: int OCIAttrSet ( dvoid* trgthndlp, ub4 trgthndltyp, dvoid* attributep, ub4 size, ub4 attrtype, oci_error* errhp ) ;
186 FUNCTION: int OCIDefineByPos ( void* stmtp, dvoid* defnpp, void* errhp, ub4 position, void* valuep, sb4 value_sz, ub2 dty, sb2* indp, ub2* rlenp, ub2* rcodep, ub4 mode ) ;
187 FUNCTION: int OCIStmtFetch ( void* stmthp, void* errhp, ub4 p2, ub2 p3, ub4 p4 ) ;
188 FUNCTION: int OCITransStart ( void* svchp, void* errhp, ushort p2, ushort p3 ) ;
189 FUNCTION: int OCITransCommit ( void* svchp, void* errhp, ushort p2 ) ;
190 FUNCTION: int OCITransRollback ( void* svchp, void* errhp, ushort p2 ) ;
191 FUNCTION: int OCISessionBegin ( oci_svc_ctx* svchp, oci_error* errhp, oci_session* usrhp, ub4 credt, ub4 mode ) ;
192 FUNCTION: int OCISessionEnd ( oci_svc_ctx* svchp, oci_error* errhp, oci_session* usrhp, ub4 mode ) ;
193 FUNCTION: int OCIServerVersion ( void* handlp, void* errhp, uchar* bufsz, int bufsz, short hndltype ) ;