Header And Logo

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

connect-test3.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 "test3.pgc"
00010 /*
00011  * this file just tests the several possibilities you have for a disconnect
00012  */
00013 
00014 #include <stdlib.h>
00015 #include <string.h>
00016 #include <stdlib.h>
00017 #include <stdio.h>
00018 
00019 
00020 #line 1 "regression.h"
00021 
00022 
00023 
00024 
00025 
00026 
00027 #line 10 "test3.pgc"
00028 
00029 
00030 int
00031 main(void)
00032 {
00033 /* exec sql begin declare section */
00034      
00035      
00036 
00037 #line 16 "test3.pgc"
00038  char id [ 200 ] ;
00039  
00040 #line 17 "test3.pgc"
00041  char res [ 200 ] ;
00042 /* exec sql end declare section */
00043 #line 18 "test3.pgc"
00044 
00045 
00046     ECPGdebug(1, stderr);
00047 
00048     strcpy(id, "first");
00049     { ECPGconnect(__LINE__, 0, "connectdb" , NULL, NULL , id, 0); }
00050 #line 23 "test3.pgc"
00051 
00052     { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , "second", 0); }
00053 #line 24 "test3.pgc"
00054 
00055 
00056     /* this selects from "second" which was opened last */
00057     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select current_database ( )", ECPGt_EOIT, 
00058     ECPGt_char,(res),(long)200,(long)1,(200)*sizeof(char), 
00059     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
00060 #line 27 "test3.pgc"
00061 
00062 
00063     /* will close "second" */
00064     { ECPGdisconnect(__LINE__, "CURRENT");}
00065 #line 30 "test3.pgc"
00066 
00067     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select current_database ( )", ECPGt_EOIT, 
00068     ECPGt_char,(res),(long)200,(long)1,(200)*sizeof(char), 
00069     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
00070 #line 31 "test3.pgc"
00071 
00072 
00073     { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , "second", 0); }
00074 #line 33 "test3.pgc"
00075 
00076     /* will close "second" */
00077     { ECPGdisconnect(__LINE__, "DEFAULT");}
00078 #line 35 "test3.pgc"
00079 
00080 
00081     { ECPGconnect(__LINE__, 0, "connectdb" , NULL, NULL , "second", 0); }
00082 #line 37 "test3.pgc"
00083 
00084     { ECPGdisconnect(__LINE__, "ALL");}
00085 #line 38 "test3.pgc"
00086 
00087 
00088     { ECPGdisconnect(__LINE__, "CURRENT");}
00089 #line 40 "test3.pgc"
00090 
00091     { ECPGdisconnect(__LINE__, "DEFAULT");}
00092 #line 41 "test3.pgc"
00093 
00094     { ECPGdisconnect(__LINE__, "ALL");}
00095 #line 42 "test3.pgc"
00096 
00097 
00098     /*
00099      * exec sql disconnect;
00100      * exec sql disconnect name;
00101      *
00102      *     are used in other tests
00103      */
00104 
00105     return (0);
00106 }