1/* Processed by ecpg (regression mode) */
2/* These include files are added by the preprocessor */
6/* End of automatic include section */
7 #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
13#include "ecpg_config.h"
30#ifdef _ECPG_INFORMIX_H
44#endif /* ECPG_SQLDA_H */
49#line 1 "pgtypes_numeric.h"
50#ifndef PGTYPES_NUMERIC
51 #define PGTYPES_NUMERIC
55 #define NUMERIC_POS 0x0000
56 #define NUMERIC_NEG 0x4000
57 #define NUMERIC_NAN 0xC000
58 #define NUMERIC_NULL 0xF000
59 #define NUMERIC_MAX_PRECISION 1000
60 #define NUMERIC_MAX_DISPLAY_SCALE NUMERIC_MAX_PRECISION
61 #define NUMERIC_MIN_DISPLAY_SCALE 0
62 #define NUMERIC_MIN_SIG_DIGITS 16
69 int ndigits;
/* number of digits in digits[] - can be 0! */
70 int weight;
/* weight of first digit */
71 int rscale;
/* result scale */
72 int dscale;
/* display scale */
73 int sign;
/* NUMERIC_POS, NUMERIC_NEG, or NUMERIC_NAN */
80 int ndigits;
/* number of digits in digits[] - can be 0! */
81 int weight;
/* weight of first digit */
82 int rscale;
/* result scale */
83 int dscale;
/* display scale */
84 int sign;
/* NUMERIC_POS, NUMERIC_NEG, or NUMERIC_NAN */
118#endif /* PGTYPES_NUMERIC */
123/* exec sql whenever sqlerror stop ; */
127/* These shouldn't be under DECLARE SECTION */
137 printf(
"dump_sqlda called with NULL sqlda\n");
141 for (
i = 0;
i < sqlda->
sqld;
i++)
158 printf(
"name sqlda descriptor: '%s' value %lld\n",
180/* exec sql begin declare section */
187 char * stmt1 =
"SELECT * FROM t1" ;
190 char * stmt2 =
"SELECT * FROM t1 WHERE id = ?" ;
197/* exec sql end declare section */
205 strcpy(msg,
"connect");
206 {
ECPGconnect(__LINE__, 0,
"ecpg1_regression" , NULL, NULL ,
"regress1", 0);
209if (
sqlca.sqlcode < 0) exit (1);}
217if (
sqlca.sqlcode < 0) exit (1);}
221 strcpy(msg,
"create");
222 {
ECPGdo(__LINE__, 0, 1, NULL, 0,
ECPGst_normal,
"create table t1 ( id integer , t text , d1 numeric , d2 float8 , c char ( 10 ) , big bigint )",
ECPGt_EOIT,
ECPGt_EORT);
225if (
sqlca.sqlcode < 0) exit (1);}
229 strcpy(msg,
"insert");
230 {
ECPGdo(__LINE__, 0, 1, NULL, 0,
ECPGst_normal,
"insert into t1 values ( 1 , 'a' , 1.0 , 1 , 'a' , 1111111111111111111 ) , ( 2 , null , null , null , null , null ) , ( 3 , 'c' , 0.0 , 3 , 'c' , 3333333333333333333 ) , ( 4 , 'd' , 'NaN' , 4 , 'd' , 4444444444444444444 ) , ( 5 , 'e' , 0.001234 , 5 , 'e' , 5555555555555555555 )",
ECPGt_EOIT,
ECPGt_EORT);
233if (
sqlca.sqlcode < 0) exit (1);}
237 strcpy(msg,
"commit");
241if (
sqlca.sqlcode < 0) exit (1);}
245 /* SQLDA test for getting all records from a table */
249 strcpy(msg,
"prepare");
253if (
sqlca.sqlcode < 0) exit (1);}
257 strcpy(msg,
"declare");
258 /* declare mycur1 cursor for 1ドル */
268if (
sqlca.sqlcode < 0) exit (1);}
272 /* exec sql whenever not found break ; */
279 strcpy(msg,
"fetch");
288if (
sqlca.sqlcode < 0) exit (1);}
292 printf(
"FETCH RECORD %d\n", ++rec);
296 /* exec sql whenever not found continue ; */
300 strcpy(msg,
"close");
304if (
sqlca.sqlcode < 0) exit (1);}
308 strcpy(msg,
"deallocate");
312if (
sqlca.sqlcode < 0) exit (1);}
318 /* SQLDA test for getting ALL records into the sqlda list */
322 strcpy(msg,
"prepare");
326if (
sqlca.sqlcode < 0) exit (1);}
330 strcpy(msg,
"declare");
331 /* declare mycur2 cursor for 1ドル */
341if (
sqlca.sqlcode < 0) exit (1);}
345 strcpy(msg,
"fetch");
351if (
sqlca.sqlcode < 0) exit (1);}
360 printf(
"FETCH RECORD %d\n", ++rec);
368 strcpy(msg,
"close");
372if (
sqlca.sqlcode < 0) exit (1);}
376 strcpy(msg,
"deallocate");
380if (
sqlca.sqlcode < 0) exit (1);}
384 /* SQLDA test for getting one record using an input descriptor */
387 * Input sqlda has to be built manually
388 * sqlda_t contains 1 sqlvar_t structure already.
397 printf(
"EXECUTE RECORD 4\n");
403 strcpy(msg,
"prepare");
407if (
sqlca.sqlcode < 0) exit (1);}
411 strcpy(msg,
"execute");
419if (
sqlca.sqlcode < 0) exit (1);}
425 strcpy(msg,
"deallocate");
429if (
sqlca.sqlcode < 0) exit (1);}
436 /* SQLDA test for getting one record using an input descriptor
437 * on a named connection
440 {
ECPGconnect(__LINE__, 0,
"ecpg1_regression" , NULL, NULL ,
"con2", 0);
443if (
sqlca.sqlcode < 0) exit (1);}
448 * Input sqlda has to be built manually
449 * sqlda_t contains 1 sqlvar_t structure already.
458 printf(
"EXECUTE RECORD 4\n");
464 strcpy(msg,
"prepare");
465 {
ECPGprepare(__LINE__,
"con2", 0,
"st_id4", stmt2);
468if (
sqlca.sqlcode < 0) exit (1);}
472 strcpy(msg,
"execute");
480if (
sqlca.sqlcode < 0) exit (1);}
486 strcpy(msg,
"commit");
490if (
sqlca.sqlcode < 0) exit (1);}
494 strcpy(msg,
"deallocate");
498if (
sqlca.sqlcode < 0) exit (1);}
505 strcpy(msg,
"disconnect");
509if (
sqlca.sqlcode < 0) exit (1);}
519if (
sqlca.sqlcode < 0) exit (1);}
523 strcpy(msg,
"commit");
527if (
sqlca.sqlcode < 0) exit (1);}
531 strcpy(msg,
"disconnect");
535if (
sqlca.sqlcode < 0) exit (1);}
Datum numeric(PG_FUNCTION_ARGS)
bool ECPGdisconnect(int lineno, const char *connection_name)
bool ECPGconnect(int lineno, int c, const char *name, const char *user, const char *passwd, const char *connection_name, int autocommit)
bool ECPGdo(const int lineno, const int compat, const int force_indicator, const char *connection_name, const bool questionmarks, const int st, const char *query,...)
bool ECPGtrans(int lineno, const char *connection_name, const char *transaction)
char * ECPGprepared_statement(const char *connection_name, const char *name, int lineno)
bool ECPGprepare(int lineno, const char *connection_name, const bool questionmarks, const char *name, const char *variable)
bool ECPGdeallocate(int lineno, int c, const char *connection_name, const char *name)
void PGTYPESchar_free(char *ptr)
int PGTYPESnumeric_from_double(double d, numeric *dst)
int PGTYPESnumeric_copy(numeric *src, numeric *dst)
int PGTYPESnumeric_from_decimal(decimal *src, numeric *dst)
numeric * PGTYPESnumeric_new(void)
int PGTYPESnumeric_to_decimal(numeric *src, decimal *dst)
char * PGTYPESnumeric_to_asc(numeric *num, int dscale)
void PGTYPESdecimal_free(decimal *var)
int PGTYPESnumeric_mul(numeric *var1, numeric *var2, numeric *result)
int PGTYPESnumeric_to_long(numeric *nv, long *lp)
int PGTYPESnumeric_to_double(numeric *nv, double *dp)
int PGTYPESnumeric_from_long(signed long int long_val, numeric *var)
int PGTYPESnumeric_to_int(numeric *nv, int *ip)
static void dump_sqlda(sqlda_t *sqlda)
int PGTYPESnumeric_from_int(signed int int_val, numeric *var)
int PGTYPESnumeric_sub(numeric *var1, numeric *var2, numeric *result)
decimal * PGTYPESdecimal_new(void)
void PGTYPESnumeric_free(numeric *var)
int PGTYPESnumeric_cmp(numeric *var1, numeric *var2)
int PGTYPESnumeric_div(numeric *var1, numeric *var2, numeric *result)
int PGTYPESnumeric_add(numeric *var1, numeric *var2, numeric *result)
unsigned char NumericDigit
numeric * PGTYPESnumeric_from_asc(char *str, char **endptr)
struct sqlvar_struct sqlvar[1]
struct sqlda_struct * desc_next