summaryrefslogtreecommitdiffstats
path: root/src/interfaces/ecpg/test/sql/indicators.pgc
diff options
context:
space:
mode:
Diffstat (limited to 'src/interfaces/ecpg/test/sql/indicators.pgc')
-rw-r--r--src/interfaces/ecpg/test/sql/indicators.pgc50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/interfaces/ecpg/test/sql/indicators.pgc b/src/interfaces/ecpg/test/sql/indicators.pgc
new file mode 100644
index 0000000..c1f26e3
--- /dev/null
+++ b/src/interfaces/ecpg/test/sql/indicators.pgc
@@ -0,0 +1,50 @@
+#include <stdio.h>
+
+exec sql include sqlca;
+exec sql include ../regression;
+
+int main()
+{
+ exec sql begin declare section;
+ int intvar = 5;
+ int nullind = -1;
+ exec sql end declare section;
+
+ ECPGdebug(1,stderr);
+
+ exec sql connect to REGRESSDB1;
+ exec sql set autocommit to off;
+
+ exec sql create table indicator_test (
+ "id" int primary key,
+ "str" text NOT NULL,
+ val int null);
+ exec sql commit work;
+
+ exec sql insert into indicator_test (id, str, val) values ( 1, 'Hello', 0);
+
+ /* use indicator in insert */
+ exec sql insert into indicator_test (id, str, val) values ( 2, 'Hi there', :intvar :nullind);
+ nullind = 0;
+ exec sql insert into indicator_test (id, str, val) values ( 3, 'Good evening', :intvar :nullind);
+ exec sql commit work;
+
+ /* use indicators to get information about selects */
+ exec sql select val into :intvar from indicator_test where id = 1;
+ exec sql select val into :intvar :nullind from indicator_test where id = 2;
+ printf("intvar: %d, nullind: %d\n", intvar, nullind);
+ exec sql select val into :intvar :nullind from indicator_test where id = 3;
+ printf("intvar: %d, nullind: %d\n", intvar, nullind);
+
+ /* use indicators for update */
+ intvar = 5; nullind = -1;
+ exec sql update indicator_test set val = :intvar :nullind where id = 1;
+ exec sql select val into :intvar :nullind from indicator_test where id = 1;
+ printf("intvar: %d, nullind: %d\n", intvar, nullind);
+
+ exec sql drop table indicator_test;
+ exec sql commit work;
+
+ exec sql disconnect;
+ return 0;
+}