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