diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 12:15:05 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 12:15:05 +0000 |
commit | 46651ce6fe013220ed397add242004d764fc0153 (patch) | |
tree | 6e5299f990f88e60174a1d3ae6e48eedd2688b2b /src/interfaces/ecpg/test/sql/code100.pgc | |
parent | Initial commit. (diff) | |
download | postgresql-14-upstream.tar.xz postgresql-14-upstream.zip |
Adding upstream version 14.5.upstream/14.5upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/interfaces/ecpg/test/sql/code100.pgc')
-rw-r--r-- | src/interfaces/ecpg/test/sql/code100.pgc | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/interfaces/ecpg/test/sql/code100.pgc b/src/interfaces/ecpg/test/sql/code100.pgc new file mode 100644 index 0000000..d9a5e52 --- /dev/null +++ b/src/interfaces/ecpg/test/sql/code100.pgc @@ -0,0 +1,52 @@ +exec sql include sqlca; +#include <stdio.h> + +exec sql include ../regression; + + +int main() +{ exec sql begin declare section; + int index; + exec sql end declare section; + + + ECPGdebug(1,stderr); + + exec sql connect to REGRESSDB1; + if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); + + exec sql create table test ( + "index" numeric(3) primary key, + "payload" int4 NOT NULL); + if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); + exec sql commit work; + if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); + + for (index=0;index<10;++index) + { exec sql insert into test + (payload, index) + values (0, :index); + if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); + } + exec sql commit work; + if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); + + exec sql update test + set payload=payload+1 where index=-1; + if (sqlca.sqlcode!=100) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); + + exec sql delete from test where index=-1; + if (sqlca.sqlcode!=100) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); + + exec sql insert into test (select * from test where index=-1); + if (sqlca.sqlcode!=100) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); + + exec sql drop table test; + if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); + exec sql commit work; + if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); + + exec sql disconnect; + if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); + return 0; +} |