Header And Logo

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

Data Structures | Defines | Functions

sql-copystdout.c File Reference

#include <ecpglib.h>
#include <ecpgerrno.h>
#include <sqlca.h>
#include <stdio.h>
Include dependency graph for sql-copystdout.c:

Go to the source code of this file.

Data Structures

struct  sqlca_t

Defines

#define ECPGdebug(X, Y)   ECPGdebug((X)+100,(Y))
#define PGDLLIMPORT
#define SQLERRMC_LEN   150
#define sqlca   (*ECPGget_sqlca())

Functions

struct sqlca_tECPGget_sqlca (void)
int main ()

Define Documentation

#define ECPGdebug (   X,
  Y 
)    ECPGdebug((X)+100,(Y))

Definition at line 7 of file sql-copystdout.c.

#define PGDLLIMPORT

Definition at line 21 of file sql-copystdout.c.

#define sqlca   (*ECPGget_sqlca())

Definition at line 72 of file sql-copystdout.c.

Referenced by main().

#define SQLERRMC_LEN   150

Definition at line 25 of file sql-copystdout.c.


Function Documentation

struct sqlca_t* ECPGget_sqlca ( void   )  [read]

Definition at line 135 of file misc.c.

{
#ifdef ENABLE_THREAD_SAFETY
    struct sqlca_t *sqlca;

    pthread_once(&sqlca_key_once, ecpg_sqlca_key_init);

    sqlca = pthread_getspecific(sqlca_key);
    if (sqlca == NULL)
    {
        sqlca = malloc(sizeof(struct sqlca_t));
        ecpg_init_sqlca(sqlca);
        pthread_setspecific(sqlca_key, sqlca);
    }
    return (sqlca);
#else
    return (&sqlca);
#endif
}

int main ( void   ) 

Definition at line 99 of file sql-copystdout.c.

References ECPGconnect(), ECPGdebug, ECPGdisconnect(), ECPGdo(), ECPGst_normal, ECPGt_EOIT, ECPGt_EORT, NULL, sqlca, and sqlprint().

{
  ECPGdebug (1, stderr);

  { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); 
#line 13 "copystdout.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 13 "copystdout.pgc"

  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table foo ( a int , b varchar )", ECPGt_EOIT, ECPGt_EORT);
#line 14 "copystdout.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 14 "copystdout.pgc"

  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into foo values ( 5 , 'abc' )", ECPGt_EOIT, ECPGt_EORT);
#line 15 "copystdout.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 15 "copystdout.pgc"

  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into foo values ( 6 , 'def' )", ECPGt_EOIT, ECPGt_EORT);
#line 16 "copystdout.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 16 "copystdout.pgc"

  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into foo values ( 7 , 'ghi' )", ECPGt_EOIT, ECPGt_EORT);
#line 17 "copystdout.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 17 "copystdout.pgc"


  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "copy foo to stdout with delimiter ','", ECPGt_EOIT, ECPGt_EORT);
#line 19 "copystdout.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 19 "copystdout.pgc"

  printf ("copy to STDOUT : sqlca.sqlcode = %ld\n", sqlca.sqlcode);

  { ECPGdisconnect(__LINE__, "CURRENT");
#line 22 "copystdout.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 22 "copystdout.pgc"


  return 0;
}