/* Processed by ecpg (2.7.1) */
/* These three include files are added by the preprocessor */
#include <ecpgtype.h>
#include <ecpglib.h>
#include <ecpgerrno.h>
#line 1 "test1.pgc"

#line 1 "../include/sqlca.h"
#ifndef POSTGRES_SQLCA_H#define POSTGRES_SQLCA_H#define SQLERRMC_LEN	70#ifdef __cplusplusextern"C"{#endifstructsqlca{charsqlcaid[8];longsqlabc;longsqlcode;struct{intsqlerrml;charsqlerrmc[SQLERRMC_LEN];}sqlerrm;charsqlerrp[8];longsqlerrd[6];/*/*/*/*/*/*/*/*charsqlwarn[8];/*/*/*/*/*/*/*/*/*/*charsqlext[8];};externstructsqlcasqlca;#ifdef __cplusplus}#endif#endif
#line 0 "test1.pgc"
/* exec sql whenever sqlerror  do PrintAndStop ( msg ) ; */

#line 2 "test1.pgc"
/* exec sql whenever sql_warning  do warn (  ) ; */

#line 3 "test1.pgc"
voidPrintAndStop(msg){fprintf(stderr,"Error in statement '%s':\n",msg);sqlprint();exit(-1);}voidwarn(void){fprintf(stderr,"Warning: At least one column was truncated\n");}/*
#line 20 "test1.pgc"
/* exec sql type intarray is int [ 6 ]   */
#line 20 "test1.pgc"
/* exec sql type string is char [ 8 ]   */
#line 21 "test1.pgc"
typedefintintarray[6
#line 23 "test1.pgc"
];intmain(){/* exec sql begin declare section */
#line 31 "test1.pgc"

#line 32 "test1.pgc"

#line 29 "test1.pgc"
   intarray  amount   ;
 
#line 30 "test1.pgc"
   int  increment  = 100 ;
 
#line 31 "test1.pgc"
   char  name [ 6 ] [ 8 ]   ;
 
#line 32 "test1.pgc"
   char  letter [ 6 ] [ 1 ]   ;
 
#line 33 "test1.pgc"
   char  command [ 128 ]   ;
/* exec sql end declare section */
#line 34 "test1.pgc"

#line 35 "test1.pgc"
/* exec sql var name is string [ 6 ]   */
#line 35 "test1.pgc"
charmsg[128];FILE*dbgs;inti,j;if((dbgs=fopen("log","w"))!=NULL)ECPGdebug(1,dbgs);strcpy(msg,"connect");{ ECPGconnect(__LINE__, "mm" , NULL,NULL , "main", 0);
#line 44 "test1.pgc"

if (sqlca.sqlwarn[0] == 'W') warn (  );
#line 44 "test1.pgc"

if (sqlca.sqlcode < 0) PrintAndStop ( msg );}
#line 44 "test1.pgc"
strcpy(msg,"connect");{ ECPGconnect(__LINE__, "pm" , NULL,NULL , NULL, 0);
#line 47 "test1.pgc"

if (sqlca.sqlwarn[0] == 'W') warn (  );
#line 47 "test1.pgc"

if (sqlca.sqlcode < 0) PrintAndStop ( msg );}
#line 47 "test1.pgc"
strcpy(msg,"create");{ ECPGdo(__LINE__, "main", "create  table \"Test\" ( name char  ( 8 )    , amount int    , letter char  ( 1 )    ) ", ECPGt_EOIT, ECPGt_EORT);

#line 50 "test1.pgc"

if (sqlca.sqlwarn[0] == 'W') warn (  );
#line 50 "test1.pgc"

if (sqlca.sqlcode < 0) PrintAndStop ( msg );}
#line 50 "test1.pgc"
{ ECPGdo(__LINE__, NULL, "create  table \"Test\" ( name char  ( 8 )    , amount int    , letter char  ( 1 )    ) ", ECPGt_EOIT, ECPGt_EORT);

#line 51 "test1.pgc"

if (sqlca.sqlwarn[0] == 'W') warn (  );
#line 51 "test1.pgc"

if (sqlca.sqlcode < 0) PrintAndStop ( msg );}
#line 51 "test1.pgc"
strcpy(msg,"commit");{ ECPGtrans(__LINE__, "main", "commit");
#line 54 "test1.pgc"

if (sqlca.sqlwarn[0] == 'W') warn (  );
#line 54 "test1.pgc"

if (sqlca.sqlcode < 0) PrintAndStop ( msg );}
#line 54 "test1.pgc"
{ ECPGtrans(__LINE__, NULL, "commit");
#line 55 "test1.pgc"

if (sqlca.sqlwarn[0] == 'W') warn (  );
#line 55 "test1.pgc"

if (sqlca.sqlcode < 0) PrintAndStop ( msg );}
#line 55 "test1.pgc"
strcpy(msg,"set connection");{ ECPGsetconn(__LINE__, "main");
#line 58 "test1.pgc"

if (sqlca.sqlwarn[0] == 'W') warn (  );
#line 58 "test1.pgc"

if (sqlca.sqlcode < 0) PrintAndStop ( msg );}
#line 58 "test1.pgc"
strcpy(msg,"execute insert 1");sprintf(command,"insert into \"Test\" (name, amount, letter) values ('db: ''mm''', 1, 'f')");{ ECPGdo(__LINE__, NULL, "?", 
	ECPGt_char_variable,(command),1L,1L,1*sizeof(char), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);

#line 62 "test1.pgc"

if (sqlca.sqlwarn[0] == 'W') warn (  );
#line 62 "test1.pgc"

if (sqlca.sqlcode < 0) PrintAndStop ( msg );}
#line 62 "test1.pgc"
printf("New tuple got OID = %d\n",sqlca.sqlerrd[1]);sprintf(command,"insert into \"Test\" (name, amount, letter) values ('db: \\\'mm\\\'', 2, 't')");{ ECPGdo(__LINE__, NULL, "?", 
	ECPGt_char_variable,(command),1L,1L,1*sizeof(char), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);

#line 66 "test1.pgc"

if (sqlca.sqlwarn[0] == 'W') warn (  );
#line 66 "test1.pgc"

if (sqlca.sqlcode < 0) PrintAndStop ( msg );}
#line 66 "test1.pgc"
strcpy(msg,"execute insert 2");sprintf(command,"insert into \"Test\" (name, amount, letter) values ('db: ''pm''', 1, 'f')");{ ECPGdo(__LINE__, "pm", "?", 
	ECPGt_char_variable,(command),1L,1L,1*sizeof(char), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);

#line 70 "test1.pgc"

if (sqlca.sqlwarn[0] == 'W') warn (  );
#line 70 "test1.pgc"

if (sqlca.sqlcode < 0) PrintAndStop ( msg );}
#line 70 "test1.pgc"
strcpy(msg,"execute insert 3");sprintf(command,"insert into \"Test\" (name, amount, letter) select name, amount+10, letter from \"Test\"");{ ECPGdo(__LINE__, NULL, "?", 
	ECPGt_char_variable,(command),1L,1L,1*sizeof(char), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);

#line 74 "test1.pgc"

if (sqlca.sqlwarn[0] == 'W') warn (  );
#line 74 "test1.pgc"

if (sqlca.sqlcode < 0) PrintAndStop ( msg );}
#line 74 "test1.pgc"
printf("Inserted %d tuples via execute immediate\n",sqlca.sqlerrd[2]);strcpy(msg,"execute insert 4");sprintf(command,"insert into \"Test\" (name, amount, letter) select name, amount+?, letter from \"Test\"");{ ECPGprepare(__LINE__, "I", command);
#line 80 "test1.pgc"

if (sqlca.sqlwarn[0] == 'W') warn (  );
#line 80 "test1.pgc"

if (sqlca.sqlcode < 0) PrintAndStop ( msg );}
#line 80 "test1.pgc"
{ ECPGdo(__LINE__, "pm", "?", 
	ECPGt_char_variable,(ECPGprepared_statement("I")),1L,1L,1*sizeof(char), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_int,&(increment),1L,1L,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);

#line 81 "test1.pgc"

if (sqlca.sqlwarn[0] == 'W') warn (  );
#line 81 "test1.pgc"

if (sqlca.sqlcode < 0) PrintAndStop ( msg );}
#line 81 "test1.pgc"
printf("Inserted %d tuples via prepared execute\n",sqlca.sqlerrd[2]);strcpy(msg,"commit");{ ECPGtrans(__LINE__, NULL, "commit");
#line 86 "test1.pgc"

if (sqlca.sqlwarn[0] == 'W') warn (  );
#line 86 "test1.pgc"

if (sqlca.sqlcode < 0) PrintAndStop ( msg );}
#line 86 "test1.pgc"
/*{ ECPGsetcommit(__LINE__, "on", "pm");
#line 89 "test1.pgc"

if (sqlca.sqlwarn[0] == 'W') warn (  );
#line 89 "test1.pgc"

if (sqlca.sqlcode < 0) PrintAndStop ( msg );}
#line 89 "test1.pgc"
{ ECPGtrans(__LINE__, "pm", "begin transaction");
#line 90 "test1.pgc"

if (sqlca.sqlwarn[0] == 'W') warn (  );
#line 90 "test1.pgc"

if (sqlca.sqlcode < 0) PrintAndStop ( msg );}
#line 90 "test1.pgc"
strcpy(msg,"select");{ ECPGdo(__LINE__, NULL, "select  name  , amount  , letter   from \"Test\"       ", ECPGt_EOIT, 
	ECPGt_char,(name),8L,6L,8*sizeof(char), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_int,(amount),1L,6L,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_char,(letter),1L,6L,1*sizeof(char), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);

#line 93 "test1.pgc"

if (sqlca.sqlwarn[0] == 'W') warn (  );
#line 93 "test1.pgc"

if (sqlca.sqlcode < 0) PrintAndStop ( msg );}
#line 93 "test1.pgc"
printf("Database: mm\n");for(i=0,j=sqlca.sqlerrd[2];i<j;i++){/* exec sql begin declare section */
#line 99 "test1.pgc"
   char  n [ 8 ]   ,  l  = letter [ i ] [ 0 ] ;
 
#line 100 "test1.pgc"
   int  a  = amount [ i ] ;
/* exec sql end declare section */
#line 101 "test1.pgc"
strncpy(n,name[i],8);printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n",i,n,i,a,i,l);amount[i]+=1000;strcpy(msg,"insert");{ ECPGdo(__LINE__, "pm", "insert into \"Test\" ( name  , amount  , letter  ) values ( ? , ? , ? )", 
	ECPGt_char,(n),8L,1L,8*sizeof(char), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_int,&(a),1L,1L,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_char,&(l),1L,1L,1*sizeof(char), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);

