From: <kr_...@us...> - 2005-10-18 11:43:40
|
Update of /cvsroot/htoolkit/HSQL/Oracle/Database/HSQL In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14309/Database/HSQL Modified Files: HsOCI.h Oracle.hsc Log Message: closeStatement/fetch/startTransaction/commitTransaction/rollbackTransaction are added. Index: HsOCI.h =================================================================== RCS file: /cvsroot/htoolkit/HSQL/Oracle/Database/HSQL/HsOCI.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** HsOCI.h 12 Oct 2005 15:01:44 -0000 1.2 --- HsOCI.h 18 Oct 2005 11:43:28 -0000 1.3 *************** *** 10,13 **** --- 10,14 ---- ub1 dprec; ub1 dscale; + ub1 isNull; ub4 colNameLen; char *colName; Index: Oracle.hsc =================================================================== RCS file: /cvsroot/htoolkit/HSQL/Oracle/Database/HSQL/Oracle.hsc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Oracle.hsc 12 Oct 2005 15:01:44 -0000 1.2 --- Oracle.hsc 18 Oct 2005 11:43:28 -0000 1.3 *************** *** 46,49 **** --- 46,50 ---- foreign import ccall "OCIStmtPrepare" ociStmtPrepare :: OCIStmt -> OCIError -> CString -> CInt -> CInt -> CInt -> IO CInt foreign import ccall "OCIStmtExecute" ociStmtExecute :: OCISvcCtx -> OCIStmt -> OCIError -> CInt -> CInt -> OCIHandle -> OCIHandle -> CInt -> IO CInt + foreign import ccall "OCIStmtFetch2" ociStmtFetch2 :: OCIStmt -> OCIError -> CInt -> CInt -> CInt -> CInt -> IO CInt foreign import ccall "OCIParamGet" ociParamGet :: OCIStmt -> CInt -> OCIError -> Ptr OCIParam -> CInt -> IO CInt *************** *** 52,55 **** --- 53,60 ---- foreign import ccall "OCIDescriptorFree" ociDescriptorFree :: OCIHandle -> CInt -> IO CInt + foreign import ccall "OCITransStart" ociTransStart :: OCISvcCtx -> OCIError -> Word8 -> CInt -> IO CInt + foreign import ccall "OCITransCommit" ociTransCommit :: OCISvcCtx -> OCIError -> CInt -> IO CInt + foreign import ccall "OCITransRollback" ociTransRollback :: OCISvcCtx -> OCIError -> CInt -> IO CInt + ----------------------------------------------------------------------------------------- -- keeper of OCIEnv *************** *** 121,127 **** , connTables = tables connection svcCtx , connDescribe = describe connection svcCtx ! , connBeginTransaction = beginTransaction myEnvironment svcCtx ! , connCommitTransaction = commitTransaction myEnvironment svcCtx ! , connRollbackTransaction = rollbackTransaction myEnvironment svcCtx , connClosed = refFalse }) --- 126,132 ---- , connTables = tables connection svcCtx , connDescribe = describe connection svcCtx ! , connBeginTransaction = beginTransaction myEnvironment svcCtx err ! , connCommitTransaction = commitTransaction myEnvironment svcCtx err ! , connRollbackTransaction = rollbackTransaction myEnvironment svcCtx err , connClosed = refFalse }) *************** *** 139,143 **** stmt <- peek pStmt ociStmtPrepare stmt err query (fromIntegral query_len) (#const OCI_NTV_SYNTAX) (#const OCI_DEFAULT) >>= handleSqlResult err ! ociStmtExecute svcCtx stmt err 0 0 nullPtr nullPtr (#const OCI_DEFAULT) >>= handleSqlResult err ociHandleFree stmt (#const OCI_HTYPE_STMT) >>= handleSqlResult err --- 144,148 ---- stmt <- peek pStmt ociStmtPrepare stmt err query (fromIntegral query_len) (#const OCI_NTV_SYNTAX) (#const OCI_DEFAULT) >>= handleSqlResult err ! ociStmtExecute svcCtx stmt err 1 0 nullPtr nullPtr (#const OCI_DEFAULT) >>= handleSqlResult err ociHandleFree stmt (#const OCI_HTYPE_STMT) >>= handleSqlResult err *************** *** 151,160 **** ociStmtExecute svcCtx stmt err 0 0 nullPtr nullPtr (#const OCI_DEFAULT) >>= handleSqlResult err fields <- allocaBytes (#const (sizeof(FIELD_DEF))) (getFieldDefs stmt 1) refFalse <- newMVar False let statement = Statement { stmtConn = connection ! , stmtClose = closeStatement stmt ! , stmtFetch = fetch stmt ! , stmtGetCol = getColValue stmt , stmtFields = fields , stmtClosed = refFalse --- 156,167 ---- ociStmtExecute svcCtx stmt err 0 0 nullPtr nullPtr (#const OCI_DEFAULT) >>= handleSqlResult err fields <- allocaBytes (#const (sizeof(FIELD_DEF))) (getFieldDefs stmt 1) + buffer <- mallocBytes (fetchBufferSize fields) + definePositions buffer fields refFalse <- newMVar False let statement = Statement { stmtConn = connection ! , stmtClose = closeStatement stmt buffer err ! , stmtFetch = fetch stmt err ! , stmtGetCol = getColValue stmt buffer , stmtFields = fields , stmtClosed = refFalse *************** *** 180,183 **** --- 187,192 ---- ociAttrGet par (#const OCI_DTYPE_PARAM) ((#ptr FIELD_DEF, dscale) buffer) nullPtr (#const OCI_ATTR_SCALE) err >>= handleSqlResult err dscale <- (#peek FIELD_DEF, dscale) buffer + ociAttrGet par (#const OCI_DTYPE_PARAM) ((#ptr FIELD_DEF, isNull) buffer) nullPtr (#const OCI_ATTR_IS_NULL) err >>= handleSqlResult err + (isNull :: (#type ub1)) <- (#peek FIELD_DEF, isNull) buffer ociAttrGet par (#const OCI_DTYPE_PARAM) ((#ptr FIELD_DEF, colName) buffer) ((#ptr FIELD_DEF, colNameLen) buffer) (#const OCI_ATTR_NAME) err >>= handleSqlResult err pColName <- (#peek FIELD_DEF, colName) buffer *************** *** 186,212 **** ociDescriptorFree par (#const OCI_DTYPE_PARAM) print (dtype,dsize,dprec,dscale) ! return (colName,mkSqlType dtype dsize dprec dscale,False) mkSqlType :: (#type OCITypeCode) -> (#type ub2) -> (#type ub1) -> (#type ub1) -> SqlType ! mkSqlType (#const OCI_TYPECODE_CHAR) size _ _ = SqlChar (fromIntegral size) ! mkSqlType (#const OCI_TYPECODE_VARCHAR) size _ _ = SqlVarChar (fromIntegral size) ! mkSqlType (#const OCI_TYPECODE_DECIMAL) _ prec scale = SqlDecimal (fromIntegral prec) (fromIntegral scale) ! mkSqlType (#const OCI_TYPECODE_NUMBER) _ prec scale = SqlNumeric (fromIntegral prec) (fromIntegral scale) ! mkSqlType (#const OCI_TYPECODE_SMALLINT) _ _ _ = SqlSmallInt ! mkSqlType (#const OCI_TYPECODE_INTEGER) _ _ _ = SqlInteger ! mkSqlType (#const OCI_TYPECODE_FLOAT) _ _ _ = SqlFloat ! mkSqlType (#const OCI_TYPECODE_DATE) _ _ _ = SqlDate ! mkSqlType (#const OCI_TYPECODE_TIME) _ _ _ = SqlTime ! mkSqlType (#const OCI_TYPECODE_TIMESTAMP) _ _ _ = SqlTimeStamp ! mkSqlType (#const SQLT_LNG) _ _ _ = SqlText ! mkSqlType tp _ _ _ = SqlUnknown (fromIntegral tp) tables connection svcCtx = undefined describe connection svcCtx = undefined - beginTransaction myEnvironment svcCtx = undefined - commitTransaction myEnvironment svcCtx = undefined - rollbackTransaction myEnvironment svcCtx = undefined ! closeStatement stmt = undefined ! fetch stmt = undefined ! getColValue stmt = undefined --- 195,246 ---- ociDescriptorFree par (#const OCI_DTYPE_PARAM) print (dtype,dsize,dprec,dscale) ! return (colName,mkSqlType dtype dsize dprec dscale,toBool (fromIntegral isNull)) ! ! fetchBufferSize [] = 0 ! fetchBufferSize ((_,tp,_):fields) = undefined + fetchBufferSize fields ! ! definePositions buffer [] = return () ! definePositions buffer (field:fields) = do ! undefined ! definePositions buffer fields mkSqlType :: (#type OCITypeCode) -> (#type ub2) -> (#type ub1) -> (#type ub1) -> SqlType ! mkSqlType (#const OCI_TYPECODE_CHAR) size _ _ = SqlChar (fromIntegral size) ! mkSqlType (#const OCI_TYPECODE_VARCHAR) size _ _ = SqlVarChar (fromIntegral size) ! mkSqlType (#const OCI_TYPECODE_VARCHAR2) size _ _ = SqlVarChar (fromIntegral size) ! mkSqlType (#const OCI_TYPECODE_DECIMAL) _ prec scale = SqlDecimal (fromIntegral prec) (fromIntegral scale) ! mkSqlType (#const OCI_TYPECODE_NUMBER) _ prec scale = SqlNumeric (fromIntegral prec) (fromIntegral scale) ! mkSqlType (#const OCI_TYPECODE_SMALLINT) _ _ _ = SqlSmallInt ! mkSqlType (#const OCI_TYPECODE_INTEGER) _ _ _ = SqlInteger ! mkSqlType (#const OCI_TYPECODE_REAL) _ _ _ = SqlReal ! mkSqlType (#const OCI_TYPECODE_FLOAT) _ _ _ = SqlFloat ! mkSqlType (#const OCI_TYPECODE_DOUBLE) _ _ _ = SqlDouble ! mkSqlType (#const OCI_TYPECODE_DATE) _ _ _ = SqlDate ! mkSqlType (#const OCI_TYPECODE_TIME) _ _ _ = SqlTime ! mkSqlType (#const OCI_TYPECODE_TIME_TZ) _ _ _ = SqlTimeTZ ! mkSqlType (#const OCI_TYPECODE_TIMESTAMP) _ _ _ = SqlTimeStamp ! mkSqlType (#const SQLT_LNG) _ _ _ = SqlText ! mkSqlType tp _ _ _ = SqlUnknown (fromIntegral tp) tables connection svcCtx = undefined describe connection svcCtx = undefined ! beginTransaction myEnvironment svcCtx err = ! ociTransStart svcCtx err 0 (#const OCI_TRANS_READWRITE) >>= handleSqlResult err ! ! commitTransaction myEnvironment svcCtx err = ! ociTransCommit svcCtx err (#const OCI_DEFAULT) >>= handleSqlResult err ! ! rollbackTransaction myEnvironment svcCtx err = do ! ociTransRollback svcCtx err (#const OCI_DEFAULT) >>= handleSqlResult err ! ! closeStatement stmt buffer err = do ! ociHandleFree stmt (#const OCI_HTYPE_STMT) >>= handleSqlResult err ! free buffer ! ! fetch stmt err = do ! res <- ociStmtFetch2 stmt err 1 (#const OCI_FETCH_NEXT) 0 (#const OCI_DEFAULT) ! handleSqlResult err res ! return (res /= (#const OCI_NO_DATA)) ! ! getColValue stmt buffer = undefined |