PostgreSQL Source Code  git master
sql-declare.c File Reference
#include <ecpglib.h>
#include <ecpgerrno.h>
#include <sqlca.h>
#include <locale.h>
#include <string.h>
#include <stdlib.h>
Include dependency graph for sql-declare.c:

Go to the source code of this file.

Data Structures

struct  sqlca_t
 

Macros

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

Functions

struct sqlca_tECPGget_sqlca (void)
 
void execute_test (void)
 
void commitTable (void)
 
void reset (void)
 
void printResult (char *tc_name, int loop)
 
int main (void)
 

Variables

int f1 [ARRAY_SIZE]
 
int f2 [ARRAY_SIZE]
 
char f3 [ARRAY_SIZE][20]
 

Macro Definition Documentation

◆ ARRAY_SIZE

#define ARRAY_SIZE   2

Definition at line 100 of file sql-declare.c.

Referenced by execute_test().

◆ ECPGdebug

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

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

Referenced by main().

◆ PGDLLIMPORT

#define PGDLLIMPORT

Definition at line 27 of file sql-declare.c.

◆ POSTGRES_SQLCA_H

#define POSTGRES_SQLCA_H

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

◆ sqlca

#define sqlca   (*ECPGget_sqlca())

Definition at line 78 of file sql-declare.c.

Referenced by commitTable(), execute_test(), and main().

◆ SQLERRMC_LEN

#define SQLERRMC_LEN   150

Definition at line 31 of file sql-declare.c.

Function Documentation

◆ commitTable()

void commitTable ( void  )

Definition at line 581 of file sql-declare.c.

References ECPGtrans(), sqlca, and sqlprint().

Referenced by main().

582 {
583  { ECPGtrans(__LINE__, "con1", "commit");
584 #line 187 "declare.pgc"
585 
586 if (sqlca.sqlcode < 0) sqlprint();}
587 #line 187 "declare.pgc"
588 
589  { ECPGtrans(__LINE__, "con2", "commit");
590 #line 188 "declare.pgc"
591 
592 if (sqlca.sqlcode < 0) sqlprint();}
593 #line 188 "declare.pgc"
594 
595 }
#define sqlca
Definition: sql-declare.c:78
void sqlprint(void)
Definition: error.c:335
bool ECPGtrans(int lineno, const char *connection_name, const char *transaction)
Definition: misc.c:198

◆ ECPGget_sqlca()

struct sqlca_t* ECPGget_sqlca ( void  )

Definition at line 141 of file misc.c.

142 {
143 #ifdef ENABLE_THREAD_SAFETY
144  struct sqlca_t *sqlca;
145 
146  pthread_once(&sqlca_key_once, ecpg_sqlca_key_init);
147 
148  sqlca = pthread_getspecific(sqlca_key);
149  if (sqlca == NULL)
150  {
151  sqlca = malloc(sizeof(struct sqlca_t));
152  if (sqlca == NULL)
153  return NULL;
154  ecpg_init_sqlca(sqlca);
155  pthread_setspecific(sqlca_key, sqlca);
156  }
157  return sqlca;
158 #else
159  return &sqlca;
160 #endif
161 }
void ecpg_init_sqlca(struct sqlca_t *sqlca)
Definition: misc.c:98
#define malloc(a)
Definition: header.h:50
Definition: sqlca.h:19
void * pthread_getspecific(pthread_key_t key)
Definition: pthread-win32.c:29
static struct sqlca_t sqlca
Definition: misc.c:62
void pthread_setspecific(pthread_key_t key, void *val)
Definition: pthread-win32.c:24

◆ execute_test()

void execute_test ( void  )

Definition at line 216 of file sql-declare.c.

References ARRAY_SIZE, ECPG_NOT_FOUND, ECPGallocate_desc(), ECPGd_data, ECPGd_EODT, ECPGd_length, ECPGdeallocate(), ECPGdeallocate_desc(), ECPGdescribe(), ECPGdo(), ECPGget_desc(), ECPGget_desc_header(), ECPGprepare(), ECPGprepared_statement(), ECPGst_execute, ECPGst_normal, ECPGt_char, ECPGt_char_variable, ECPGt_descriptor, ECPGt_EOIT, ECPGt_EORT, ECPGt_int, ECPGt_NO_INDICATOR, f1, f2, f3, i, printf, printResult(), reset(), sqlca, and sqlprint().

Referenced by main().

