summaryrefslogtreecommitdiffstats
path: root/src/interfaces/ecpg/test/sql/insupd.pgc
diff options
context:
space:
mode:
Diffstat (limited to 'src/interfaces/ecpg/test/sql/insupd.pgc')
-rw-r--r--src/interfaces/ecpg/test/sql/insupd.pgc36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/interfaces/ecpg/test/sql/insupd.pgc b/src/interfaces/ecpg/test/sql/insupd.pgc
new file mode 100644
index 0000000..b12f66f
--- /dev/null
+++ b/src/interfaces/ecpg/test/sql/insupd.pgc
@@ -0,0 +1,36 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+EXEC SQL INCLUDE ../regression;
+
+int main() {
+ EXEC SQL BEGIN DECLARE SECTION;
+ int i1[3], i2[3], i3[3], i4;
+ EXEC SQL END DECLARE SECTION;
+
+ ECPGdebug(1, stderr);
+ EXEC SQL CONNECT TO REGRESSDB1;
+
+ EXEC SQL WHENEVER SQLWARNING SQLPRINT;
+ EXEC SQL WHENEVER SQLERROR SQLPRINT;
+
+ EXEC SQL CREATE TABLE insupd_test(a int, b int);
+
+ EXEC SQL INSERT INTO insupd_test (a,b) values (1, 1);
+ EXEC SQL INSERT INTO insupd_test (a,b) values (2, 2);
+ EXEC SQL INSERT INTO insupd_test (a,b) values (3, 3) returning a into :i4;
+
+ EXEC SQL UPDATE insupd_test set a=a+1 returning a into :i3;
+ EXEC SQL UPDATE insupd_test set (a,b)=(5,5) where a = 4;
+ EXEC SQL UPDATE insupd_test set a=4 where a=3;;
+
+ EXEC SQL SELECT a,b into :i1,:i2 from insupd_test order by a;
+
+ printf("changes\n%d %d %d %d\n", i3[0], i3[1], i3[2], i4);
+ printf("test\na b\n%d %d\n%d %d\n%d %d\n", i1[0], i2[0], i1[1], i2[1], i1[2], i2[2]);
+
+ EXEC SQL DISCONNECT ALL;
+
+ return 0;
+}