home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1997 November
/
PCWorld_1997-11_cd.bin
/
software
/
programy
/
komix
/
DATA.Z
/
DBObject.ec
< prev
next >
Wrap
Text File
|
1996-05-31
|
3KB
|
124 lines
/*---------------------------------------------------------------------------
*
* 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 1.4
* 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 1.4 17 Oct 1995 Copyright 1994 Westmount Technology";
#include "stream.h"
#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;
}