217 {
218  /* exec sql begin declare section */
219 
220 
221 
222 #line 63 "declare.pgc"
223  int i , count , length ;
224 
225 #line 64 "declare.pgc"
226  char * selectString = "SELECT f1,f2,f3 FROM source" ;
227 /* exec sql end declare section */
228 #line 65 "declare.pgc"
229 
230 
231  /*
232  * testcase1. using DECLARE STATEMENT without using AT clause,
233  * using PREPARE and CURSOR statement without using AT clause
234  */
235  reset();
236 
237  /* declare \"stmt_1\" as an SQL identifier */
238 #line 73 "declare.pgc"
239 
240  { ECPGprepare(__LINE__, NULL, 0, "stmt_1", selectString);
241 #line 74 "declare.pgc"
242 
243 if (sqlca.sqlcode < 0) sqlprint();}
244 #line 74 "declare.pgc"
245 
246  /* declare cur_1 cursor for $1 */
247 #line 75 "declare.pgc"
248 
249  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_1 cursor for $1",
250  ECPGt_char_variable,(ECPGprepared_statement(NULL, "stmt_1", __LINE__)),(long)1,(long)1,(1)*sizeof(char),
251  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
252 #line 76 "declare.pgc"
253 
254 if (sqlca.sqlcode < 0) sqlprint();}
255 #line 76 "declare.pgc"
256 
257 
258  /* exec sql whenever not found break ; */
259 #line 78 "declare.pgc"
260 
261  i = 0;
262  while (1)
263  {
264  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_1", ECPGt_EOIT,
265  ECPGt_int,&(f1[i]),(long)1,(long)1,sizeof(int),
266  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
267  ECPGt_int,&(f2[i]),(long)1,(long)1,sizeof(int),
268  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
269  ECPGt_char,(f3[i]),(long)20,(long)1,(20)*sizeof(char),
270  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
271 #line 82 "declare.pgc"
272 
273 if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
274 #line 82 "declare.pgc"
275 
276 if (sqlca.sqlcode < 0) sqlprint();}
277 #line 82 "declare.pgc"
278 
279  i++;
280  }
281  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_1", ECPGt_EOIT, ECPGt_EORT);
282 #line 85 "declare.pgc"
283 
284 if (sqlca.sqlcode < 0) sqlprint();}
285 #line 85 "declare.pgc"
286 
287  { ECPGdeallocate(__LINE__, 0, NULL, "stmt_1");
288 #line 86 "declare.pgc"
289 
290 if (sqlca.sqlcode < 0) sqlprint();}
291 #line 86 "declare.pgc"
292 
293  /* exec sql whenever not found continue ; */
294 #line 87 "declare.pgc"
295 
296 
297  printResult("testcase1", 2);
298 
299 
300  /*
301  * testcase2. using DECLARE STATEMENT at con1,
302  * using PREPARE and CURSOR statement without using AT clause
303  */
304  reset();
305 
306  /* declare \"stmt_2\" as an SQL identifier */
307 #line 98 "declare.pgc"
308 
309  { ECPGprepare(__LINE__, "con1", 0, "stmt_2", selectString);
310 #line 99 "declare.pgc"
311 
312 if (sqlca.sqlcode < 0) sqlprint();}
313 #line 99 "declare.pgc"
314 
315  /* declare cur_2 cursor for $1 */
316 #line 100 "declare.pgc"
317 
318  { ECPGdo(__LINE__, 0, 1, "con1", 0, ECPGst_normal, "declare cur_2 cursor for $1",
319  ECPGt_char_variable,(ECPGprepared_statement("con1", "stmt_2", __LINE__)),(long)1,(long)1,(1)*sizeof(char),
320  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
321 #line 101 "declare.pgc"
322 
323 if (sqlca.sqlcode < 0) sqlprint();}
324 #line 101 "declare.pgc"
325 
326 
327  /* exec sql whenever not found break ; */
328 #line 103 "declare.pgc"
329 
330  i = 0;
331  while (1)
332  {
333  { ECPGdo(__LINE__, 0, 1, "con1", 0, ECPGst_normal, "fetch cur_2", ECPGt_EOIT,
334  ECPGt_int,&(f1[i]),(long)1,(long)1,sizeof(int),
335  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
336  ECPGt_int,&(f2[i]),(long)1,(long)1,sizeof(int),
337  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
338  ECPGt_char,(f3[i]),(long)20,(long)1,(20)*sizeof(char),
339  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
340 #line 107 "declare.pgc"
341 
342 if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
343 #line 107 "declare.pgc"
344 
345 if (sqlca.sqlcode < 0) sqlprint();}
346 #line 107 "declare.pgc"
347 
348  i++;
349  }
350  { ECPGdo(__LINE__, 0, 1, "con1", 0, ECPGst_normal, "close cur_2", ECPGt_EOIT, ECPGt_EORT);
351 #line 110 "declare.pgc"
352 
353 if (sqlca.sqlcode < 0) sqlprint();}
354 #line 110 "declare.pgc"
355 
356  { ECPGdeallocate(__LINE__, 0, "con1", "stmt_2");
357 #line 111 "declare.pgc"
358 
359 if (sqlca.sqlcode < 0) sqlprint();}
360 #line 111 "declare.pgc"
361 
362  /* exec sql whenever not found continue ; */
363 #line 112 "declare.pgc"
364 
365 
366  printResult("testcase2", 2);
367 
368  /*
369  * testcase3. using DECLARE STATEMENT without using AT clause,
370  * using PREPARE and EXECUTE statement without using AT clause
371  */
372  reset();
373 
374  /* declare \"stmt_3\" as an SQL identifier */
375 #line 122 "declare.pgc"
376 
377  { ECPGprepare(__LINE__, NULL, 0, "stmt_3", selectString);
378 #line 123 "declare.pgc"
379 
380 if (sqlca.sqlcode < 0) sqlprint();}
381 #line 123 "declare.pgc"
382 
383  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, "stmt_3", ECPGt_EOIT,
384  ECPGt_int,(f1),(long)1,(long)ARRAY_SIZE,sizeof(int),
385  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
386  ECPGt_int,(f2),(long)1,(long)ARRAY_SIZE,sizeof(int),
387  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
388  ECPGt_char,(f3),(long)20,(long)ARRAY_SIZE,(20)*sizeof(char),
389  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
390 #line 124 "declare.pgc"
391 
392 if (sqlca.sqlcode < 0) sqlprint();}
393 #line 124 "declare.pgc"
394 
395 
396  { ECPGdeallocate(__LINE__, 0, NULL, "stmt_3");
397 #line 126 "declare.pgc"
398 
399 if (sqlca.sqlcode < 0) sqlprint();}
400 #line 126 "declare.pgc"
401 
402 
403  printResult("testcase3", 2);
404 
405  /*
406  * testcase4. using DECLARE STATEMENT without using AT clause,
407  * using PREPARE and CURSOR statement at con2
408  */
409  reset();
410 
411  /* declare \"stmt_4\" as an SQL identifier */
412 #line 136 "declare.pgc"
413 
414  { ECPGprepare(__LINE__, "con2", 0, "stmt_4", selectString);
415 #line 137 "declare.pgc"
416 
417 if (sqlca.sqlcode < 0) sqlprint();}
418 #line 137 "declare.pgc"
419 
420  /* declare cur_4 cursor for $1 */
421 #line 138 "declare.pgc"
422 
423  { ECPGdo(__LINE__, 0, 1, "con2", 0, ECPGst_normal, "declare cur_4 cursor for $1",
424  ECPGt_char_variable,(ECPGprepared_statement("con2", "stmt_4", __LINE__)),(long)1,(long)1,(1)*sizeof(char),
425  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
426 #line 139 "declare.pgc"
427 
428 if (sqlca.sqlcode < 0) sqlprint();}
429 #line 139 "declare.pgc"
430 
431 
432  /* exec sql whenever not found break ; */
433 #line 141 "declare.pgc"
434 
435  i = 0;
436  while (1)
437  {
438  { ECPGdo(__LINE__, 0, 1, "con2", 0, ECPGst_normal, "fetch cur_4", ECPGt_EOIT,
439  ECPGt_int,&(f1[i]),(long)1,(long)1,sizeof(int),
440  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
441  ECPGt_int,&(f2[i]),(long)1,(long)1,sizeof(int),
442  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
443  ECPGt_char,(f3[i]),(long)20,(long)1,(20)*sizeof(char),
444  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
445 #line 145 "declare.pgc"
446 
447 if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
448 #line 145 "declare.pgc"
449 
450 if (sqlca.sqlcode < 0) sqlprint();}
451 #line 145 "declare.pgc"
452 
453  i++;
454  }
455  { ECPGdo(__LINE__, 0, 1, "con2", 0, ECPGst_normal, "close cur_4", ECPGt_EOIT, ECPGt_EORT);
456 #line 148 "declare.pgc"
457 
458 if (sqlca.sqlcode < 0) sqlprint();}
459 #line 148 "declare.pgc"
460 
461  { ECPGdeallocate(__LINE__, 0, "con2", "stmt_4");
462 #line 149 "declare.pgc"
463 
464 if (sqlca.sqlcode < 0) sqlprint();}
465 #line 149 "declare.pgc"
466 
467  /* exec sql whenever not found continue ; */
468 #line 150 "declare.pgc"
469 
470 
471  printResult("testcase4", 2);
472 
473  /*
474  * DESCRIBE statement is also supported.
475  */
476  /* declare \"stmt_desc\" as an SQL identifier */
477 #line 157 "declare.pgc"
478 
479  { ECPGprepare(__LINE__, "con1", 0, "stmt_desc", selectString);
480 #line 158 "declare.pgc"
481 
482 if (sqlca.sqlcode < 0) sqlprint();}
483 #line 158 "declare.pgc"
484 
485  /* declare cur_desc cursor for $1 */
486 #line 159 "declare.pgc"
487 
488  { ECPGdo(__LINE__, 0, 1, "con1", 0, ECPGst_normal, "declare cur_desc cursor for $1",
489  ECPGt_char_variable,(ECPGprepared_statement("con1", "stmt_desc", __LINE__)),(long)1,(long)1,(1)*sizeof(char),
490  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
491 #line 160 "declare.pgc"
492 
493 if (sqlca.sqlcode < 0) sqlprint();}
494 #line 160 "declare.pgc"
495 
496 
497  /* descriptor can be used for describe statement */
498  ECPGallocate_desc(__LINE__, "desc_for_describe");
499 #line 163 "declare.pgc"
500 
501 if (sqlca.sqlcode < 0) sqlprint();
502 #line 163 "declare.pgc"
503 
504  { ECPGdescribe(__LINE__, 0, 0, "con1", "stmt_desc",
505  ECPGt_descriptor, "desc_for_describe", 1L, 1L, 1L,
506  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
507 #line 164 "declare.pgc"
508 
509 
510  { ECPGget_desc_header(__LINE__, "desc_for_describe", &(count));
511 
512 #line 166 "declare.pgc"
513 
514 if (sqlca.sqlcode < 0) sqlprint();}
515 #line 166 "declare.pgc"
516 
517  { ECPGget_desc(__LINE__, "desc_for_describe", 3,ECPGd_length,
518  ECPGt_int,&(length),(long)1,(long)1,sizeof(int), ECPGd_EODT);
519 
520 #line 167 "declare.pgc"
521 
522 if (sqlca.sqlcode < 0) sqlprint();}
523 #line 167 "declare.pgc"
524 
525 
526  ECPGdeallocate_desc(__LINE__, "desc_for_describe");
527 #line 169 "declare.pgc"
528 
529 if (sqlca.sqlcode < 0) sqlprint();
530 #line 169 "declare.pgc"
531 
532 
533  /* for fetch statement */
534  ECPGallocate_desc(__LINE__, "desc_for_fetch");
535 #line 172 "declare.pgc"
536 
537 if (sqlca.sqlcode < 0) sqlprint();
538 #line 172 "declare.pgc"
539 
540  { ECPGdo(__LINE__, 0, 1, "con1", 0, ECPGst_normal, "fetch cur_desc", ECPGt_EOIT,
541  ECPGt_descriptor, "desc_for_fetch", 1L, 1L, 1L,
542  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
543 #line 173 "declare.pgc"
544 
545 if (sqlca.sqlcode < 0) sqlprint();}
546 #line 173 "declare.pgc"
547 
548 
549  { ECPGget_desc(__LINE__, "desc_for_fetch", 3,ECPGd_data,
550  ECPGt_char,(f3[0]),(long)20,(long)1,(20)*sizeof(char), ECPGd_EODT);
551 
552 #line 175 "declare.pgc"
553 
554 if (sqlca.sqlcode < 0) sqlprint();}
555 #line 175 "declare.pgc"
556 
557 
558  ECPGdeallocate_desc(__LINE__, "desc_for_fetch");
559 #line 177 "declare.pgc"
560 
561 if (sqlca.sqlcode < 0) sqlprint();
562 #line 177 "declare.pgc"
563 
564  { ECPGdo(__LINE__, 0, 1, "con1", 0, ECPGst_normal, "close cur_desc", ECPGt_EOIT, ECPGt_EORT);
565 #line 178 "declare.pgc"
566 
567 if (sqlca.sqlcode < 0) sqlprint();}
568 #line 178 "declare.pgc"
569 
570  { ECPGdeallocate(__LINE__, 0, "con1", "stmt_desc");
571 #line 179 "declare.pgc"
572 
573 if (sqlca.sqlcode < 0) sqlprint();}
574 #line 179 "declare.pgc"
575 
576 
577  printf("****descriptor results****\n");
578  printf("count: %d, length: %d, data: %s\n", count, length, f3[0]);
579 }
bool ECPGallocate_desc(int line, const char *name)
Definition: descriptor.c:797
char f3[ARRAY_SIZE][20]
Definition: sql-declare.c:119
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,...)
Definition: execute.c:2287
void reset(void)
Definition: sql-declare.c:600
bool ECPGprepare(int lineno, const char *connection_name, const bool questionmarks, const char *name, const char *variable)
Definition: prepare.c:217
#define printf(...)
Definition: port.h:222
bool ECPGdescribe(int line, int compat, bool input, const char *connection_name, const char *stmt_name,...)
Definition: descriptor.c:852
#define sqlca
Definition: sql-declare.c:78
void printResult(char *tc_name, int loop)
Definition: sql-declare.c:607
#define ECPG_NOT_FOUND
Definition: ecpgerrno.h:10
bool ECPGget_desc(int lineno, const char *desc_name, int index,...)
Definition: descriptor.c:241
bool ECPGdeallocate(int lineno, int c, const char *connection_name, const char *name)
Definition: prepare.c:315
int f2[ARRAY_SIZE]
Definition: sql-declare.c:116
bool ECPGget_desc_header(int lineno, const char *desc_name, int *count)
Definition: descriptor.c:91
void sqlprint(void)
Definition: error.c:335
bool ECPGdeallocate_desc(int line, const char *name)
Definition: descriptor.c:750
char * ECPGprepared_statement(const char *connection_name, const char *name, int lineno)
Definition: prepare.c:368
#define ARRAY_SIZE
Definition: sql-declare.c:100
int i
int f1[ARRAY_SIZE]
Definition: sql-declare.c:113

◆ main()

int main ( void  )

Definition at line 124 of file sql-declare.c.

References commitTable(), ECPGconnect(), ECPGdebug, ECPGdisconnect(), ECPGdo(), ECPGst_normal, ECPGt_EOIT, ECPGt_EORT, execute_test(), setlocale, sqlca, and sqlprint().

125 {
126  setlocale(LC_ALL, "C");
127 
128  ECPGdebug(1, stderr);
129 
130  { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , "con1", 0);
131 #line 29 "declare.pgc"
132 
133 if (sqlca.sqlcode < 0) sqlprint();}
134 #line 29 "declare.pgc"
135 
136  { ECPGconnect(__LINE__, 0, "ecpg2_regression" , NULL, NULL , "con2", 0);
137 #line 30 "declare.pgc"
138 
139 if (sqlca.sqlcode < 0) sqlprint();}
140 #line 30 "declare.pgc"
141 
142 
143  { ECPGdo(__LINE__, 0, 1, "con1", 0, ECPGst_normal, "create table source ( f1 integer , f2 integer , f3 varchar ( 20 ) )", ECPGt_EOIT, ECPGt_EORT);
144 #line 32 "declare.pgc"
145 
146 if (sqlca.sqlcode < 0) sqlprint();}
147 #line 32 "declare.pgc"
148 
149  { ECPGdo(__LINE__, 0, 1, "con2", 0, ECPGst_normal, "create table source ( f1 integer , f2 integer , f3 varchar ( 20 ) )", ECPGt_EOIT, ECPGt_EORT);
150 #line 33 "declare.pgc"
151 
152 if (sqlca.sqlcode < 0) sqlprint();}
153 #line 33 "declare.pgc"
154 
155 
156  { ECPGdo(__LINE__, 0, 1, "con1", 0, ECPGst_normal, "insert into source values ( 1 , 10 , 'db on con1' )", ECPGt_EOIT, ECPGt_EORT);
157 #line 35 "declare.pgc"
158 
159 if (sqlca.sqlcode < 0) sqlprint();}
160 #line 35 "declare.pgc"
161 
162  { ECPGdo(__LINE__, 0, 1, "con1", 0, ECPGst_normal, "insert into source values ( 2 , 20 , 'db on con1' )", ECPGt_EOIT, ECPGt_EORT);
163 #line 36 "declare.pgc"
164 
165 if (sqlca.sqlcode < 0) sqlprint();}
166 #line 36 "declare.pgc"
167 
168 
169  { ECPGdo(__LINE__, 0, 1, "con2", 0, ECPGst_normal, "insert into source values ( 1 , 10 , 'db on con2' )", ECPGt_EOIT, ECPGt_EORT);
170 #line 38 "declare.pgc"
171 
172 if (sqlca.sqlcode < 0) sqlprint();}
173 #line 38 "declare.pgc"
174 
175  { ECPGdo(__LINE__, 0, 1, "con2", 0, ECPGst_normal, "insert into source values ( 2 , 20 , 'db on con2' )", ECPGt_EOIT, ECPGt_EORT);
176 #line 39 "declare.pgc"
177 
178 if (sqlca.sqlcode < 0) sqlprint();}
179 #line 39 "declare.pgc"
180 
181 
182  commitTable();
183 
184  execute_test();
185 
186  { ECPGdo(__LINE__, 0, 1, "con1", 0, ECPGst_normal, "drop table if exists source", ECPGt_EOIT, ECPGt_EORT);
187 #line 45 "declare.pgc"
188 
189 if (sqlca.sqlcode < 0) sqlprint();}
190 #line 45 "declare.pgc"
191 
192  { ECPGdo(__LINE__, 0, 1, "con2", 0, ECPGst_normal, "drop table if exists source", ECPGt_EOIT, ECPGt_EORT);
193 #line 46 "declare.pgc"
194 
195 if (sqlca.sqlcode < 0) sqlprint();}
196 #line 46 "declare.pgc"
197 
198 
199  commitTable();
200 
201  { ECPGdisconnect(__LINE__, "ALL");
202 #line 50 "declare.pgc"
203 
204 if (sqlca.sqlcode < 0) sqlprint();}
205 #line 50 "declare.pgc"
206 
207 
208  return 0;
209 }
bool ECPGdisconnect(int lineno, const char *connection_name)
Definition: connect.c:666
#define setlocale(a, b)
Definition: win32_port.h:436
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,...)
Definition: execute.c:2287
void commitTable(void)
Definition: sql-declare.c:581
#define sqlca
Definition: sql-declare.c:78
bool ECPGconnect(int lineno, int c, const char *name, const char *user, const char *passwd, const char *connection_name, int autocommit)
Definition: connect.c:271
#define ECPGdebug(X, Y)
Definition: sql-declare.c:7
void sqlprint(void)
Definition: error.c:335
void execute_test(void)
Definition: sql-declare.c:216

◆ printResult()

void printResult ( char *  tc_name,
int  loop 
)

Definition at line 607 of file sql-declare.c.

References f1, f2, f3, i, and printf.

Referenced by execute_test().

608 {
609  int i;
610 
611  if (tc_name)
612  printf("****%s test results:****\n", tc_name);
613 
614  for (i = 0; i < loop; i++)
615  printf("f1=%d, f2=%d, f3=%s\n", f1[i], f2[i], f3[i]);
616 
617  printf("\n");
618 }
char f3[ARRAY_SIZE][20]
Definition: sql-declare.c:119
#define printf(...)
Definition: port.h:222
int f2[ARRAY_SIZE]
Definition: sql-declare.c:116
int i
int f1[ARRAY_SIZE]
Definition: sql-declare.c:113

◆ reset()

void reset ( void  )

Definition at line 600 of file sql-declare.c.

References f1, f2, and f3.

Referenced by execute_test().

601 {
602  memset(f1, 0, sizeof(f1));
603  memset(f2, 0, sizeof(f2));
604  memset(f3, 0, sizeof(f3));
605 }
char f3[ARRAY_SIZE][20]
Definition: sql-declare.c:119
int f2[ARRAY_SIZE]
Definition: sql-declare.c:116
int f1[ARRAY_SIZE]
Definition: sql-declare.c:113

Variable Documentation

◆ f1

◆ f2

int f2[ARRAY_SIZE]

Definition at line 116 of file sql-declare.c.

Referenced by cmpcmdflag(), execute_test(), float8_qsort_cmp(), printResult(), and reset().

◆ f3

char f3[ARRAY_SIZE][20]

Definition at line 119 of file sql-declare.c.

Referenced by execute_test(), printResult(), and reset().