~ubuntu-branches/ubuntu/oneiric/postgresql-9.1/oneiric-security

« back to all changes in this revision

Viewing changes to src/interfaces/ecpg/test/sql/insupd.pgc

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2011-05-11 10:41:53 UTC
  • Revision ID: james.westby@ubuntu.com-20110511104153-psbh2o58553fv1m0
Tags: upstream-9.1~beta1
ImportĀ upstreamĀ versionĀ 9.1~beta1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <stdio.h>
 
2
#include <stdlib.h>
 
3
#include <string.h>
 
4
 
 
5
EXEC SQL INCLUDE ../regression;
 
6
 
 
7
int main() {
 
8
  EXEC SQL BEGIN DECLARE SECTION;
 
9
        int i1[3], i2[3], i3[3], i4;
 
10
  EXEC SQL END DECLARE SECTION;
 
11
 
 
12
  ECPGdebug(1, stderr);
 
13
  EXEC SQL CONNECT TO REGRESSDB1;
 
14
 
 
15
  EXEC SQL WHENEVER SQLWARNING SQLPRINT;
 
16
  EXEC SQL WHENEVER SQLERROR SQLPRINT;
 
17
 
 
18
  EXEC SQL CREATE TABLE insupd_test(a int, b int);
 
19
 
 
20
  EXEC SQL INSERT INTO insupd_test (a,b) values (1, 1);
 
21
  EXEC SQL INSERT INTO insupd_test (a,b) values (2, 2);
 
22
  EXEC SQL INSERT INTO insupd_test (a,b) values (3, 3) returning a into :i4;
 
23
 
 
24
  EXEC SQL UPDATE insupd_test set a=a+1 returning a into :i3;
 
25
  EXEC SQL UPDATE insupd_test set (a,b)=(5,5) where a = 4;
 
26
  EXEC SQL UPDATE insupd_test set a=4 where a=3;;
 
27
 
 
28
  EXEC SQL SELECT a,b into :i1,:i2 from insupd_test order by a;
 
29
 
 
30
  printf("changes\n%d %d %d %d\n", i3[0], i3[1], i3[2], i4);
 
31
  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]);
 
32
 
 
33
  EXEC SQL DISCONNECT ALL;
 
34
 
 
35
  return 0;
 
36
}