home *** CD-ROM | disk | FTP | other *** search
- /*---------------------------------------------------------------------------
- *
- * Copyright (c) 1994 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.ec /main/titanic/1
- * Original date : Mon Feb 21 14:49:59 MET 1994
- * Description : Base Class for all Database Classes
- * uses RogueWave class library
- *
- *---------------------------------------------------------------------------
- */
- static const char SccsId[]="@(#)DBObject.ec /main/titanic/1 15 Oct 1997 Copyright 1994 Westmount Technology";
-
- #include <string.h>
-
- #ifndef DBOBJECT_HXX
- #include "DBObject.hxx"
- #endif
-
- #ifndef INFORMIX_HXX
- #include "Informix.hxx"
- #endif
-
- #ifndef SQLPRINT_HXX
- #include "SqlPrint.hxx"
- #endif
-
- $define MAX_NAME_LEN 80;
-
- static unsigned hashInt(const int& i)
- {
- return i;
- }
-
- static unsigned hashName(const RWCString& s)
- {
- return s.hash();
- }
-
- DBObject::DBObject(const RWCString &name) :
- dbState(CREATED),
- className(name)
- {
- }
-
- DBObject::~DBObject()
- {
- }
-
- int DBObject::connectDB(const char *name)
- {
- const
- $char *dbName = name;
-
- $WHENEVER SQLERROR CALL sqlprint;
-
- $DATABASE $dbName;
- if (sqlca.sqlcode != 0)
- return -1;
-
- return 0;
- }
-
- int DBObject::beginWork()
- {
- $begin work;
- return sqlca.sqlcode != 0 ? -1 : 0;
- }
-
- int DBObject::commit()
- {
- $commit work;
- return sqlca.sqlcode != 0 ? -1 : 0;
- }
-
- int DBObject::rollback()
- {
- $rollback work;
- return sqlca.sqlcode != 0 ? -1 : 0;
- }
-
- int DBObject::notFound()
- {
- return dbState == SQL_ERROR && sqlca.sqlcode == 100;
- }
-
- void DBObject::resetState()
- {
- dbState = CREATED;
- }
-
- int DBObject::processSqlStatus()
- {
- switch (dbState) {
- case CREATED:
- case NORMAL:
- if (sqlca.sqlcode != 0) {
- dbState = SQL_ERROR;
- return -1;
- } else {
- dbState = NORMAL;
- return 0;
- }
- case SQL_ERROR:
- case TYPE_ERROR:
- return -1;
- }
- return -1;
- }
-
-