Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Postgres/src/interfaces/ecpg/test/connect/   (Postgres Database Version 18.4©)  Datei vom 11.4.2026 mit Größe 1010 B image not shown  

Quelle  test2.pgc   Sprache: unbekannt

 
Spracherkennung für: .pgc vermutete Sprache: Unknown {[0] [0] [0]} [Methode: Schwerpunktbildung, einfache Gewichte, sechs Dimensionen]

/*
 * 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;
}

[Dauer der Verarbeitung: 0.18 Sekunden, vorverarbeitet 2026-08-08]