From 46651ce6fe013220ed397add242004d764fc0153 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 4 May 2024 14:15:05 +0200 Subject: Adding upstream version 14.5. Signed-off-by: Daniel Baumann --- src/interfaces/ecpg/test/sql/oldexec.pgc | 90 ++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 src/interfaces/ecpg/test/sql/oldexec.pgc (limited to 'src/interfaces/ecpg/test/sql/oldexec.pgc') diff --git a/src/interfaces/ecpg/test/sql/oldexec.pgc b/src/interfaces/ecpg/test/sql/oldexec.pgc new file mode 100644 index 0000000..4f94a18 --- /dev/null +++ b/src/interfaces/ecpg/test/sql/oldexec.pgc @@ -0,0 +1,90 @@ +#include +#include +#include +#include + +exec sql include ../regression; + +exec sql whenever sqlerror sqlprint; + +int +main(void) +{ +exec sql begin declare section; + int amount[8]; + int increment=100; + char name[8][8]; + char letter[8][1]; + char command[128]; +exec sql end declare section; + int i,j; + + ECPGdebug(1, stderr); + + exec sql connect to REGRESSDB1 as main; + + exec sql create table test (name char(8), amount int, letter char(1)); + exec sql commit; + + sprintf(command, "insert into test (name, amount, letter) values ('db: ''r1''', 1, 'f')"); + exec sql execute immediate :command; + + sprintf(command, "insert into test (name, amount, letter) values ('db: ''r1''', 2, 't')"); + exec sql execute immediate :command; + + sprintf(command, "insert into test (name, amount, letter) select name, amount+10, letter from test"); + exec sql execute immediate :command; + + printf("Inserted %ld tuples via execute immediate\n", sqlca.sqlerrd[2]); + + sprintf(command, "insert into test (name, amount, letter) select name, amount+$1, letter from test"); + exec sql prepare I from :command; + exec sql execute I using :increment; + + printf("Inserted %ld tuples via prepared execute\n", sqlca.sqlerrd[2]); + + exec sql commit; + + sprintf (command, "select * from test"); + + exec sql prepare F from :command; + exec sql declare CUR cursor for F; + + exec sql open CUR; + exec sql fetch 8 in CUR into :name, :amount, :letter; + + for (i=0, j=sqlca.sqlerrd[2]; i