LCOV - differential code coverage report
Current view: top level - src/interfaces/ecpg/test/sql - execute.pgc (source / functions) Coverage Total Hit CBC
Current: Differential Code Coverage HEAD vs 15 Lines: 100.0 % 66 66 66
Current Date: 2023-04-08 17:13:01 Functions: 100.0 % 1 1 1
Baseline: 15 Line coverage date bins:
Baseline Date: 2023-04-08 15:09:40 (240..) days: 100.0 % 66 66 66
Legend: Lines: hit not hit Function coverage date bins:
(240..) days: 100.0 % 1 1 1

 Age         Owner                  TLA  Line data    Source code
                                  1                 : #include <stdlib.h>
                                  2                 : #include <string.h>
                                  3                 : #include <stdlib.h>
                                  4                 : #include <stdio.h>
                                  5                 : 
                                  6                 : exec sql include ../regression;
                                  7                 : 
                                  8                 : exec sql whenever sqlerror sqlprint;
                                  9                 : 
                                 10                 : int
 6057 meskes                     11 CBC           1 : main(void)
                                 12                 : {
                                 13                 : exec sql begin declare section;
                                 14                 :     int amount[8];
                                 15               1 :     int increment=100;
                                 16                 :     char name[8][8];
                                 17                 :     char letter[8][1];
                                 18                 :     char command[128];
                                 19                 : exec sql end declare section;
                                 20                 :     int i,j;
                                 21                 : 
                                 22               1 :     ECPGdebug(1, stderr);
                                 23                 : 
                                 24               1 :     exec sql connect to REGRESSDB1 as main;
                                 25               1 :     exec sql create table test (name char(8), amount int, letter char(1));
                                 26               1 :     exec sql commit;
                                 27               1 : 
                                 28                 :     /* test handling of embedded quotes in EXECUTE IMMEDIATE "literal" */
  899 tgl                        29               1 :     exec sql execute immediate "insert into test (name, \042amount\042, letter) values ('db: ''r1''', 1, 'f')";
 6057 meskes                     30               1 : 
                                 31               1 :     sprintf(command, "insert into test (name, amount, letter) values ('db: ''r1''', 2, 't')");
                                 32               1 :     exec sql execute immediate :command;
                                 33               1 : 
                                 34               1 :     sprintf(command, "insert into test (name, amount, letter) select name, amount+10, letter from test");
                                 35               1 :     exec sql execute immediate :command;
                                 36               1 : 
                                 37               1 :     printf("Inserted %ld tuples via execute immediate\n", sqlca.sqlerrd[2]);
                                 38                 : 
 5717                            39               1 :     sprintf(command, "insert into test (name, amount, letter) select name, amount+$1, letter from test");
 6057                            40               1 :     exec sql prepare I from :command;
                                 41               1 :     exec sql execute I using :increment;
                                 42               1 : 
                                 43               1 :     printf("Inserted %ld tuples via prepared execute\n", sqlca.sqlerrd[2]);
                                 44                 : 
                                 45               1 :     exec sql commit;
                                 46               1 : 
                                 47               1 :     sprintf (command, "select * from test");
                                 48                 : 
 5717                            49               1 :     exec sql prepare f from :command;
                                 50               1 :     exec sql declare CUR cursor for f;
                                 51                 : 
 6057                            52               1 :     exec sql open CUR;
                                 53               1 :     exec sql fetch 8 in CUR into :name, :amount, :letter;
                                 54               1 : 
                                 55               9 :     for (i=0, j=sqlca.sqlerrd[2]; i<j; i++)
                                 56                 :     {
                                 57                 :         exec sql begin declare section;
                                 58               8 :         char n[8], l = letter[i][0];
                                 59               8 :         int a = amount[i];
                                 60                 :         exec sql end declare section;
                                 61                 : 
                                 62               8 :         strncpy(n, name[i], 8);
                                 63               8 :         printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l);
                                 64                 :     }
                                 65                 : 
                                 66               1 :     exec sql close CUR;
 5717                            67               1 :     exec sql deallocate f;
 6057                            68               1 : 
 5717                            69               1 :     sprintf (command, "select * from test where amount = $1");
                                 70                 : 
                                 71               1 :     exec sql prepare f from :command;
                                 72               1 :     exec sql declare CUR2 cursor for f;
                                 73                 : 
 6057                            74               1 :     exec sql open CUR2 using 1;
                                 75               1 :     exec sql fetch in CUR2 into :name, :amount, :letter;
                                 76               1 : 
                                 77               2 :     for (i=0, j=sqlca.sqlerrd[2]; i<j; i++)
                                 78                 :     {
                                 79                 :         exec sql begin declare section;
                                 80               1 :         char n[8], l = letter[i][0];
                                 81               1 :         int a = amount[i];
                                 82                 :         exec sql end declare section;
                                 83                 : 
                                 84               1 :         strncpy(n, name[i], 8);
                                 85               1 :         printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l);
                                 86                 :     }
                                 87                 : 
                                 88               1 :     exec sql close CUR2;
 5533                            89               1 :     exec sql deallocate f;
                                 90               1 : 
                                 91               1 :     sprintf (command, "select * from test where amount = $1");
                                 92                 : 
                                 93               1 :     exec sql prepare f from :command;
                                 94               1 :     exec sql execute f using 2 into :name, :amount, :letter;
                                 95               1 : 
                                 96               2 :     for (i=0, j=sqlca.sqlerrd[2]; i<j; i++)
                                 97                 :     {
                                 98                 :         exec sql begin declare section;
                                 99               1 :         char n[8], l = letter[i][0];
                                100               1 :         int a = amount[i];
                                101                 :         exec sql end declare section;
                                102                 : 
                                103               1 :         strncpy(n, name[i], 8);
                                104               1 :         printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l);
                                105                 :     }
                                106                 : 
                                107               1 :     exec sql deallocate f;
 6057                           108               1 :     exec sql drop table test;
                                109               1 :     exec sql commit;
                                110               1 :     exec sql disconnect;
                                111               1 : 
 2061 peter_e                   112               1 :     return 0;
                                113                 : }
        

Generated by: LCOV version v1.16-55-g56c0a2a