home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
cppsql.zip
/
SQLSRC.ZIP
/
SQL.HPP
< prev
next >
Wrap
Text File
|
1992-09-18
|
10KB
|
332 lines
// :H1 sql.hpp: START OF SPECIFICATIONS
//----------------------------------------------------------------------
//
// Module Name: SQL.HPP
//
// Description: SQL Interface.
//
// Product Classification:
// IBM Internal Use Only
// (C) Copyright IBM Corp. 1992
//
// Status: New
//
// Initial Author: George L. Havens
//
// Function: To provide an interface to SQL databases.
//
// Notes: None.
//
// Dependencies: Requires PORTABLE.H include.
//
// Restrictions: None.
//
// Compiler: Zortech C++
//
// Change Activity -----------------------------------------------------
//
// $MOD(module) COMP(component) PROD(product): Description...
//
// FLAG REASON VERS DATE WHO DESCRIPTION
// ---- -------- ---- ------ --- -----------
// V100 920224 GLH : Initial level
// $P1 P0001979 V100 920608 GLH : Fix problems caused when start database
// started from application
//
// END-OF-SPECIFICATIONS -----------------------------------------------
#ifndef XX_SQL
#define XX_SQL
class SQL
{
public:
//----------------------------------------------------------------------
//
// Function Name: SQL constructor
//
// Purpose: This method is the SQL object constructor.
//
// Description: This method will save the name of the database.
//
// Input:
// name database name to be used
// access access is SHARED or EXCLUSIVE, default is SHARED
// drive drive to create database on
//
// Output:
// none
//
//----------------------------------------------------------------------
SQL (const CHAR *name, CHAR access = 'S', CHAR drive = 0);
#define SHARE 'S' // shared access
#define EXCLUSIVE 'X' // exclusive access
//----------------------------------------------------------------------
//
// Function Name: Create
//
// Purpose: This method creates an SQL database.
//
// Description: This method creates an SQL database. The database must still
// be opened to be used.
//
// Input:
// comment comment to be placed into database
// bind_path path for SQL bind file
//
// Output:
// return code 0 = successful, not 0 = error
//
//----------------------------------------------------------------------
SHORT Create (const CHAR *comment = "", const CHAR *bind_path = ".");
//----------------------------------------------------------------------
//
// Function Name: Open
//
// Purpose: This method opens an SQL database.
//
// Description: This method attempts to open an SQL database.
//
// Input:
// none
//
// Output:
// return code 0 = successful, not 0 = error
//
//----------------------------------------------------------------------
SHORT Open (VOID);
//----------------------------------------------------------------------
//
// Function Name: Close
//
// Purpose: This method will close an SQL database.
//
// Description: This method will close an SQL database.
//
// Input:
// none
//
// Output:
// return code 0 = successful, not 0 = error
//
//----------------------------------------------------------------------
SHORT Close (VOID);
//----------------------------------------------------------------------
//
// Function Name: Delete
//
// Purpose: This method will delete an SQL database.
//
// Description: This method will delete an SQL database.
//
// Input:
// none
//
// Output:
// return code 0 = successful, not 0 = error
//
//----------------------------------------------------------------------
SHORT Delete (VOID);
//----------------------------------------------------------------------
//
// Function Name: Get_buffer_size
//
// Purpose: This method will get the buffer size for an SQL database.
//
// Description: This method will get the size for the specified SQL database.
//
// Input:
// size size of buffer
//
// Output:
// return code 0 = successful, not 0 = error
//
//----------------------------------------------------------------------
SHORT Get_buffer_size (USHORT& size);
//----------------------------------------------------------------------
//
// Function Name: Set_buffer_size
//
// Purpose: This method will set the buffer size for an SQL database.
//
// Description: This method will set the size for the specified SQL database.
//
// Input:
// size size of buffer
//
// Output:
// return code 0 = successful, not 0 = error
//
//----------------------------------------------------------------------
SHORT Set_buffer_size (USHORT size);
//----------------------------------------------------------------------
//
// Function Name: Get_log_size
//
// Purpose: This method will get the log file size for an SQL database.
//
// Description: This method will get the size for the specified SQL database.
//
// Input:
// size size of log file
//
// Output:
// return code 0 = successful, not 0 = error
//
//----------------------------------------------------------------------
SHORT Get_log_size (USHORT& size);
//----------------------------------------------------------------------
//
// Function Name: Set_log_size
//
// Purpose: This method will set the log file size for an SQL database.
//
// Description: This method will set the size for the specified SQL database.
//
// Input:
// size size of buffer
//
// Output:
// return code 0 = successful, not 0 = error
//
//----------------------------------------------------------------------
SHORT Set_log_size (USHORT size);
//----------------------------------------------------------------------
//
// Function Name: Get_log_number
//
// Purpose: This method will get the number log files for an SQL database.
//
// Description: This method will get the number of primary and seconday
// log files.
//
// Input:
// num_pri number of primary log files
// num_sec number of secondary log files
//
// Output:
// return code 0 = successful, not 0 = error
//
//----------------------------------------------------------------------
SHORT Get_log_number (USHORT& num_pri, USHORT& num_sec);
//----------------------------------------------------------------------
//
// Function Name: Set_log_number
//
// Purpose: This method will set the number log files for an SQL database.
//
// Description: This method will set the number of primary and seconday
// log files.
//
// Input:
// num_pri number of primary log files
// num_sec number of secondary log files
//
// Output:
// return code 0 = successful, not 0 = error
//
//----------------------------------------------------------------------
SHORT Set_log_number (USHORT num_pri, USHORT num_sec);
//----------------------------------------------------------------------
//
// Function Name: Commit
//
// Purpose: This method will commit the changes to the database.
//
// Description: This method will commit all the changes that have been
// made to the database.
//
// Input:
// none
//
// Output:
// return code 0 = successful, not 0 = error
//
//----------------------------------------------------------------------
SHORT Commit (VOID);
//----------------------------------------------------------------------
//
// Function Name: Rollback
//
// Purpose: This method will rollback changes to the database.
//
// Description: This method will rollback all the changes that have been
// made to the database.
//
// Input:
// none
//
// Output:
// return code 0 = successful, not 0 = error
//
//----------------------------------------------------------------------
SHORT Rollback (VOID);
//----------------------------------------------------------------------
//
// Function Name: Error
//
// Purpose: This method will return last method return code and
// location.
//
// Description: This method will return the last method return code
// and location saved in private variables.
// Input:
// none
//
// Output:
// rc_a return code
// id_a location of error
//
//----------------------------------------------------------------------
inline VOID Error (SHORT& rc_a, SHORT& id_a)
{
// set current return code and location
rc_a = rc;
id_a = (rc == 0) ? 0 : id;
}
//----------------------------------------------------------------------
//
// Function Name: SQL destructor
//
// Purpose: This method is the SQL object destructor.
//
// Description: This method will free the database name, close
// the database, and stop the database manager.
//
// Input:
// none
//
// Output:
// none
//
//----------------------------------------------------------------------
~SQL ();
private:
CHAR *database; // database name
CHAR use; // database use, SHARED or EXCLUSIVE
CHAR build_drive; // database build on drive
SHORT rc; // return code for last operation
#define SQL_MEMORY_ERROR -10500
#define SQL_NAME_ERROR -1001 // SQL error code
SHORT id; // id of where last error occurred
// #define SQL_ID_1 1 // available for use // @P1C
#define SQL_ID_2 2
#define SQL_ID_3 3
#define SQL_ID_4 4
#define SQL_ID_5 5
// #define SQL_ID_6 6 // available for use
#define SQL_ID_7 7
#define SQL_ID_8 8
#define SQL_ID_9 9
#define SQL_ID_10 10
#define SQL_ID_11 11
#define SQL_ID_12 12
#define SQL_ID_13 13
#define SQL_ID_14 14
#define SQL_ID_15 15
#define SQL_ID_16 16
#define SQL_ID_17 17
#define SQL_ID_18 18
};
#endif