#ifndef TESTDB_HBG
#define TESTDB_HBG

#include "dbsys.h"


#define TEST_TABLENR    1000
typedef struct {
  int _iSize;
  int iDB;
  int _iTablenr;
  PFNCMP _pfnCmpPk;
  PFNCMP _pfnCmpLk;
  TFSurrogat	fszTEST_Id;
  TFChar_35	fszName;
  TFLong	flIVal;
  TFDouble	fdDVal;
} TEST;


typedef ARRAY MTEST;

#define MTEST_New()	(MTEST *) ARRAY_New()
MTEST * MTEST_Init(MTEST *mtest);
#define MTEST_Assign(p1,p2)	ARRAY_Assign((ARRAY*)p1,(ARRAY*)p2)
#define MTEST_Free(p)	ARRAY_Free((ARRAY*)p)
#define MTEST_Remove(p,i)	ARRAY_Remove((ARRAY*)p,i)
#define MTEST_Add(p,ps)	ARRAY_Add((ARRAY*)p,(void *)ps)
#define MTEST_SetDefault(p)	ARRAY_Free((ARRAY*)p)
#define MTEST_GetPtr(p,i)	((TEST*)ARRAY_GetPtr((ARRAY*)p,i))
#define MTEST_GetCount(p)	(((ARRAY*)p)->iCount)
#define MTEST_SetCmpFunc(p,pfn)	(p)->pfnCmp=(PFNCMP)pfn
#define MTEST_Sort(p)	ARRAY_Sort((ARRAY*)p)

extern int TEST_Sizeof(void);
extern TEST * TEST_New(void);
extern TEST * TEST_Init(TEST *test);
#define TEST_Assign(p1,p2)    (*(TEST*)p1=*(TEST*)p2)
#define TEST_SetDefault(p1)    TEST_Init((TEST*)p1)
#define TEST_SetDB(p1, p2)    (p1)->iDB = p2
extern char * TEST_Definition(void);
extern int TEST_BFill(TEST *test, DBresult *res, int row, int status, DBHANDLE *pbsc);
extern char * TEST_Attribs(void);
extern char * TEST_Data(DBHANDLE *pDBHANDLE, TEST *test);
extern int TEST_IsValid(DBHANDLE *pDBHANDLE, TEST *test);
extern char * TEST_TB_Attribs(int kz_db);
extern int TEST_SelectPk(TEST *test, DBHANDLE *pbsc);
extern int TEST_SelectLk(TEST *test, DBHANDLE *pbsc);
extern int TEST_Insert(TEST *test, DBHANDLE *pbsc);
extern int TEST_Load(TEST *test, DBHANDLE *pbsc);
extern int TEST_Update(TEST *test, DBHANDLE *pbsc);
extern int TEST_Delete(TEST *test, DBHANDLE *pbsc);
#define TEST_DeletePk(p1,p2)    TEST_Delete(p1,p2)
extern int TEST_DeleteAll(DBHANDLE *pbsc);
extern int TEST_Do(TEST *test, DBHANDLE *pbsc);

extern int TEST_CopyPk(TEST *test1, TEST *test2);

extern int TEST_CmpPk(TFSurrogat pkey, TEST *test2);
extern int TEST_CmpLk(TEST *test1, TEST *test2);

extern int TEST_Select(TEST *test, DBHANDLE *pbsc);
extern int TEST_Fetch(TEST *test, DBHANDLE *pbsc);

extern int TEST_Compare(DBHANDLE * pDBHANDLE, TEST * test1, TEST * test2, _MCMP * mcmp);

extern int TEST_Select_IVal (TEST * test, DBHANDLE * pDBHANDLE);
extern int TEST_Fetch_IVal (TEST * test, DBHANDLE * pDBHANDLE);

#endif
