Age Owner TLA Line data Source code
1 : /*
2 : * this file tests multiple connections to databases and switches
3 : * between them.
4 : */
5 :
6 : #include <stdlib.h>
7 : #include <string.h>
8 : #include <stdlib.h>
9 : #include <stdio.h>
10 :
11 : exec sql include ../regression;
12 :
13 : int
6976 meskes@postgresql.or 14 CBC 1 : main(void)
15 : {
16 : exec sql begin declare section;
17 : char id[200];
18 : char res[200];
19 : exec sql end declare section;
20 :
21 1 : ECPGdebug(1, stderr);
22 :
23 1 : strcpy(id, "first");
3339 tgl@sss.pgh.pa.us 24 1 : exec sql connect to ecpg2_regression as :id;
6974 meskes@postgresql.or 25 1 : exec sql connect to REGRESSDB1 as second;
26 :
27 : /* this selects from "second" which was opened last */
6976 28 1 : exec sql select current_database() into :res;
29 1 : exec sql at first select current_database() into :res;
30 1 : exec sql at second select current_database() into :res;
31 :
32 1 : exec sql set connection first;
33 1 : exec sql select current_database() into :res;
34 :
35 : /* this will disconnect from "first" */
36 1 : exec sql disconnect;
37 1 : exec sql select current_database() into :res;
38 :
39 : /* error here since "first" is already disconnected */
40 1 : exec sql disconnect :id;
41 :
42 : /* disconnect from "second" */
43 1 : exec sql disconnect;
44 :
2943 peter_e@gmx.net 45 1 : return 0;
46 : }
|