@@ -80,7 +80,7 @@ print_action(struct when *w)
8080static void
8181whenever_action (int mode)
8282{
83- if (mode ==1 && when_nf.code != W_NOTHING)
83+ if (( mode& 1 ) ==1 && when_nf.code != W_NOTHING)
8484{
8585output_line_number ();
8686fprintf (yyout," \n if (sqlca.sqlcode == ECPG_NOT_FOUND)" );
@@ -98,6 +98,8 @@ whenever_action(int mode)
9898fprintf (yyout," \n if (sqlca.sqlcode < 0)" );
9999print_action (&when_error);
100100 }
101+ if ((mode&2 ) ==2 )
102+ fputc (' }' , yyout);
101103output_line_number ();
102104}
103105
@@ -525,7 +527,7 @@ output_statement(char * stmt, int mode)
525527{
526528int i, j=strlen (stmt);
527529
528- fprintf (yyout," ECPGdo(__LINE__, %s,\" " , connection ? connection :" NULL" );
530+ fprintf (yyout," { ECPGdo(__LINE__, %s,\" " , connection ? connection :" NULL" );
529531
530532/* do this char by char as we have to filter '\"'*/
531533for (i =0 ;i < j; i++)
@@ -538,6 +540,7 @@ output_statement(char * stmt, int mode)
538540fputs (" ECPGt_EOIT," , yyout);
539541dump_variables (argsresult,1 );
540542fputs (" ECPGt_EORT);" , yyout);
543+ mode |=2 ;
541544whenever_action (mode);
542545free (stmt);
543546if (connection !=NULL )
@@ -854,7 +857,7 @@ prog: statements;
854857statements :/* empty*/
855858| statements statement
856859
857- statement :ecpgstart opt_at stmt ' ;' { connection =NULL ; }
860+ statement :ecpgstart opt_at stmt ' ;' { connection =NULL ; }
858861| ecpgstart stmt ' ;'
859862| ECPGDeclaration
860863| c_thing { fprintf(yyout," %s" ,$1 ); free($1 ); }
@@ -903,8 +906,8 @@ stmt: AddAttrStmt{ output_statement($1, 0); }
903906}
904907| RuleStmt { output_statement($1 ,0 ); }
905908| TransactionStmt {
906- fprintf (yyout," ECPGtrans(__LINE__, %s,\" %s\" );" , connection ? connection :" NULL" , $1 );
907- whenever_action (0 );
909+ fprintf (yyout," { ECPGtrans(__LINE__, %s,\" %s\" );" , connection ? connection :" NULL" , $1 );
910+ whenever_action (2 );
908911free ($1 );
909912}
910913| ViewStmt { output_statement($1 ,0 ); }
@@ -919,8 +922,8 @@ stmt: AddAttrStmt{ output_statement($1, 0); }
919922if (connection)
920923yyerror (" no at option for connect statement.\n " );
921924
922- fprintf (yyout," ECPGconnect(__LINE__, %s, %d);" , $1 , autocommit);
923- whenever_action (0 );
925+ fprintf (yyout," { ECPGconnect(__LINE__, %s, %d);" , $1 , autocommit);
926+ whenever_action (2 );
924927free ($1 );
925928}
926929| ECPGCursorStmt {
@@ -930,8 +933,9 @@ stmt: AddAttrStmt{ output_statement($1, 0); }
930933if (connection)
931934yyerror (" no at option for connect statement.\n " );
932935
936+ fputc (' {' , yyout);
933937fputs ($1 , yyout);
934- whenever_action (0 );
938+ whenever_action (2 );
935939free ($1 );
936940}
937941| ECPGDeclare {
@@ -941,16 +945,16 @@ stmt: AddAttrStmt{ output_statement($1, 0); }
941945if (connection)
942946yyerror (" no at option for disconnect statement.\n " );
943947
944- fprintf (yyout," ECPGdisconnect(__LINE__,\" %s\" );" , $1 );
945- whenever_action (0 );
948+ fprintf (yyout," { ECPGdisconnect(__LINE__,\" %s\" );" , $1 );
949+ whenever_action (2 );
946950free ($1 );
947951}
948952| ECPGExecute {
949953output_statement ($1 ,0 );
950954}
951955| ECPGFree {
952- fprintf (yyout," ECPGdeallocate(__LINE__, %s,\" %s\" );" , connection ? connection :" NULL" , $1 );
953- whenever_action (0 );
956+ fprintf (yyout," { ECPGdeallocate(__LINE__, %s,\" %s\" );" , connection ? connection :" NULL" , $1 );
957+ whenever_action (2 );
954958free ($1 );
955959}
956960| ECPGOpen {
@@ -968,36 +972,36 @@ stmt: AddAttrStmt{ output_statement($1, 0); }
968972yyerror (errortext);
969973}
970974
971- fprintf (yyout," ECPGdo(__LINE__, %s,\" %s\" ," , ptr->connection ? ptr->connection :" NULL" , ptr->command);
975+ fprintf (yyout," { ECPGdo(__LINE__, %s,\" %s\" ," , ptr->connection ? ptr->connection :" NULL" , ptr->command);
972976/* dump variables to C file*/
973977dump_variables (ptr->argsinsert,0 );
974978dump_variables (argsinsert,0 );
975979fputs (" ECPGt_EOIT," , yyout);
976980dump_variables (ptr->argsresult,0 );
977981fputs (" ECPGt_EORT);" , yyout);
978- whenever_action (0 );
982+ whenever_action (2 );
979983free ($1 );
980984}
981985| ECPGPrepare {
982986if (connection)
983987yyerror (" no at option for set connection statement.\n " );
984988
985- fprintf (yyout," ECPGprepare(__LINE__, %s);" , $1 );
986- whenever_action (0 );
989+ fprintf (yyout," { ECPGprepare(__LINE__, %s);" , $1 );
990+ whenever_action (2 );
987991free ($1 );
988992}
989993| ECPGRelease {/* output already done*/ }
990994| ECPGSetAutocommit {
991- fprintf (yyout," ECPGsetcommit(__LINE__,\" %s\" , %s);" , $1 , connection ? connection :" NULL" );
992- whenever_action (0 );
995+ fprintf (yyout," { ECPGsetcommit(__LINE__,\" %s\" , %s);" , $1 , connection ? connection :" NULL" );
996+ whenever_action (2 );
993997free ($1 );
994998}
995999| ECPGSetConnection {
9961000if (connection)
9971001yyerror (" no at option for set connection statement.\n " );
9981002
999- fprintf (yyout," ECPGsetconn(__LINE__, %s);" , $1 );
1000- whenever_action (0 );
1003+ fprintf (yyout," { ECPGsetconn(__LINE__, %s);" , $1 );
1004+ whenever_action (2 );
10011005free ($1 );
10021006}
10031007| ECPGTypedef {