Header And Logo

PostgreSQL
| The world's most advanced open source database.

connect-test2.c

Go to the documentation of this file.
00001 /* Processed by ecpg (regression mode) */
00002 /* These include files are added by the preprocessor */
00003 #include <ecpglib.h>
00004 #include <ecpgerrno.h>
00005 #include <sqlca.h>
00006 /* End of automatic include section */
00007 #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
00008 
00009 #line 1 "test2.pgc"
00010 /*
00011  * this file tests multiple connections to databases and switches
00012  * between them.
00013  */
00014 
00015 #include <stdlib.h>
00016 #include <string.h>
00017 #include <stdlib.h>
00018 #include <stdio.h>
00019 
00020 
00021 #line 1 "regression.h"
00022 
00023 
00024 
00025 
00026 
00027 
00028 #line 11 "test2.pgc"
00029 
00030 
00031 int
00032 main(void)
00033 {
00034 /* exec sql begin declare section */
00035      
00036      
00037 
00038 #line 17 "test2.pgc"
00039  char id [ 200 ] ;
00040  
00041 #line 18 "test2.pgc"
00042  char res [ 200 ] ;
00043 /* exec sql end declare section */
00044 #line 19 "test2.pgc"
00045 
00046 
00047     ECPGdebug(1, stderr);
00048 
00049     strcpy(id, "first");
00050     { ECPGconnect(__LINE__, 0, "connectdb" , NULL, NULL , id, 0); }
00051 #line 24 "test2.pgc"
00052 
00053     { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , "second", 0); }
00054 #line 25 "test2.pgc"
00055 
00056 
00057     /* this selects from "second" which was opened last */
00058     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select current_database ( )", ECPGt_EOIT, 
00059     ECPGt_char,(res),(long)200,(long)1,(200)*sizeof(char), 
00060     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
00061 #line 28 "test2.pgc"
00062 
00063     { ECPGdo(__LINE__, 0, 1, "first", 0, ECPGst_normal, "select current_database ( )", ECPGt_EOIT, 
00064     ECPGt_char,(res),(long)200,(long)1,(200)*sizeof(char), 
00065     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
00066 #line 29 "test2.pgc"
00067 
00068     { ECPGdo(__LINE__, 0, 1, "second", 0, ECPGst_normal, "select current_database ( )", ECPGt_EOIT, 
00069     ECPGt_char,(res),(long)200,(long)1,(200)*sizeof(char), 
00070     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
00071 #line 30 "test2.pgc"
00072 
00073 
00074     { ECPGsetconn(__LINE__, "first");}
00075 #line 32 "test2.pgc"
00076 
00077     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select current_database ( )", ECPGt_EOIT, 
00078     ECPGt_char,(res),(long)200,(long)1,(200)*sizeof(char), 
00079     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
00080 #line 33 "test2.pgc"
00081 
00082 
00083     /* this will disconnect from "first" */
00084     { ECPGdisconnect(__LINE__, "CURRENT");}
00085 #line 36 "test2.pgc"
00086 
00087     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select current_database ( )", ECPGt_EOIT, 
00088     ECPGt_char,(res),(long)200,(long)1,(200)*sizeof(char), 
00089     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
00090 #line 37 "test2.pgc"
00091 
00092 
00093     /* error here since "first" is already disconnected */
00094     { ECPGdisconnect(__LINE__, id);}
00095 #line 40 "test2.pgc"
00096 
00097 
00098     /* disconnect from "second" */
00099     { ECPGdisconnect(__LINE__, "CURRENT");}
00100 #line 43 "test2.pgc"
00101 
00102 
00103     return (0);
00104 }