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/define.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/define.pgc')
-rw-r--r-- | src/interfaces/ecpg/test/sql/define.pgc | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/src/interfaces/ecpg/test/sql/define.pgc b/src/interfaces/ecpg/test/sql/define.pgc new file mode 100644 index 0000000..ed58a4b --- /dev/null +++ b/src/interfaces/ecpg/test/sql/define.pgc @@ -0,0 +1,58 @@ +exec sql include sqlca; +exec sql include ../regression; +exec sql define STR 'abcdef'; +exec sql define INSERTNULL 1; +exec sql define NUMBER 29; + +int main(void) +{ + exec sql begin declare section; + int i; + char s[200]; + exec sql end declare section; + + ECPGdebug(1, stderr); + + exec sql whenever sqlerror do sqlprint(); + exec sql connect to REGRESSDB1; + + exec sql create table test (a int, b text); + exec sql insert into test values (NUMBER, STR); + + exec sql ifdef INSERTNULL; + exec sql insert into test values (NULL, 'defined'); + exec sql endif; + + exec sql ifndef INSERTNULL; + exec sql insert into test values (NULL, 'not defined'); + exec sql elif SOMEOTHERVAR; + exec sql insert into test values (NULL, 'someothervar defined'); + exec sql else; + exec sql insert into test values (NULL, 'someothervar not defined'); + exec sql endif; + + exec sql define NUMBER 29; + + exec sql select INSERTNULL, NUMBER::text || '-' || STR INTO :i, :s; + + printf("i: %d, s: %s\n", i, s); + + exec sql undef STR; + exec sql ifndef STR; + exec sql insert into test values (NUMBER, 'no string'); + exec sql endif; + + exec sql define TZVAR; /* no value */ + exec sql define TZVAR 'UTC'; + + exec sql ifndef TZVAR; + exec sql SET TIMEZONE TO 'GMT'; + exec sql elif TZNAME; + exec sql SET TIMEZONE TO TZNAME; + exec sql else; + exec sql SET TIMEZONE TO TZVAR; + exec sql endif; + + exec sql disconnect; + return 0; +} |