Header And Logo

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

sql-copystdout.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 "copystdout.pgc"
00010 #include <stdio.h>
00011 
00012 
00013 #line 1 "sqlca.h"
00014 #ifndef POSTGRES_SQLCA_H
00015 #define POSTGRES_SQLCA_H
00016 
00017 #ifndef PGDLLIMPORT
00018 #if  defined(WIN32) || defined(__CYGWIN__)
00019 #define PGDLLIMPORT __declspec (dllimport)
00020 #else
00021 #define PGDLLIMPORT
00022 #endif   /* __CYGWIN__ */
00023 #endif   /* PGDLLIMPORT */
00024 
00025 #define SQLERRMC_LEN    150
00026 
00027 #ifdef __cplusplus
00028 extern      "C"
00029 {
00030 #endif
00031 
00032 struct sqlca_t
00033 {
00034     char        sqlcaid[8];
00035     long        sqlabc;
00036     long        sqlcode;
00037     struct
00038     {
00039         int         sqlerrml;
00040         char        sqlerrmc[SQLERRMC_LEN];
00041     }           sqlerrm;
00042     char        sqlerrp[8];
00043     long        sqlerrd[6];
00044     /* Element 0: empty                     */
00045     /* 1: OID of processed tuple if applicable          */
00046     /* 2: number of rows processed              */
00047     /* after an INSERT, UPDATE or               */
00048     /* DELETE statement                 */
00049     /* 3: empty                     */
00050     /* 4: empty                     */
00051     /* 5: empty                     */
00052     char        sqlwarn[8];
00053     /* Element 0: set to 'W' if at least one other is 'W'   */
00054     /* 1: if 'W' at least one character string      */
00055     /* value was truncated when it was          */
00056     /* stored into a host variable.             */
00057 
00058     /*
00059      * 2: if 'W' a (hopefully) non-fatal notice occurred
00060      */ /* 3: empty */
00061     /* 4: empty                     */
00062     /* 5: empty                     */
00063     /* 6: empty                     */
00064     /* 7: empty                     */
00065 
00066     char        sqlstate[5];
00067 };
00068 
00069 struct sqlca_t *ECPGget_sqlca(void);
00070 
00071 #ifndef POSTGRES_ECPG_INTERNAL
00072 #define sqlca (*ECPGget_sqlca())
00073 #endif
00074 
00075 #ifdef __cplusplus
00076 }
00077 #endif
00078 
00079 #endif
00080 
00081 #line 3 "copystdout.pgc"
00082 
00083 
00084 #line 1 "regression.h"
00085 
00086 
00087 
00088 
00089 
00090 
00091 #line 4 "copystdout.pgc"
00092 
00093 
00094 /* exec sql whenever sqlerror  sqlprint ; */
00095 #line 6 "copystdout.pgc"
00096 
00097 
00098 int
00099 main ()
00100 {
00101   ECPGdebug (1, stderr);
00102 
00103   { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); 
00104 #line 13 "copystdout.pgc"
00105 
00106 if (sqlca.sqlcode < 0) sqlprint();}
00107 #line 13 "copystdout.pgc"
00108 
00109   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table foo ( a int , b varchar )", ECPGt_EOIT, ECPGt_EORT);
00110 #line 14 "copystdout.pgc"
00111 
00112 if (sqlca.sqlcode < 0) sqlprint();}
00113 #line 14 "copystdout.pgc"
00114 
00115   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into foo values ( 5 , 'abc' )", ECPGt_EOIT, ECPGt_EORT);
00116 #line 15 "copystdout.pgc"
00117 
00118 if (sqlca.sqlcode < 0) sqlprint();}
00119 #line 15 "copystdout.pgc"
00120 
00121   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into foo values ( 6 , 'def' )", ECPGt_EOIT, ECPGt_EORT);
00122 #line 16 "copystdout.pgc"
00123 
00124 if (sqlca.sqlcode < 0) sqlprint();}
00125 #line 16 "copystdout.pgc"
00126 
00127   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into foo values ( 7 , 'ghi' )", ECPGt_EOIT, ECPGt_EORT);
00128 #line 17 "copystdout.pgc"
00129 
00130 if (sqlca.sqlcode < 0) sqlprint();}
00131 #line 17 "copystdout.pgc"
00132 
00133 
00134   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "copy foo to stdout with delimiter ','", ECPGt_EOIT, ECPGt_EORT);
00135 #line 19 "copystdout.pgc"
00136 
00137 if (sqlca.sqlcode < 0) sqlprint();}
00138 #line 19 "copystdout.pgc"
00139 
00140   printf ("copy to STDOUT : sqlca.sqlcode = %ld\n", sqlca.sqlcode);
00141 
00142   { ECPGdisconnect(__LINE__, "CURRENT");
00143 #line 22 "copystdout.pgc"
00144 
00145 if (sqlca.sqlcode < 0) sqlprint();}
00146 #line 22 "copystdout.pgc"
00147 
00148 
00149   return 0;
00150 }