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/define.pgc | 58 +++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 src/interfaces/ecpg/test/sql/define.pgc (limited to 'src/interfaces/ecpg/test/sql/define.pgc') 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; +} -- cgit v1.2.3