libdatabase/utils/dbbench.c
2006-02-28 23:28:21 +00:00

710 lines
30 KiB
C
Raw Blame History

/*---------------------------------------------------------------------------------*/
/* $RCSfile: dbbench.c,v $ */
/*---------------------------------------------------------------------------------*/
/* $Revision: 1.1 $ */
/* $Name: $ */
/* $Date: 2006/02/28 23:28:21 $ */
/* $Author: agibert $ */
/*---------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------------*/
/* This file is part of LibDataBase */
/* */
/* LibDataBase is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU Lesser General Public Licence as published by */
/* the Free Software Foundation; either version 2.1 of the License, or */
/* (at your option) any later version. */
/* */
/* LibDataBase is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU Lesser General Public License for more details. */
/* */
/* You should have received a copy of the GNU Lesser General Public License */
/* along with LibDataBase; if not, write to the Free Software */
/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/*---------------------------------------------------------------------------------*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include "../lib/database.h"
/* D<>finition des propri<72>t<EFBFBD>s de la tables sur laquelle les tests sont r<>alis<69>s */
/* CREATE TABLE TOTO (
CD_TOTO CHAR (3) NOT NULL PRIMARY KEY,
LIB_TOTO VARCHAR2 (50),
NUM_TOTO NUMBER (5) NOT NULL,
DAT_TOTO DATE);
*/
#define CD_TOTO_LEN 3
#define LIB_TOTO_LEN 50
/* Mesure des temps d'ex<65>cution */
typedef struct
{
double sec;
struct timeval start;
struct timeval stop;
} cpt;
#define t_start(x) {gettimeofday (&(x.start), NULL);}
#define t_stop(x) {gettimeofday (&(x.stop), NULL); x.sec=(double)(x.stop.tv_sec)-(double)(x.start.tv_sec)+((double)(x.stop.tv_usec)-(double)(x.start.tv_usec))/1000000;}
#define NB_MAX_RECORD 2
#define USAGE "Usage : %s insert|update|delete|select [start=<idx>] [exec=<nb_exec>]\n"
/*--------------------------------------------------------------*/
/* Fonction principale du bench */
/*--------------------------------------------------------------*/
int main ( int argc , char ** argv )
{
cpt t_exec;
DBT_Status rc;
DBT_Result Result;
DBT_Result ins_Result;
unsigned int i;
unsigned int Start_Idx = 0;
unsigned int Nb_Exec = NB_MAX_RECORD;
const char * Request;
const char * ins_Request;
DBT_Indicator Tab_Indic [NB_MAX_RECORD];
DBT_Indicator Tab_ins_Indic [NB_MAX_RECORD];
char Tab_CD_TOTO [NB_MAX_RECORD][CD_TOTO_LEN + 1];
char Tab_LIB_TOTO [NB_MAX_RECORD][LIB_TOTO_LEN + 1];
char Date_Value [11];
int Tab_NUM_TOTO [NB_MAX_RECORD];
int Tab_CT_PERSONNE_PHYSIQUE[NB_MAX_RECORD];
int Tab_ins_CT_PERSONNE_PHYSIQUE[NB_MAX_RECORD];
char Tab_NUM_PP[NB_MAX_RECORD][8];
char Tab_ins_NUM_PP[NB_MAX_RECORD][8];
DBT_Date * Tab_DAT_DER_MAJ_BDM;
DBT_Date * Tab_DAT_CRE_PP_BDM;
int Tab_CT_CG_RDP[NB_MAX_RECORD];
int Tab_NUM_IDENT_CG_RDP[NB_MAX_RECORD];
DBT_Date * Tab_DAT_CRE_CG_BDM_RDP;
char Tab_CD_BQUE_RDP[NB_MAX_RECORD][6];
char Tab_CD_GUI_CLI_RDP[NB_MAX_RECORD][6];
char Tab_CD_ACT_ECO[NB_MAX_RECORD][3];
char Tab_CD_PAYS_NAIS[NB_MAX_RECORD][3];
int Tab_CD_SOGETYPE[NB_MAX_RECORD];
char Tab_CD_SIT_FAM[NB_MAX_RECORD][3];
char Tab_CD_CMN_INSEE_NAIS[NB_MAX_RECORD][3];
char Tab_CD_PAYS_RM[NB_MAX_RECORD][3];
char Tab_CD_PAYS_RF[NB_MAX_RECORD][3];
char Tab_CD_DEPT_NAIS[NB_MAX_RECORD][3];
char Tab_CD_ST_PROF[NB_MAX_RECORD][3];
char Tab_NOM_PAT[NB_MAX_RECORD][33];
char Tab_NOM_MAR[NB_MAX_RECORD][33];
char Tab_PNOM_OFF[NB_MAX_RECORD][33];
char Tab_PNOM_SUPP[NB_MAX_RECORD][33];
char Tab_RAISON_SOC[NB_MAX_RECORD][41];
int Tab_CT_FOYER_MKT[NB_MAX_RECORD];
char Tab_CD_CAT_PROF[NB_MAX_RECORD][3];
int Tab_CT_ADRESSE[NB_MAX_RECORD];
char Tab_CD_SEXE[NB_MAX_RECORD][3];
int Tab_CD_ST_INT_CHQ[NB_MAX_RECORD];
char Tab_CD_ST_DECEDE[NB_MAX_RECORD][3];
int Tab_CD_ST_COM_PP[NB_MAX_RECORD];
int Tab_CD_ETA_PP[NB_MAX_RECORD];
int Tab_CD_ST_TECH[NB_MAX_RECORD];
char Tab_CD_IND_PP_ANO[NB_MAX_RECORD][2];
int Tab_CD_CAP_JUR[NB_MAX_RECORD];
int Tab_CD_UNIC_PP[NB_MAX_RECORD];
char Tab_ADR_EMAIL[NB_MAX_RECORD][81];
DBT_Date * Tab_DAT_DER_MAJ_BLPP;
DBT_Date * Tab_DAT_DEB_REL_PP;
DBT_Date * Tab_DAT_NAIS;
DBT_Date * Tab_DAT_PUR_BLPP;
DBT_Date * Tab_DAT_FIN_ACT_COM;
int Tab_AGE[NB_MAX_RECORD];
char Tab_NUM_FAX[NB_MAX_RECORD][16];
char Tab_NUM_TEL_DOM[NB_MAX_RECORD][16];
char Tab_NUM_PORT[NB_MAX_RECORD][16];
int Tab_STP_MKT[NB_MAX_RECORD];
int Tab_STP_TEL[NB_MAX_RECORD];
int Tab_TP_FICP[NB_MAX_RECORD];
int Tab_TP_BFM[NB_MAX_RECORD];
int Tab_TP_HDG[NB_MAX_RECORD];
int Tab_TP_CLI_SNS[NB_MAX_RECORD];
int Tab_TP_NOR_DAT_NAIS[NB_MAX_RECORD];
int Tab_TP_TEL_DOM[NB_MAX_RECORD];
int Tab_TP_RLV_BRA[NB_MAX_RECORD];
int Tab_CD_PRIO_FOY[NB_MAX_RECORD];
char Tab_CD_SEG_MAR[NB_MAX_RECORD][6];
DBT_HostVar CT_PERSONNE_PHYSIQUE;
DBT_HostVar NUM_PP;
DBT_HostVar DAT_DER_MAJ_BDM;
DBT_HostVar DAT_CRE_PP_BDM;
DBT_HostVar CT_CG_RDP;
DBT_HostVar NUM_IDENT_CG_RDP;
DBT_HostVar DAT_CRE_CG_BDM_RDP;
DBT_HostVar CD_BQUE_RDP;
DBT_HostVar CD_GUI_CLI_RDP;
DBT_HostVar CD_ACT_ECO;
DBT_HostVar CD_PAYS_NAIS;
DBT_HostVar CD_SOGETYPE;
DBT_HostVar CD_SIT_FAM;
DBT_HostVar CD_CMN_INSEE_NAIS;
DBT_HostVar CD_PAYS_RM;
DBT_HostVar CD_PAYS_RF;
DBT_HostVar CD_DEPT_NAIS;
DBT_HostVar CD_ST_PROF;
DBT_HostVar NOM_PAT;
DBT_HostVar NOM_MAR;
DBT_HostVar PNOM_OFF;
DBT_HostVar PNOM_SUPP;
DBT_HostVar RAISON_SOC;
DBT_HostVar CT_FOYER_MKT;
DBT_HostVar CD_CAT_PROF;
DBT_HostVar CT_ADRESSE;
DBT_HostVar CD_SEXE;
DBT_HostVar CD_ST_INT_CHQ;
DBT_HostVar CD_ST_DECEDE;
DBT_HostVar CD_ST_COM_PP;
DBT_HostVar CD_ETA_PP;
DBT_HostVar CD_ST_TECH;
DBT_HostVar CD_IND_PP_ANO;
DBT_HostVar CD_CAP_JUR;
DBT_HostVar CD_UNIC_PP;
DBT_HostVar ADR_EMAIL;
DBT_HostVar DAT_DER_MAJ_BLPP;
DBT_HostVar DAT_DEB_REL_PP;
DBT_HostVar DAT_NAIS;
DBT_HostVar DAT_PUR_BLPP;
DBT_HostVar DAT_FIN_ACT_COM;
DBT_HostVar AGE;
DBT_HostVar NUM_FAX;
DBT_HostVar NUM_TEL_DOM;
DBT_HostVar NUM_PORT;
DBT_HostVar STP_MKT;
DBT_HostVar STP_TEL;
DBT_HostVar TP_FICP;
DBT_HostVar TP_BFM;
DBT_HostVar TP_HDG;
DBT_HostVar TP_CLI_SNS;
DBT_HostVar TP_NOR_DAT_NAIS;
DBT_HostVar TP_TEL_DOM;
DBT_HostVar TP_RLV_BRA;
DBT_HostVar CD_PRIO_FOY;
DBT_HostVar CD_SEG_MAR;
DBT_HostVar SEL_NUM_TOTO;
DBT_Cursor Cursor;
int t1, t2;
DBT_Indicator Tab_Indic_CT_PERSONNE_PHYSIQUE [NB_MAX_RECORD];
DBT_Indicator Tab_Indic_NUM_PP [NB_MAX_RECORD];
DBT_Indicator Tab_Indic_DAT_DER_MAJ_BDM [NB_MAX_RECORD];
DBT_Indicator Tab_Indic_DAT_CRE_PP_BDM [NB_MAX_RECORD];
DBT_Indicator Tab_Indic_CT_CG_RDP [NB_MAX_RECORD];
DBT_Indicator Tab_Indic_NUM_IDENT_CG_RDP [NB_MAX_RECORD];
DBT_Indicator Tab_Indic_DAT_CRE_CG_BDM_RDP [NB_MAX_RECORD];
DBT_Indicator Tab_Indic_CD_BQUE_RDP [NB_MAX_RECORD];
DBT_Indicator Tab_Indic_CD_GUI_CLI_RDP [NB_MAX_RECORD];
DBT_Indicator Tab_Indic_CD_ACT_ECO [NB_MAX_RECORD];
DBT_Indicator Tab_Indic_CD_PAYS_NAIS [NB_MAX_RECORD];
DBT_Indicator Tab_Indic_CD_SOGETYPE [NB_MAX_RECORD];
DBT_Indicator Tab_Indic_CD_SIT_FAM [NB_MAX_RECORD];
DBT_Indicator Tab_Indic_CD_CMN_INSEE_NAIS [NB_MAX_RECORD];
DBT_Indicator Tab_Indic_CD_PAYS_RM [NB_MAX_RECORD];
DBT_Indicator Tab_Indic_CD_PAYS_RF [NB_MAX_RECORD];
DBT_Indicator Tab_Indic_CD_DEPT_NAIS [NB_MAX_RECORD];
DBT_Indicator Tab_Indic_CD_ST_PROF [NB_MAX_RECORD];
DBT_Indicator Tab_Indic_NOM_PAT [NB_MAX_RECORD];
DBT_Indicator Tab_Indic_NOM_MAR [NB_MAX_RECORD];
DBT_Indicator Tab_Indic_PNOM_OFF [NB_MAX_RECORD];
DBT_Indicator Tab_Indic_PNOM_SUPP [NB_MAX_RECORD];
DBT_Indicator Tab_Indic_RAISON_SOC [NB_MAX_RECORD];
DBT_Indicator Tab_Indic_CT_FOYER_MKT [NB_MAX_RECORD];
DBT_Indicator Tab_Indic_CD_CAT_PROF [NB_MAX_RECORD];
DBT_Indicator Tab_Indic_CT_ADRESSE [NB_MAX_RECORD];
DBT_Indicator Tab_Indic_CD_SEXE [NB_MAX_RECORD];
DBT_Indicator Tab_Indic_CD_ST_INT_CHQ [NB_MAX_RECORD];
DBT_Indicator Tab_Indic_CD_ST_DECEDE [NB_MAX_RECORD];
DBT_Indicator Tab_Indic_CD_ST_COM_PP [NB_MAX_RECORD];
DBT_Indicator Tab_Indic_CD_ETA_PP [NB_MAX_RECORD];
DBT_Indicator Tab_Indic_CD_ST_TECH [NB_MAX_RECORD];
DBT_Indicator Tab_Indic_CD_IND_PP_ANO [NB_MAX_RECORD];
DBT_Indicator Tab_Indic_CD_CAP_JUR [NB_MAX_RECORD];
DBT_Indicator Tab_Indic_CD_UNIC_PP [NB_MAX_RECORD];
DBT_Indicator Tab_Indic_ADR_EMAIL [NB_MAX_RECORD];
DBT_Indicator Tab_Indic_DAT_DER_MAJ_BLPP [NB_MAX_RECORD];
DBT_Indicator Tab_Indic_DAT_DEB_REL_PP [NB_MAX_RECORD];
DBT_Indicator Tab_Indic_DAT_NAIS [NB_MAX_RECORD];
DBT_Indicator Tab_Indic_DAT_PUR_BLPP [NB_MAX_RECORD];
DBT_Indicator Tab_Indic_DAT_FIN_ACT_COM [NB_MAX_RECORD];
DBT_Indicator Tab_Indic_AGE [NB_MAX_RECORD];
DBT_Indicator Tab_Indic_NUM_FAX [NB_MAX_RECORD];
DBT_Indicator Tab_Indic_NUM_TEL_DOM [NB_MAX_RECORD];
DBT_Indicator Tab_Indic_NUM_PORT [NB_MAX_RECORD];
DBT_Indicator Tab_Indic_STP_MKT [NB_MAX_RECORD];
DBT_Indicator Tab_Indic_STP_TEL [NB_MAX_RECORD];
DBT_Indicator Tab_Indic_TP_FICP [NB_MAX_RECORD];
DBT_Indicator Tab_Indic_TP_BFM [NB_MAX_RECORD];
DBT_Indicator Tab_Indic_TP_HDG [NB_MAX_RECORD];
DBT_Indicator Tab_Indic_TP_CLI_SNS [NB_MAX_RECORD];
DBT_Indicator Tab_Indic_TP_NOR_DAT_NAIS [NB_MAX_RECORD];
DBT_Indicator Tab_Indic_TP_TEL_DOM [NB_MAX_RECORD];
DBT_Indicator Tab_Indic_TP_RLV_BRA [NB_MAX_RECORD];
DBT_Indicator Tab_Indic_CD_PRIO_FOY [NB_MAX_RECORD];
DBT_Indicator Tab_Indic_CD_SEG_MAR [NB_MAX_RECORD];
/* Ouverture de la librairie */
if (DB_Library_Open (DBD_ERRMSG | DBD_DEBUG) != DBS_OK)
{
fprintf (stderr, "=> Ouverture de la lbrairie LIBDATABASE impossible\n");
goto Error0;
}
/* Connexion <20> la base de donn<6E>es */
/* if (DB_DataBase_Connect (ORACLE, "PBDME1", "entr", "entr") != DBS_OK) */
if (DB_DataBase_Connect (ORACLE, "ENT1", "beatrice", "beatrice") != DBS_OK)
{
fprintf (stderr, "=> Connexion <20> la base impossible\n");
DB_Library_Close ();
goto Error1;
}
/* D\351finition des tableaux de valeurs */
DB_DateArray_Alloc (&Tab_DAT_DER_MAJ_BDM, NB_MAX_RECORD);
DB_DateArray_Alloc (&Tab_DAT_CRE_PP_BDM, NB_MAX_RECORD);
DB_DateArray_Alloc (&Tab_DAT_CRE_CG_BDM_RDP, NB_MAX_RECORD);
DB_DateArray_Alloc (&Tab_DAT_DER_MAJ_BLPP, NB_MAX_RECORD);
DB_DateArray_Alloc (&Tab_DAT_DEB_REL_PP, NB_MAX_RECORD);
DB_DateArray_Alloc (&Tab_DAT_NAIS, NB_MAX_RECORD);
DB_DateArray_Alloc (&Tab_DAT_PUR_BLPP, NB_MAX_RECORD);
DB_DateArray_Alloc (&Tab_DAT_FIN_ACT_COM, NB_MAX_RECORD);
/* D<>finition des variables h<>tes */
DB_HostVar_Setup (&CT_PERSONNE_PHYSIQUE,INTEGER,35,Tab_CT_PERSONNE_PHYSIQUE, Tab_Indic_CT_PERSONNE_PHYSIQUE);
DB_HostVar_Setup (&NUM_PP, STRING,7,Tab_NUM_PP, Tab_Indic_NUM_PP);
DB_HostVar_Setup (&DAT_DER_MAJ_BDM,DATE,NULL,Tab_DAT_DER_MAJ_BDM, Tab_Indic_DAT_DER_MAJ_BDM);
DB_HostVar_Setup (&DAT_CRE_PP_BDM,DATE,NULL,Tab_DAT_CRE_PP_BDM, Tab_Indic_DAT_CRE_PP_BDM);
DB_HostVar_Setup (&CT_CG_RDP,INTEGER,35,Tab_CT_CG_RDP, Tab_Indic_CT_CG_RDP);
DB_HostVar_Setup (&NUM_IDENT_CG_RDP,INTEGER,11,Tab_NUM_IDENT_CG_RDP, Tab_Indic_NUM_IDENT_CG_RDP);
DB_HostVar_Setup (&DAT_CRE_CG_BDM_RDP,DATE,NULL,Tab_DAT_CRE_CG_BDM_RDP, Tab_Indic_DAT_CRE_CG_BDM_RDP);
DB_HostVar_Setup (&CD_BQUE_RDP, STRING,5,Tab_CD_BQUE_RDP, Tab_Indic_CD_BQUE_RDP);
DB_HostVar_Setup (&CD_GUI_CLI_RDP, STRING,5,Tab_CD_GUI_CLI_RDP, Tab_Indic_CD_GUI_CLI_RDP);
DB_HostVar_Setup (&CD_ACT_ECO, STRING,2,Tab_CD_ACT_ECO, Tab_Indic_CD_ACT_ECO);
DB_HostVar_Setup (&CD_PAYS_NAIS, STRING,2,Tab_CD_PAYS_NAIS, Tab_Indic_CD_PAYS_NAIS);
DB_HostVar_Setup (&CD_SOGETYPE,INTEGER,2,Tab_CD_SOGETYPE, Tab_Indic_CD_SOGETYPE);
DB_HostVar_Setup (&CD_SIT_FAM, STRING,2,Tab_CD_SIT_FAM, Tab_Indic_CD_SIT_FAM);
DB_HostVar_Setup (&CD_CMN_INSEE_NAIS, STRING,5,Tab_CD_CMN_INSEE_NAIS, Tab_Indic_CD_CMN_INSEE_NAIS);
DB_HostVar_Setup (&CD_PAYS_RM, STRING,2,Tab_CD_PAYS_RM, Tab_Indic_CD_PAYS_RM);
DB_HostVar_Setup (&CD_PAYS_RF, STRING,2,Tab_CD_PAYS_RF, Tab_Indic_CD_PAYS_RF);
DB_HostVar_Setup (&CD_DEPT_NAIS, STRING,2,Tab_CD_DEPT_NAIS, Tab_Indic_CD_DEPT_NAIS);
DB_HostVar_Setup (&CD_ST_PROF, STRING,2,Tab_CD_ST_PROF, Tab_Indic_CD_ST_PROF);
DB_HostVar_Setup (&NOM_PAT, STRING,32,Tab_NOM_PAT, Tab_Indic_NOM_PAT);
DB_HostVar_Setup (&NOM_MAR, STRING,32,Tab_NOM_MAR, Tab_Indic_NOM_MAR);
DB_HostVar_Setup (&PNOM_OFF, STRING,32,Tab_PNOM_OFF, Tab_Indic_PNOM_OFF);
DB_HostVar_Setup (&PNOM_SUPP, STRING,32,Tab_PNOM_SUPP, Tab_Indic_PNOM_SUPP);
DB_HostVar_Setup (&RAISON_SOC, STRING,40,Tab_RAISON_SOC, Tab_Indic_RAISON_SOC);
DB_HostVar_Setup (&CT_FOYER_MKT,INTEGER,35,Tab_CT_FOYER_MKT, Tab_Indic_CT_FOYER_MKT);
DB_HostVar_Setup (&CD_CAT_PROF, STRING,2,Tab_CD_CAT_PROF, Tab_Indic_CD_CAT_PROF);
DB_HostVar_Setup (&CT_ADRESSE,INTEGER,35,Tab_CT_ADRESSE, Tab_Indic_CT_ADRESSE);
DB_HostVar_Setup (&CD_SEXE, STRING,2,Tab_CD_SEXE, Tab_Indic_CD_SEXE);
DB_HostVar_Setup (&CD_ST_INT_CHQ,INTEGER,1,Tab_CD_ST_INT_CHQ, Tab_Indic_CD_ST_INT_CHQ);
DB_HostVar_Setup (&CD_ST_DECEDE, STRING,2,Tab_CD_ST_DECEDE, Tab_Indic_CD_ST_DECEDE);
DB_HostVar_Setup (&CD_ST_COM_PP,INTEGER,1,Tab_CD_ST_COM_PP, Tab_Indic_CD_ST_COM_PP);
DB_HostVar_Setup (&CD_ETA_PP,INTEGER,1,Tab_CD_ETA_PP, Tab_Indic_CD_ETA_PP);
DB_HostVar_Setup (&CD_ST_TECH,INTEGER,1,Tab_CD_ST_TECH, Tab_Indic_CD_ST_TECH);
DB_HostVar_Setup (&CD_IND_PP_ANO, STRING,1,Tab_CD_IND_PP_ANO, Tab_Indic_CD_IND_PP_ANO);
DB_HostVar_Setup (&CD_CAP_JUR,INTEGER,1,Tab_CD_CAP_JUR, Tab_Indic_CD_CAP_JUR);
DB_HostVar_Setup (&CD_UNIC_PP,INTEGER,12,Tab_CD_UNIC_PP, Tab_Indic_CD_UNIC_PP);
DB_HostVar_Setup (&ADR_EMAIL, STRING,60,Tab_ADR_EMAIL, Tab_Indic_ADR_EMAIL);
DB_HostVar_Setup (&DAT_DER_MAJ_BLPP,DATE,NULL,Tab_DAT_DER_MAJ_BLPP, Tab_Indic_DAT_DER_MAJ_BLPP);
DB_HostVar_Setup (&DAT_DEB_REL_PP,DATE,NULL,Tab_DAT_DEB_REL_PP, Tab_Indic_DAT_DEB_REL_PP);
DB_HostVar_Setup (&DAT_NAIS,DATE,NULL,Tab_DAT_NAIS, Tab_Indic_DAT_NAIS);
DB_HostVar_Setup (&DAT_PUR_BLPP,DATE,NULL,Tab_DAT_PUR_BLPP, Tab_Indic_DAT_PUR_BLPP);
DB_HostVar_Setup (&DAT_FIN_ACT_COM,DATE,NULL,Tab_DAT_FIN_ACT_COM, Tab_Indic_DAT_FIN_ACT_COM);
DB_HostVar_Setup (&AGE,INTEGER,3,Tab_AGE, Tab_Indic_AGE);
DB_HostVar_Setup (&NUM_FAX, STRING,15,Tab_NUM_FAX, Tab_Indic_NUM_FAX);
DB_HostVar_Setup (&NUM_TEL_DOM, STRING,15,Tab_NUM_TEL_DOM, Tab_Indic_NUM_TEL_DOM);
DB_HostVar_Setup (&NUM_PORT, STRING,15,Tab_NUM_PORT, Tab_Indic_NUM_PORT);
DB_HostVar_Setup (&STP_MKT,INTEGER,1,Tab_STP_MKT, Tab_Indic_STP_MKT);
DB_HostVar_Setup (&STP_TEL,INTEGER,1,Tab_STP_TEL, Tab_Indic_STP_TEL);
DB_HostVar_Setup (&TP_FICP,INTEGER,1,Tab_TP_FICP, Tab_Indic_TP_FICP);
DB_HostVar_Setup (&TP_BFM,INTEGER,1,Tab_TP_BFM, Tab_Indic_TP_BFM);
DB_HostVar_Setup (&TP_HDG,INTEGER,1,Tab_TP_HDG, Tab_Indic_TP_HDG);
DB_HostVar_Setup (&TP_CLI_SNS,INTEGER,1,Tab_TP_CLI_SNS, Tab_Indic_TP_CLI_SNS);
DB_HostVar_Setup (&TP_NOR_DAT_NAIS,INTEGER,1,Tab_TP_NOR_DAT_NAIS, Tab_Indic_TP_NOR_DAT_NAIS);
DB_HostVar_Setup (&TP_TEL_DOM,INTEGER,1,Tab_TP_TEL_DOM, Tab_Indic_TP_TEL_DOM);
DB_HostVar_Setup (&TP_RLV_BRA,INTEGER,1,Tab_TP_RLV_BRA, Tab_Indic_TP_RLV_BRA);
DB_HostVar_Setup (&CD_PRIO_FOY,INTEGER,2,Tab_CD_PRIO_FOY, Tab_Indic_CD_PRIO_FOY);
DB_HostVar_Setup (&CD_SEG_MAR, STRING,5,Tab_CD_SEG_MAR, Tab_Indic_CD_SEG_MAR);
/* Ex<45>cution de la requ<71>te */
/* DB_HostVar_Setup(&SEL_NUM_TOTO, INTEGER, NULL, &Start_Idx, &Start_Idx); */
Request = "SELECT \
CT_PERSONNE_PHYSIQUE, \
NUM_PP, \
DAT_DER_MAJ_BDM, \
DAT_CRE_PP_BDM, \
CT_CG_RDP, \
NUM_IDENT_CG_RDP, \
DAT_CRE_CG_BDM_RDP, \
CD_BQUE_RDP, \
CD_GUI_CLI_RDP, \
CD_ACT_ECO, \
CD_PAYS_NAIS, \
CD_SOGETYPE, \
CD_SIT_FAM, \
CD_CMN_INSEE_NAIS, \
CD_PAYS_RM, \
CD_PAYS_RF, \
CD_DEPT_NAIS, \
CD_ST_PROF, \
NOM_PAT, \
NOM_MAR, \
PNOM_OFF, \
PNOM_SUPP, \
RAISON_SOC, \
CT_FOYER_MKT, \
CD_CAT_PROF, \
CT_ADRESSE, \
CD_SEXE, \
CD_ST_INT_CHQ, \
CD_ST_DECEDE, \
CD_ST_COM_PP, \
CD_ETA_PP, \
CD_ST_TECH, \
CD_IND_PP_ANO, \
CD_CAP_JUR, \
CD_UNIC_PP, \
ADR_EMAIL, \
DAT_DER_MAJ_BLPP, \
CD_SEG_MAR \
FROM TB_PERSONNE_PHYSIQUE";
/* Ouverture d'un curseur */
rc = DB_Cursor_Open (&Cursor, &Result, Request,NULL);
if (rc != DBS_OK)
{
fprintf (stderr, "=> S<>lection impossible\n");
goto Error2;
}
/* Fetch du curseur */
rc = DB_Cursor_Fetch (Cursor, &Result, Nb_Exec,
&CT_PERSONNE_PHYSIQUE,
&NUM_PP,
&DAT_DER_MAJ_BDM,
&DAT_CRE_PP_BDM,
&CT_CG_RDP,
&NUM_IDENT_CG_RDP,
&DAT_CRE_CG_BDM_RDP,
&CD_BQUE_RDP,
&CD_GUI_CLI_RDP,
&CD_ACT_ECO,
&CD_PAYS_NAIS,
&CD_SOGETYPE,
&CD_SIT_FAM,
&CD_CMN_INSEE_NAIS,
&CD_PAYS_RM,
&CD_PAYS_RF,
&CD_DEPT_NAIS,
&CD_ST_PROF,
&NOM_PAT,
&NOM_MAR,
&PNOM_OFF,
&PNOM_SUPP,
&RAISON_SOC,
&CT_FOYER_MKT,
&CD_CAT_PROF,
&CT_ADRESSE,
&CD_SEXE,
&CD_ST_INT_CHQ,
&CD_ST_DECEDE,
&CD_ST_COM_PP,
&CD_ETA_PP,
&CD_ST_TECH,
&CD_IND_PP_ANO,
&CD_CAP_JUR,
&CD_UNIC_PP,
&ADR_EMAIL,
&DAT_DER_MAJ_BLPP,
&CD_SEG_MAR,
NULL);
if (rc == DBS_OK)
{
fprintf (stderr, "=> %d enregistrement(s) s<>lectionn<6E>(s) :\n", Result.Row_Num);
}
else if (rc == DBS_ERRNODATA)
{
fprintf (stderr, "=> Il y a moins de %d enregistrement(s) <20> s<>lectionner.\n", Nb_Exec);
}
else
{
fprintf (stderr, "=> S<>lection impossible\n");
DB_Cursor_Close (Cursor);
goto Error2;
}
for (i = 0; i < Result.Row_Num; i++)
{
if (DB_DateToString_Convert (Tab_DAT_DER_MAJ_BDM, i, Date_Value, NULL) != DBS_OK) goto Error2;
fprintf (stderr, "Debug HME Tab_Indic_CD_ETA_PP = ##%d##\n", Tab_Indic_CD_ETA_PP[i]);
fprintf (stderr, "Debug HME CD_ETA_PP = ##%d##\n", Tab_CD_ETA_PP[i]);
fprintf (stderr, "Debug HME Tab_Indic_CD_ST_TECH = ##%d##\n", Tab_Indic_CD_ST_TECH[i]);
fprintf (stderr, "Debug HME CD_ST_TECH = ##%d##\n", Tab_CD_ST_TECH[i]);
}
/* Fermeture du curseur */
DB_Cursor_Close (Cursor);
if (DB_DataBase_Disconnect () != DBS_OK)
{
fprintf (stderr, "=> D\351connexion de la base impossible\n");
goto Error1;
}
/* INsertion dans la table TEST_ENS */
t_start (t_exec);
/* Connexion \340 la base de donn\351es */
if (DB_DataBase_Connect (ORACLE, "ENT1", "beatrice", "beatrice") != DBS_OK)
{
fprintf (stderr, "=> Connexion \340 la base impossible\n");
DB_Library_Close ();
goto Error1;
}
ins_Request = "INSERT INTO TEST_ENS \
( \
CT_PERSONNE_PHYSIQUE, \
NUM_PP, \
DAT_DER_MAJ_BDM \
/* DAT_CRE_PP_BDM, \
CT_CG_RDP, \
NUM_IDENT_CG_RDP, \
DAT_CRE_CG_BDM_RDP, \
CD_BQUE_RDP, \
CD_GUI_CLI_RDP, \
CD_ACT_ECO, \
CD_PAYS_NAIS, \
CD_SOGETYPE, \
CD_SIT_FAM, \
CD_CMN_INSEE_NAIS, \
CD_PAYS_RM, \
CD_PAYS_RF, \
CD_DEPT_NAIS, \
CD_ST_PROF, \
NOM_PAT, \
NOM_MAR, \
PNOM_OFF, \
PNOM_SUPP, \
RAISON_SOC, \
CT_FOYER_MKT, \
CD_CAT_PROF, \
CT_ADRESSE, \
CD_SEXE, \
CD_ST_INT_CHQ, \
CD_ST_DECEDE, \
CD_ST_COM_PP, \
CD_ETA_PP, \
CD_ST_TECH, \
CD_IND_PP_ANO, \
CD_CAP_JUR, \
CD_UNIC_PP, \
ADR_EMAIL, \
DAT_DER_MAJ_BLPP, \
CD_SEG_MAR */
) \
VALUES \
( \
:1, \
:2, \
:3 \
/* :4, \
:5, \
:6, \
:7, \
:8, \
:9, \
:10, \
:11, \
:12, \
:13, \
:14, \
:15, \
:16, \
:17, \
:18, \
:19, \
:20, \
:21, \
:22, \
:23, \
:24, \
:25, \
:26, \
:27, \
:28, \
:29, \
:30, \
:31, \
:32, \
:33, \
:34, \
:35, \
:36, \
:37, \
:38 */
)";
fprintf (stderr, "Result.Row_Num = ##%d##\n",Result.Row_Num);
fprintf (stderr, "Start_Idx = ##%d##\n",Start_Idx);
fprintf (stderr, "ins_Request = ##%s##\n",ins_Request);
rc = DB_Insert_Exec (&ins_Result, ins_Request, Nb_Exec, Start_Idx,
&CT_PERSONNE_PHYSIQUE,
&NUM_PP,
&DAT_DER_MAJ_BDM,
/* &DAT_CRE_PP_BDM,
&CT_CG_RDP,
&NUM_IDENT_CG_RDP,
&DAT_CRE_CG_BDM_RDP,
&CD_BQUE_RDP,
&CD_GUI_CLI_RDP,
&CD_ACT_ECO,
&CD_PAYS_NAIS,
&CD_SOGETYPE,
&CD_SIT_FAM,
&CD_CMN_INSEE_NAIS,
&CD_PAYS_RM,
&CD_PAYS_RF,
&CD_DEPT_NAIS,
&CD_ST_PROF,
&NOM_PAT,
&NOM_MAR,
&PNOM_OFF,
&PNOM_SUPP,
&RAISON_SOC,
&CT_FOYER_MKT,
&CD_CAT_PROF,
&CT_ADRESSE,
&CD_SEXE,
&CD_ST_INT_CHQ,
&CD_ST_DECEDE,
&CD_ST_COM_PP,
&CD_ETA_PP,
&CD_ST_TECH,
&CD_IND_PP_ANO,
&CD_CAP_JUR,
&CD_UNIC_PP,
&ADR_EMAIL,
&DAT_DER_MAJ_BLPP,
&CD_SEG_MAR, */
NULL);
if (rc == DBS_OK)
{
fprintf (stderr, "Insert OK\n");
}
else
{
fprintf (stderr, "Insert a <20>chou<6F>\n");
}
/*
if (DB_Transaction_Start (&t1) != DBS_OK) goto Error2;
rc = DB_Insert_Exec (&Result, Request, 10, 0, &CD_TOTO, &LIB_TOTO, &NUM_TOTO, &DAT_TOTO, NULL);
if (DB_Transaction_Start (&t2) != DBS_OK) goto Error2;
rc = DB_Insert_Exec (&Result, Request, 10, 10, &CD_TOTO, &LIB_TOTO, &NUM_TOTO, &DAT_TOTO, NULL);
if (DB_Transaction_Change (t1) != DBS_OK) goto Error2;
rc = DB_Insert_Exec (&Result, Request, 10, 20, &CD_TOTO, &LIB_TOTO, &NUM_TOTO, &DAT_TOTO, NULL);
if (DB_Transaction_Change (t2) != DBS_OK) goto Error2;
rc = DB_Insert_Exec (&Result, Request, 10, 30, &CD_TOTO, &LIB_TOTO, &NUM_TOTO, &DAT_TOTO, NULL);
if (DB_Rollback_Exec () != DBS_OK) goto Error2;
if (DB_Transaction_End () != DBS_OK) goto Error2;
if (DB_Transaction_Change (t1) != DBS_OK) goto Error2;
if (DB_Commit_Exec () != DBS_OK) goto Error2;
if (DB_Transaction_End () != DBS_OK) goto Error2;
*/
t_stop (t_exec);
/* Affichage du temps d'ex<65>cution */
if (Result.Row_Num)
{
fprintf (stdout, "%d enregistrement(s) trait<69>(s) en %.4f sec (%.2f enreg/sec)\n",
Result.Row_Num, t_exec.sec, Result.Row_Num / t_exec.sec );
}
if (DB_Commit_Exec () != DBS_OK) goto Error2;
/* Lib<69>ration des ressources */
DB_DateArray_Free (Tab_DAT_DER_MAJ_BDM);
DB_DateArray_Free (Tab_DAT_CRE_PP_BDM);
DB_DateArray_Free (Tab_DAT_CRE_CG_BDM_RDP);
DB_DateArray_Free (Tab_DAT_DER_MAJ_BLPP);
DB_DateArray_Free (Tab_DAT_DEB_REL_PP);
DB_DateArray_Free (Tab_DAT_NAIS);
DB_DateArray_Free (Tab_DAT_PUR_BLPP);
DB_DateArray_Free (Tab_DAT_FIN_ACT_COM);
/* D<>connexion de la base */
if (DB_DataBase_Disconnect () != DBS_OK)
{
fprintf (stderr, "=> D<>connexion de la base impossible\n");
goto Error1;
}
/* Fermeture de la librairie */
if (DB_Library_Close () != DBS_OK)
{
fprintf (stderr, "=> Fermeture de la librairie LIBDATABASE impossible\n");
goto Error0;
}
return 0;
/* Traitement des erreurs */
Error2:
DB_DateArray_Free (Tab_DAT_DER_MAJ_BDM);
DB_DateArray_Free (Tab_DAT_CRE_PP_BDM);
DB_DateArray_Free (Tab_DAT_CRE_CG_BDM_RDP);
DB_DateArray_Free (Tab_DAT_DER_MAJ_BLPP);
DB_DateArray_Free (Tab_DAT_DEB_REL_PP);
DB_DateArray_Free (Tab_DAT_NAIS);
DB_DateArray_Free (Tab_DAT_PUR_BLPP);
DB_DateArray_Free (Tab_DAT_FIN_ACT_COM);
DB_DataBase_Disconnect ();
Error1:
DB_Library_Close ();
Error0:
return -1;
}