home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 October
/
PCWorld_1998-10_cd.bin
/
software
/
prehled
/
komix
/
DATA.Z
/
DBObject.4gl
< prev
next >
Wrap
Text File
|
1996-11-28
|
3KB
|
107 lines
-----------------------------------------------------------------------------
--
-- Copyright (c) 1995 by Westmount Technology B.V., Delft, The Netherlands.
--
-- This software is furnished under a license and may be used only in
-- accordance with the terms of such license and with the inclusion of
-- the above copyright notice. This software or any other copies thereof
-- may not be provided or otherwise made available to any other person.
-- No title to and ownership of the software is hereby transferred.
--
-- The information in this software is subject to change without notice
-- and should not be construed as a commitment by Westmount Technology B.V.
--
-----------------------------------------------------------------------------
--
-- File : @(#)DBObject.4gl /main/titanic/1
-- Author :
-- Original date : 17-01-1995
-- Description : Base class for all database classes
--
-----------------------------------------------------------------------------
INCLUDE "DBObject.4gh"
VARIABLE DBObject::conn ixSQLConnect = NULL
FUNCTION DBObject::connectDB(dbName CHAR(*), connObj ixSQLConnect)
RETURNING INTEGER
IF connObj IS NULL THEN
LET conn = ixSQLConnect::getImplicitConnection()
ELSE
LET conn = connObj
END IF
CALL conn.connect(dbName)
RETURN SQLCA.SQLCODE
END FUNCTION
FUNCTION DBObject::disconnectDB() RETURNING VOID
IF conn IS NULL THEN
RETURN
END IF
CALL conn.disconnect()
END FUNCTION
FUNCTION DBObject::getConnection() RETURNING ixSQLConnect
RETURN conn
END FUNCTION
FUNCTION DBObject::commit() RETURNING INTEGER
CALL conn.transact(conn.SQL_Commit)
RETURN SQLCA.SQLCODE
END FUNCTION
FUNCTION DBObject::rollback() RETURNING INTEGER
CALL conn.transact(conn.SQL_Rollback)
RETURN SQLCA.SQLCODE
END FUNCTION
FUNCTION DBObject::getClassName() RETURNING ixString
RETURN className
END FUNCTION
FUNCTION DBObject::getODBCErrMsg(stmt ixSQLStmt) RETURNING CHAR(*)
VARIABLE sqlState CHAR(*), errNum INTEGER, errMsg CHAR(*)
IF stmt.getODBCErrorCode() != stmt.SQL_Success THEN
CALL conn.SQLError(stmt)
RETURNING sqlState, errNum, errMsg
RETURN errMsg
END IF
RETURN NULL
END FUNCTION
FUNCTION DBObject::DBObject()
LET dbstate = CREATED
LET errorStmt = NULL
END FUNCTION
FUNCTION DBObject::getState() RETURNING SMALLINT
RETURN dbState
END FUNCTION
FUNCTION DBObject::resetState() RETURNING VOID
LET dbstate = CREATED
END FUNCTION
FUNCTION DBObject::processSqlStatus(stmt ixSQLStmt) RETURNING INTEGER
CASE
WHEN dbState == CREATED OR dbState == NORMAL
IF stmt.getODBCErrorCode() != stmt.SQL_Success THEN
LET errorStmt = stmt
LET dbState = SQL_ERROR
RETURN -1
ELSE
LET errorStmt = NULL
LET dbState = NORMAL
RETURN 0
END IF
WHEN dbState == SQL_ERROR
RETURN -1
END CASE
RETURN -1
END FUNCTION