@@ -45,7 +45,7 @@ output_line_number()
45
45
/*
46
46
* store the whenever action here
47
47
*/
48
- static struct when when_error, when_nf;
48
+ static struct when when_error, when_nf, when_warn ;
49
49
50
50
static void
51
51
print_action (struct when *w)
@@ -76,6 +76,12 @@ whenever_action(int mode)
76
76
fprintf (yyout, " \n if (sqlca.sqlcode == ECPG_NOT_FOUND) " );
77
77
print_action (&when_nf);
78
78
}
79
+ if (when_warn.code != W_NOTHING)
80
+ {
81
+ output_line_number ();
82
+ fprintf (yyout, " \n if (sqlca.sqlwarn[0] == 'W') " );
83
+ print_action (&when_warn);
84
+ }
79
85
if (when_error.code != W_NOTHING)
80
86
{
81
87
output_line_number ();
@@ -517,7 +523,7 @@ output_statement(char * stmt, int mode)
517
523
%token SQL_DISCONNECT SQL_FOUND SQL_GO SQL_GOTO
518
524
%token SQL_IDENTIFIED SQL_IMMEDIATE SQL_INDICATOR SQL_OPEN SQL_RELEASE
519
525
%token SQL_SECTION SQL_SEMI SQL_SQLERROR SQL_SQLPRINT SQL_START
520
- %token SQL_STOP SQL_WHENEVER
526
+ %token SQL_STOP SQL_WHENEVER SQL_SQLWARNING
521
527
522
528
/* C token */
523
529
%token S_ANYTHING S_AUTO S_BOOL S_CHAR S_CONST S_DOUBLE S_ENUM S_EXTERN
@@ -4630,9 +4636,7 @@ ECPGSetConnection: SET SQL_CONNECTION connection_object
4630
4636
}
4631
4637
/*
4632
4638
* whenever statement: decide what to do in case of error/no data found
4633
- * according to SQL standards we miss: SQLSTATE, CONSTRAINT, SQLEXCEPTION
4634
- * and SQLWARNING
4635
-
4639
+ * according to SQL standards we lack: SQLSTATE, CONSTRAINT and SQLEXCEPTION
4636
4640
*/
4637
4641
ECPGWhenever : SQL_WHENEVER SQL_SQLERROR action {
4638
4642
when_error.code = $<action>3 .code;
@@ -4644,6 +4648,11 @@ ECPGWhenever: SQL_WHENEVER SQL_SQLERROR action {
4644
4648
when_nf.command = $<action>4 .command;
4645
4649
$$ = cat3_str(make1_str(" /* exec sql whenever not found " ), $4 .str, make1_str(" ; */\n " ));
4646
4650
}
4651
+ | SQL_WHENEVER SQL_SQLWARNING action {
4652
+ when_warn.code = $<action>3 .code;
4653
+ when_warn.command = $<action>3 .command;
4654
+ $$ = cat3_str(make1_str(" /* exec sql whenever sql_warning " ), $3 .str, make1_str(" ; */\n " ));
4655
+ }
4647
4656
4648
4657
action : SQL_CONTINUE {
4649
4658
$<action>$.code = W_NOTHING;
0 commit comments