Age Owner Branch data TLA Line data Source code
1 : : #include <stdio.h>
2 : : exec sql include sqlca;
3 : : #include <stdlib.h>
4 : : exec sql include ../regression;
5 : :
6465 meskes@postgresql.or 6 :CBC 1 : int main(void)
7 : : {
8 : : exec sql begin declare section;
9 : 1 : int *ip1=0;
10 : 1 : char **cp2=0;
11 : 1 : int *ipointer1=0;
12 : 1 : int *ipointer2=0;
13 : : int colnum;
14 : : exec sql end declare section;
15 : : int i;
16 : :
17 : 1 : ECPGdebug(1, stderr);
18 : :
19 : : exec sql whenever sqlerror do sqlprint();
20 : 1 : exec sql connect to REGRESSDB1;
21 [ - + ]: 1 :
6448 22 : 1 : exec sql set datestyle to postgres;
23 [ - + ]: 1 :
6465 24 : 1 : exec sql create table test (a int, b text);
25 [ - + ]: 1 : exec sql insert into test values (1, 'one');
26 [ - + ]: 1 : exec sql insert into test values (2, 'two');
27 [ - + ]: 1 : exec sql insert into test values (NULL, 'three');
28 [ - + ]: 1 : exec sql insert into test values (4, 'four');
29 [ - + ]: 1 : exec sql insert into test values (5, NULL);
30 [ - + ]: 1 : exec sql insert into test values (NULL, NULL);
31 [ - + ]: 1 :
32 : 1 : exec sql allocate descriptor mydesc;
5213 33 [ - + ]: 1 : exec sql select * into sql descriptor mydesc from test;
6465 34 [ - + ]: 1 : exec sql get descriptor mydesc :colnum=COUNT;
35 [ - + ]: 1 : exec sql get descriptor mydesc value 1 :ip1=DATA, :ipointer1=INDICATOR;
36 [ - + ]: 1 : exec sql get descriptor mydesc value 2 :cp2=DATA, :ipointer2=INDICATOR;
37 [ - + ]: 1 :
38 : 1 : printf("Result (%d columns):\n", colnum);
39 [ + + ]: 7 : for (i=0;i < sqlca.sqlerrd[2];++i)
40 : : {
41 [ + + ]: 6 : if (ipointer1[i]) printf("NULL, ");
4891 peter_e@gmx.net 42 : 4 : else printf("%d, ",ip1[i]);
43 : :
6465 meskes@postgresql.or 44 [ + + ]: 6 : if (ipointer2[i]) printf("NULL, ");
4891 peter_e@gmx.net 45 : 4 : else printf("'%s', ",cp2[i]);
6465 meskes@postgresql.or 46 : 6 : printf("\n");
47 : : }
48 : 1 : ECPGfree_auto_mem();
49 : 1 : printf("\n");
50 : :
51 : 1 : exec sql deallocate descriptor mydesc;
52 [ - + ]: 1 : exec sql rollback;
53 [ - + ]: 1 : exec sql disconnect;
54 [ - + ]: 1 : return 0;
55 : : }
|