home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
bufop.zip
/
TSTA.SQH
< prev
Wrap
Text File
|
1993-09-10
|
3KB
|
123 lines
#include <iostream.h>
#include <iksbag.h>
//
// This is a source sql file
// it will be transformed into "tsta.hpp"
//
class testCls
{
public:
testCls ();
~testCls();
create( char * name, char * Addr, int age, int id); // init and create
create(); // create with whats in the record
insertDBRec();
changeName(char * name);
changeID(int id);
changeAge(int age);
read(int recID);
update();
// Assigment
testCls & operator=(testCls const & a);
friend ostream
&operator <<(ostream & aStream, testCls const & arec);
inline Boolean operator == (char * n)const {return strcmp(name,n);}
inline char * const & getName()const {return pn;}
protected:
EXEC SQL BEGIN DECLARE SECTION;
char * pn; // pointer to name (needed for key access in container)
char name[40];
char addr[60];
int age;
unsigned short nullInd;
int recID;
EXEC SQL END DECLARE SECTION;
}; // end of class testCls
//
// support functions
//
void startit();
void stopit();
//========================================================
// define a collection (Key Sorted Set) of the elements
// use SQL select to get all entries from the table and
// store them in the collection
// Notice - the testCls elements (which are protected) are used in the
// the inherited class.
//=============================================================
typedef IKeySortedBag<testCls,char *> nameSet;
class selectTest : public testCls // derived from testcla
{
//
// use the overload << function to place elements into
// the collection
// could use the overload >> function to add/update elements
// in the collection
//
public:
selectTest();
selectTest(char * const & selectStr);
setSelect(char * const & selectStr);
//
// overload the << to fill the container
//
friend
nameSet & operator<<(nameSet & aset, selectTest & s);
EXEC SQL BEGIN DECLARE SECTION;
private:
char theSelectStr[800];
EXEC SQL END DECLARE SECTION;
};
//
// key access needed for collection class
//
inline char * const & key(testCls const & a) {return a.getName();}
//==================================================
// read/write into/out of structures
//====================================================
EXEC SQL BEGIN DECLARE SECTION;
struct stest {
char sname[40];
char saddr[80];
int sage;
};
EXEC SQL END DECLARE SECTION;
void readDB(stest * ); // read indirect using pointer