#line 108 "test1.pgc"

if (sqlca.sqlwarn[0] == 'W') warn (  );
#line 108 "test1.pgc"

if (sqlca.sqlcode < 0) PrintAndStop ( msg );}
#line 108 "test1.pgc"
}strcpy(msg,"select");{ ECPGdo(__LINE__, "pm", "select  *  from \"Test\"       ", ECPGt_EOIT, 
	ECPGt_char,(name),8L,6L,8*sizeof(char), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_int,(amount),1L,6L,sizeof(int), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_char,(letter),1L,6L,1*sizeof(char), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);

#line 112 "test1.pgc"

if (sqlca.sqlwarn[0] == 'W') warn (  );
#line 112 "test1.pgc"

if (sqlca.sqlcode < 0) PrintAndStop ( msg );}
#line 112 "test1.pgc"
printf("Database: pm\n");for(i=0,j=sqlca.sqlerrd[2];i<j;i++)printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n",i,name[i],i,amount[i],i,letter[i][0]);strcpy(msg,"commit");{ ECPGtrans(__LINE__, NULL, "commit");
#line 119 "test1.pgc"

if (sqlca.sqlwarn[0] == 'W') warn (  );
#line 119 "test1.pgc"

if (sqlca.sqlcode < 0) PrintAndStop ( msg );}
#line 119 "test1.pgc"
{ ECPGtrans(__LINE__, "pm", "commit");
#line 120 "test1.pgc"

if (sqlca.sqlwarn[0] == 'W') warn (  );
#line 120 "test1.pgc"

if (sqlca.sqlcode < 0) PrintAndStop ( msg );}
#line 120 "test1.pgc"
/*{ ECPGsetcommit(__LINE__, "on", NULL);
#line 123 "test1.pgc"

if (sqlca.sqlwarn[0] == 'W') warn (  );
#line 123 "test1.pgc"

if (sqlca.sqlcode < 0) PrintAndStop ( msg );}
#line 123 "test1.pgc"
strcpy(msg,"drop");{ ECPGdo(__LINE__, NULL, "drop table \"Test\"", ECPGt_EOIT, ECPGt_EORT);

#line 126 "test1.pgc"

if (sqlca.sqlwarn[0] == 'W') warn (  );
#line 126 "test1.pgc"

if (sqlca.sqlcode < 0) PrintAndStop ( msg );}
#line 126 "test1.pgc"
{ ECPGdo(__LINE__, "pm", "drop table \"Test\"", ECPGt_EOIT, ECPGt_EORT);

#line 127 "test1.pgc"

if (sqlca.sqlwarn[0] == 'W') warn (  );
#line 127 "test1.pgc"

if (sqlca.sqlcode < 0) PrintAndStop ( msg );}
#line 127 "test1.pgc"
strcpy(msg,"disconnect");{ ECPGdisconnect(__LINE__, "main");
#line 130 "test1.pgc"

if (sqlca.sqlwarn[0] == 'W') warn (  );
#line 130 "test1.pgc"

if (sqlca.sqlcode < 0) PrintAndStop ( msg );}
#line 130 "test1.pgc"
{ ECPGdisconnect(__LINE__, "pm");
#line 131 "test1.pgc"

if (sqlca.sqlwarn[0] == 'W') warn (  );
#line 131 "test1.pgc"

if (sqlca.sqlcode < 0) PrintAndStop ( msg );}
#line 131 "test1.pgc"
if(dbgs!=NULL)fclose(dbgs);return(0);}