mirror of https://github.com/postgres/postgres
parent
893632be4e
commit
52a013bea8
@ -1 +1,2 @@ |
||||
id=1 name=first user , accs=320 |
||||
name[0]=false amount[0]=1 letter[0]=f |
||||
name[1]=true amount[1]=2 letter[1]=t |
||||
|
@ -0,0 +1,168 @@ |
||||
/* Processed by ecpg (4.2.1) */ |
||||
/* These include files are added by the preprocessor */ |
||||
#include <ecpgtype.h> |
||||
#include <ecpglib.h> |
||||
#include <ecpgerrno.h> |
||||
#include <sqlca.h> |
||||
/* End of automatic include section */ |
||||
|
||||
#line 1 "type.pgc" |
||||
#include <stdio.h> |
||||
#include <stdlib.h> |
||||
|
||||
|
||||
#line 1 "regression.h" |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#line 4 "type.pgc" |
||||
|
||||
|
||||
typedef long mmInteger ; |
||||
|
||||
#line 6 "type.pgc" |
||||
|
||||
#line 6 "type.pgc" |
||||
|
||||
typedef char mmChar ; |
||||
|
||||
#line 7 "type.pgc" |
||||
|
||||
#line 7 "type.pgc" |
||||
|
||||
typedef short mmSmallInt ; |
||||
|
||||
#line 8 "type.pgc" |
||||
|
||||
#line 8 "type.pgc" |
||||
|
||||
|
||||
/* exec sql type string is char [ 11 ] */ |
||||
#line 10 "type.pgc" |
||||
|
||||
typedef char string[11]; |
||||
|
||||
/* exec sql type c is char reference */ |
||||
#line 13 "type.pgc" |
||||
|
||||
typedef char* c; |
||||
|
||||
/* exec sql begin declare section */ |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
struct TBempl {
|
||||
#line 19 "type.pgc" |
||||
mmInteger idnum ; |
||||
|
||||
#line 20 "type.pgc" |
||||
mmChar name [ 21 ] ; |
||||
|
||||
#line 21 "type.pgc" |
||||
mmSmallInt accs ; |
||||
} ;/* exec sql end declare section */ |
||||
#line 23 "type.pgc" |
||||
|
||||
|
||||
int |
||||
main (void) |
||||
{ |
||||
/* exec sql begin declare section */ |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#line 29 "type.pgc" |
||||
struct TBempl empl ; |
||||
|
||||
#line 30 "type.pgc" |
||||
string str ; |
||||
|
||||
#line 31 "type.pgc" |
||||
c ptr = NULL ; |
||||
|
||||
#line 36 "type.pgc" |
||||
struct varchar_vc {
|
||||
#line 34 "type.pgc" |
||||
int len ; |
||||
|
||||
#line 35 "type.pgc" |
||||
char text [ 10 ] ; |
||||
} vc ; |
||||
/* exec sql end declare section */ |
||||
#line 37 "type.pgc" |
||||
|
||||
|
||||
/* exec sql var vc is [ 10 ] */ |
||||
#line 39 "type.pgc" |
||||
|
||||
ECPGdebug (1, stderr); |
||||
|
||||
empl.idnum = 1; |
||||
{ ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); } |
||||
#line 43 "type.pgc" |
||||
|
||||
if (sqlca.sqlcode) |
||||
{ |
||||
printf ("connect error = %ld\n", sqlca.sqlcode); |
||||
exit (sqlca.sqlcode); |
||||
} |
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, "create table empl ( idnum integer , name char ( 20 ) , accs smallint , string1 char ( 10 ) , string2 char ( 10 ) , string3 char ( 10 ) ) ", ECPGt_EOIT, ECPGt_EORT);} |
||||
#line 51 "type.pgc" |
||||
|
||||
if (sqlca.sqlcode) |
||||
{ |
||||
printf ("create error = %ld\n", sqlca.sqlcode); |
||||
exit (sqlca.sqlcode); |
||||
} |
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, "insert into empl values ( 1 , 'user name' , 320 , 'first str' , 'second str' , 'third str' ) ", ECPGt_EOIT, ECPGt_EORT);} |
||||
#line 58 "type.pgc" |
||||
|
||||
if (sqlca.sqlcode) |
||||
{ |
||||
printf ("insert error = %ld\n", sqlca.sqlcode); |
||||
exit (sqlca.sqlcode); |
||||
} |
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, "select idnum , name , accs , string1 , string2 , string3 from empl where idnum = ? ",
|
||||
ECPGt_long,&(empl.idnum),(long)1,(long)1,sizeof(long),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
|
||||
ECPGt_long,&(empl.idnum),(long)1,(long)1,sizeof(long),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_char,&(empl.name),(long)21,(long)1,(21)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_short,&(empl.accs),(long)1,(long)1,sizeof(short),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_char,(str),(long)11,(long)1,(11)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_char,&(ptr),(long)0,(long)1,(1)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_varchar,&(vc),(long)10,(long)1,sizeof(struct varchar_vc),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} |
||||
#line 68 "type.pgc" |
||||
|
||||
if (sqlca.sqlcode) |
||||
{ |
||||
printf ("select error = %ld\n", sqlca.sqlcode); |
||||
exit (sqlca.sqlcode); |
||||
} |
||||
printf ("id=%ld name='%s' accs=%d str='%s' ptr='%s' vc='%10.10s'\n", empl.idnum, empl.name, empl.accs, str, ptr, vc.text); |
||||
|
||||
{ ECPGdisconnect(__LINE__, "CURRENT");} |
||||
#line 76 "type.pgc" |
||||
|
||||
exit (0); |
||||
} |
@ -0,0 +1,32 @@ |
||||
[NO_PID]: ECPGdebug: set to 1 |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT> |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGexecute line 50: QUERY: create table empl ( idnum integer , name char ( 20 ) , accs smallint , string1 char ( 10 ) , string2 char ( 10 ) , string3 char ( 10 ) ) on connection regress1 |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGexecute line 50 Ok: CREATE TABLE |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGexecute line 58: QUERY: insert into empl values ( 1 , 'user name' , 320 , 'first str' , 'second str' , 'third str' ) on connection regress1 |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGexecute line 58 Ok: INSERT 0 1 |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGexecute line 65: QUERY: select idnum , name , accs , string1 , string2 , string3 from empl where idnum = 1 on connection regress1 |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGexecute line 65: Correctly got 1 tuples with 6 fields |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGget_data line 65: RESULT: 1 offset: -1 array: Yes |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGget_data line 65: RESULT: user name offset: -1 array: Yes |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGget_data line 65: RESULT: 320 offset: -1 array: Yes |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGget_data line 65: RESULT: first str offset: -1 array: Yes |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGstore_result: line 65: allocating memory for 1 tuples |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGget_data line 65: RESULT: second str offset: -1 array: Yes |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGget_data line 65: RESULT: third str offset: -1 array: Yes |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ecpg_finish: Connection regress1 closed. |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
@ -0,0 +1 @@ |
||||
id=1 name='user name ' accs=320 str='first str ' ptr='second str' vc='third str ' |
@ -0,0 +1,261 @@ |
||||
/* Processed by ecpg (4.2.1) */ |
||||
/* These include files are added by the preprocessor */ |
||||
#include <ecpgtype.h> |
||||
#include <ecpglib.h> |
||||
#include <ecpgerrno.h> |
||||
#include <sqlca.h> |
||||
/* End of automatic include section */ |
||||
|
||||
#line 1 "variable.pgc" |
||||
#include <stdlib.h> |
||||
#include <string.h> |
||||
|
||||
|
||||
#line 1 "regression.h" |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#line 4 "variable.pgc" |
||||
|
||||
|
||||
/* exec sql whenever sqlerror sqlprint ; */ |
||||
#line 6 "variable.pgc" |
||||
|
||||
|
||||
/* exec sql type c is char reference */ |
||||
#line 8 "variable.pgc" |
||||
|
||||
typedef char* c; |
||||
|
||||
/* exec sql type ind is union {
|
||||
#line 11 "variable.pgc" |
||||
int integer ; |
||||
|
||||
#line 11 "variable.pgc" |
||||
short smallint ; |
||||
} */ |
||||
#line 11 "variable.pgc" |
||||
|
||||
typedef union { int integer; short smallint; } ind; |
||||
|
||||
#define BUFFERSIZ 8 |
||||
/* exec sql type str is [ BUFFERSIZ ] */ |
||||
#line 15 "variable.pgc" |
||||
|
||||
|
||||
/* declare cur cursor for select name , born , age , married , children from family */ |
||||
#line 18 "variable.pgc" |
||||
|
||||
|
||||
int |
||||
main (void) |
||||
{ |
||||
struct birthinfo {
|
||||
#line 23 "variable.pgc" |
||||
long born ; |
||||
|
||||
#line 23 "variable.pgc" |
||||
short age ; |
||||
} ; |
||||
#line 23 "variable.pgc" |
||||
|
||||
/* exec sql begin declare section */ |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#line 27 "variable.pgc" |
||||
struct personal_struct {
|
||||
#line 25 "variable.pgc" |
||||
struct varchar_name { int len; char arr[ BUFFERSIZ ]; } name ; |
||||
|
||||
#line 26 "variable.pgc" |
||||
struct birthinfo birth ; |
||||
} personal , * p ; |
||||
|
||||
#line 30 "variable.pgc" |
||||
struct personal_indicator {
|
||||
#line 28 "variable.pgc" |
||||
int ind_name ; |
||||
|
||||
#line 29 "variable.pgc" |
||||
struct birthinfo ind_birth ; |
||||
} ind_personal , * i ; |
||||
|
||||
#line 31 "variable.pgc" |
||||
ind ind_children ; |
||||
/* exec sql end declare section */ |
||||
#line 32 "variable.pgc" |
||||
|
||||
|
||||
|
||||
#line 34 "variable.pgc" |
||||
char * married = NULL ; |
||||
|
||||
#line 34 "variable.pgc" |
||||
|
||||
|
||||
#line 35 "variable.pgc" |
||||
long ind_married ; |
||||
|
||||
#line 35 "variable.pgc" |
||||
|
||||
|
||||
#line 36 "variable.pgc" |
||||
ind children ; |
||||
|
||||
#line 36 "variable.pgc" |
||||
|
||||
|
||||
char msg[128]; |
||||
|
||||
ECPGdebug(1, stderr); |
||||
|
||||
strcpy(msg, "connect"); |
||||
{ ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0);
|
||||
#line 43 "variable.pgc" |
||||
|
||||
if (sqlca.sqlcode < 0) sqlprint();} |
||||
#line 43 "variable.pgc" |
||||
|
||||
|
||||
strcpy(msg, "create"); |
||||
{ ECPGdo(__LINE__, 0, 1, NULL, "create table family ( name char ( 8 ) , born integer , age smallint , married date , children integer ) ", ECPGt_EOIT, ECPGt_EORT); |
||||
#line 46 "variable.pgc" |
||||
|
||||
if (sqlca.sqlcode < 0) sqlprint();} |
||||
#line 46 "variable.pgc" |
||||
|
||||
|
||||
strcpy(msg, "insert"); |
||||
{ ECPGdo(__LINE__, 0, 1, NULL, "insert into family ( name , married , children ) values ( 'Mum' , '19870714' , 3 ) ", ECPGt_EOIT, ECPGt_EORT); |
||||
#line 49 "variable.pgc" |
||||
|
||||
if (sqlca.sqlcode < 0) sqlprint();} |
||||
#line 49 "variable.pgc" |
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, "insert into family ( name , born , married , children ) values ( 'Dad' , '19610721' , '19870714' , 3 ) ", ECPGt_EOIT, ECPGt_EORT); |
||||
#line 50 "variable.pgc" |
||||
|
||||
if (sqlca.sqlcode < 0) sqlprint();} |
||||
#line 50 "variable.pgc" |
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, "insert into family ( name , age ) values ( 'Child 1' , 16 ) ", ECPGt_EOIT, ECPGt_EORT); |
||||
#line 51 "variable.pgc" |
||||
|
||||
if (sqlca.sqlcode < 0) sqlprint();} |
||||
#line 51 "variable.pgc" |
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, "insert into family ( name , age ) values ( 'Child 2' , 14 ) ", ECPGt_EOIT, ECPGt_EORT); |
||||
#line 52 "variable.pgc" |
||||
|
||||
if (sqlca.sqlcode < 0) sqlprint();} |
||||
#line 52 "variable.pgc" |
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, "insert into family ( name , age ) values ( 'Child 3' , 9 ) ", ECPGt_EOIT, ECPGt_EORT); |
||||
#line 53 "variable.pgc" |
||||
|
||||
if (sqlca.sqlcode < 0) sqlprint();} |
||||
#line 53 "variable.pgc" |
||||
|
||||
|
||||
strcpy(msg, "commit"); |
||||
{ ECPGtrans(__LINE__, NULL, "commit"); |
||||
#line 56 "variable.pgc" |
||||
|
||||
if (sqlca.sqlcode < 0) sqlprint();} |
||||
#line 56 "variable.pgc" |
||||
|
||||
|
||||
strcpy(msg, "open"); |
||||
{ ECPGdo(__LINE__, 0, 1, NULL, "declare cur cursor for select name , born , age , married , children from family ", ECPGt_EOIT, ECPGt_EORT); |
||||
#line 59 "variable.pgc" |
||||
|
||||
if (sqlca.sqlcode < 0) sqlprint();} |
||||
#line 59 "variable.pgc" |
||||
|
||||
|
||||
/* exec sql whenever not found break ; */ |
||||
#line 61 "variable.pgc" |
||||
|
||||
|
||||
p=&personal; |
||||
i=&ind_personal; |
||||
memset(i, 0, sizeof(ind_personal)); |
||||
while (1) { |
||||
strcpy(msg, "fetch"); |
||||
{ ECPGdo(__LINE__, 0, 1, NULL, "fetch cur", ECPGt_EOIT,
|
||||
ECPGt_varchar,&(p->name),(long)BUFFERSIZ,(long)1,sizeof(struct varchar_name),
|
||||
ECPGt_int,&(i->ind_name),(long)1,(long)1,sizeof(int),
|
||||
ECPGt_long,&(p->birth.born),(long)1,(long)1,sizeof(long),
|
||||
ECPGt_long,&(i->ind_birth.born),(long)1,(long)1,sizeof(long),
|
||||
ECPGt_short,&(p->birth.age),(long)1,(long)1,sizeof(short),
|
||||
ECPGt_short,&(i->ind_birth.age),(long)1,(long)1,sizeof(short),
|
||||
ECPGt_char,&(married),(long)0,(long)1,(1)*sizeof(char),
|
||||
ECPGt_long,&(ind_married),(long)1,(long)1,sizeof(long),
|
||||
ECPGt_int,&(children.integer),(long)1,(long)1,sizeof(int),
|
||||
ECPGt_short,&(ind_children.smallint),(long)1,(long)1,sizeof(short), ECPGt_EORT); |
||||
#line 68 "variable.pgc" |
||||
|
||||
if (sqlca.sqlcode == ECPG_NOT_FOUND) break; |
||||
#line 68 "variable.pgc" |
||||
|
||||
if (sqlca.sqlcode < 0) sqlprint();} |
||||
#line 68 "variable.pgc" |
||||
|
||||
printf("%8.8s", personal.name.arr); |
||||
if (i->ind_birth.born >= 0) |
||||
printf(", born %ld", personal.birth.born); |
||||
if (i->ind_birth.age >= 0) |
||||
printf(", age = %d", personal.birth.age); |
||||
if (ind_married >= 0) |
||||
printf(", married %s", married); |
||||
if (ind_children.smallint >= 0) |
||||
printf(", children = %d", children.integer); |
||||
putchar('\n'); |
||||
|
||||
free(married); |
||||
married = NULL; |
||||
} |
||||
|
||||
strcpy(msg, "close"); |
||||
{ ECPGdo(__LINE__, 0, 1, NULL, "close cur", ECPGt_EOIT, ECPGt_EORT); |
||||
#line 85 "variable.pgc" |
||||
|
||||
if (sqlca.sqlcode < 0) sqlprint();} |
||||
#line 85 "variable.pgc" |
||||
|
||||
|
||||
strcpy(msg, "drop"); |
||||
{ ECPGdo(__LINE__, 0, 1, NULL, "drop table family ", ECPGt_EOIT, ECPGt_EORT); |
||||
#line 88 "variable.pgc" |
||||
|
||||
if (sqlca.sqlcode < 0) sqlprint();} |
||||
#line 88 "variable.pgc" |
||||
|
||||
|
||||
strcpy(msg, "commit"); |
||||
{ ECPGtrans(__LINE__, NULL, "commit"); |
||||
#line 91 "variable.pgc" |
||||
|
||||
if (sqlca.sqlcode < 0) sqlprint();} |
||||
#line 91 "variable.pgc" |
||||
|
||||
|
||||
strcpy(msg, "disconnect");
|
||||
{ ECPGdisconnect(__LINE__, "CURRENT"); |
||||
#line 94 "variable.pgc" |
||||
|
||||
if (sqlca.sqlcode < 0) sqlprint();} |
||||
#line 94 "variable.pgc" |
||||
|
||||
|
||||
return (0); |
||||
} |
@ -0,0 +1,132 @@ |
||||
[NO_PID]: ECPGdebug: set to 1 |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT> |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGexecute line 46: QUERY: create table family ( name char ( 8 ) , born integer , age smallint , married date , children integer ) on connection regress1 |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGexecute line 46 Ok: CREATE TABLE |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGexecute line 49: QUERY: insert into family ( name , married , children ) values ( 'Mum' , '19870714' , 3 ) on connection regress1 |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGexecute line 49 Ok: INSERT 0 1 |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGexecute line 50: QUERY: insert into family ( name , born , married , children ) values ( 'Dad' , '19610721' , '19870714' , 3 ) on connection regress1 |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGexecute line 50 Ok: INSERT 0 1 |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGexecute line 51: QUERY: insert into family ( name , age ) values ( 'Child 1' , 16 ) on connection regress1 |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGexecute line 51 Ok: INSERT 0 1 |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGexecute line 52: QUERY: insert into family ( name , age ) values ( 'Child 2' , 14 ) on connection regress1 |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGexecute line 52 Ok: INSERT 0 1 |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGexecute line 53: QUERY: insert into family ( name , age ) values ( 'Child 3' , 9 ) on connection regress1 |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGexecute line 53 Ok: INSERT 0 1 |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGtrans line 56 action = commit connection = regress1 |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGexecute line 59: QUERY: declare cur cursor for select name , born , age , married , children from family on connection regress1 |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGexecute line 59 Ok: DECLARE CURSOR |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGexecute line 68: QUERY: fetch cur on connection regress1 |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGexecute line 68: Correctly got 1 tuples with 5 fields |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGget_data line 68: RESULT: Mum offset: -1 array: Yes |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGget_data line 68: RESULT: offset: -1 array: Yes |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGget_data line 68: RESULT: offset: -1 array: Yes |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGstore_result: line 68: allocating memory for 1 tuples |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGget_data line 68: RESULT: 07-14-1987 offset: -1 array: Yes |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGget_data line 68: RESULT: 3 offset: -1 array: Yes |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGexecute line 68: QUERY: fetch cur on connection regress1 |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGexecute line 68: Correctly got 1 tuples with 5 fields |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGget_data line 68: RESULT: Dad offset: -1 array: Yes |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGget_data line 68: RESULT: 19610721 offset: -1 array: Yes |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGget_data line 68: RESULT: offset: -1 array: Yes |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGstore_result: line 68: allocating memory for 1 tuples |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGget_data line 68: RESULT: 07-14-1987 offset: -1 array: Yes |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGget_data line 68: RESULT: 3 offset: -1 array: Yes |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGexecute line 68: QUERY: fetch cur on connection regress1 |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGexecute line 68: Correctly got 1 tuples with 5 fields |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGget_data line 68: RESULT: Child 1 offset: -1 array: Yes |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGget_data line 68: RESULT: offset: -1 array: Yes |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGget_data line 68: RESULT: 16 offset: -1 array: Yes |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGstore_result: line 68: allocating memory for 1 tuples |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGget_data line 68: RESULT: offset: -1 array: Yes |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGget_data line 68: RESULT: offset: -1 array: Yes |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGexecute line 68: QUERY: fetch cur on connection regress1 |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGexecute line 68: Correctly got 1 tuples with 5 fields |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGget_data line 68: RESULT: Child 2 offset: -1 array: Yes |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGget_data line 68: RESULT: offset: -1 array: Yes |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGget_data line 68: RESULT: 14 offset: -1 array: Yes |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGstore_result: line 68: allocating memory for 1 tuples |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGget_data line 68: RESULT: offset: -1 array: Yes |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGget_data line 68: RESULT: offset: -1 array: Yes |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGexecute line 68: QUERY: fetch cur on connection regress1 |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGexecute line 68: Correctly got 1 tuples with 5 fields |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGget_data line 68: RESULT: Child 3 offset: -1 array: Yes |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGget_data line 68: RESULT: offset: -1 array: Yes |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGget_data line 68: RESULT: 9 offset: -1 array: Yes |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGstore_result: line 68: allocating memory for 1 tuples |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGget_data line 68: RESULT: offset: -1 array: Yes |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGget_data line 68: RESULT: offset: -1 array: Yes |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGexecute line 68: QUERY: fetch cur on connection regress1 |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGexecute line 68: Correctly got 0 tuples with 5 fields |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: raising sqlcode 100 in line 68, 'No data found in line 68.'. |
||||
[NO_PID]: sqlca: code: 100, state: 02000 |
||||
[NO_PID]: ECPGexecute line 85: QUERY: close cur on connection regress1 |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGexecute line 85 Ok: CLOSE CURSOR |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGexecute line 88: QUERY: drop table family on connection regress1 |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGexecute line 88 Ok: DROP TABLE |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ECPGtrans line 91 action = commit connection = regress1 |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
||||
[NO_PID]: ecpg_finish: Connection regress1 closed. |
||||
[NO_PID]: sqlca: code: 0, state: 00000 |
@ -0,0 +1,5 @@ |
||||
Mum , married 07-14-1987, children = 3 |
||||
Dad , born 19610721, married 07-14-1987, children = 3 |
||||
Child 1 , age = 16 |
||||
Child 2 , age = 14 |
||||
Child 3 , age = 9 |
@ -1,64 +1,61 @@ |
||||
#include <stdio.h> |
||||
#include <stdlib.h> |
||||
#include <string.h> |
||||
#include <stdlib.h> |
||||
#include <stdio.h> |
||||
|
||||
EXEC SQL include ../regression; |
||||
exec sql include ../regression; |
||||
|
||||
EXEC SQL typedef long mmInteger; |
||||
EXEC SQL typedef char mmChar; |
||||
EXEC SQL typedef short mmSmallInt; |
||||
exec sql whenever sqlerror sqlprint; |
||||
|
||||
EXEC SQL BEGIN DECLARE SECTION; |
||||
struct TBempl |
||||
{ |
||||
mmInteger idnum; |
||||
mmChar name[21]; |
||||
mmSmallInt accs; |
||||
}; |
||||
EXEC SQL END DECLARE SECTION; |
||||
exec sql define AMOUNT 6; |
||||
exec sql define NAMELEN 8; |
||||
|
||||
exec sql type intarray is int[AMOUNT]; |
||||
typedef int intarray[AMOUNT]; |
||||
|
||||
int |
||||
main (void) |
||||
main(void) |
||||
{ |
||||
EXEC SQL BEGIN DECLARE SECTION; |
||||
struct TBempl empl; |
||||
EXEC SQL END DECLARE SECTION; |
||||
|
||||
ECPGdebug (1, stderr); |
||||
|
||||
empl.idnum = 1; |
||||
EXEC SQL connect to REGRESSDB1; |
||||
if (sqlca.sqlcode) |
||||
{ |
||||
printf ("connect error = %ld\n", sqlca.sqlcode); |
||||
exit (sqlca.sqlcode); |
||||
} |
||||
|
||||
EXEC SQL create table empl |
||||
(idnum integer, name char (20), accs smallint); |
||||
if (sqlca.sqlcode) |
||||
{ |
||||
printf ("create error = %ld\n", sqlca.sqlcode); |
||||
exit (sqlca.sqlcode); |
||||
} |
||||
|
||||
EXEC SQL insert into empl values (1, 'first user', 320); |
||||
if (sqlca.sqlcode) |
||||
{ |
||||
printf ("insert error = %ld\n", sqlca.sqlcode); |
||||
exit (sqlca.sqlcode); |
||||
} |
||||
|
||||
EXEC SQL select idnum, name, accs |
||||
into :empl |
||||
from empl |
||||
where idnum =:empl.idnum; |
||||
if (sqlca.sqlcode) |
||||
{ |
||||
printf ("select error = %ld\n", sqlca.sqlcode); |
||||
exit (sqlca.sqlcode); |
||||
} |
||||
printf ("id=%ld name=%s, accs=%d\n", empl.idnum, empl.name, empl.accs); |
||||
|
||||
EXEC SQL disconnect; |
||||
exit (0); |
||||
exec sql begin declare section; |
||||
exec sql ifdef NAMELEN; |
||||
typedef char string[NAMELEN]; |
||||
intarray amount; |
||||
char name[AMOUNT][NAMELEN]; |
||||
char letter[AMOUNT][1]; |
||||
#if 0 |
||||
int not_used; |
||||
#endif |
||||
exec sql endif; |
||||
exec sql end declare section; |
||||
int i,j; |
||||
|
||||
ECPGdebug(1, stderr); |
||||
|
||||
exec sql connect to REGRESSDB1; |
||||
|
||||
exec sql create table test (name char(NAMELEN), amount int, letter char(1)); |
||||
exec sql commit; |
||||
|
||||
exec sql insert into Test (name, amount, letter) values ('false', 1, 'f'); |
||||
exec sql insert into test (name, amount, letter) values ('true', 2, 't'); |
||||
exec sql commit; |
||||
|
||||
exec sql select * into :name, :amount, :letter from test; |
||||
|
||||
for (i=0, j=sqlca.sqlerrd[2]; i<j; i++) |
||||
{ |
||||
exec sql begin declare section; |
||||
char n[8], l = letter[i][0]; |
||||
int a = amount[i]; |
||||
exec sql end declare section; |
||||
|
||||
strncpy(n, name[i], NAMELEN); |
||||
printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l); |
||||
} |
||||
|
||||
exec sql drop table test; |
||||
exec sql commit; |
||||
exec sql disconnect; |
||||
|
||||
return (0); |
||||
} |
||||
|
@ -0,0 +1,78 @@ |
||||
#include <stdio.h> |
||||
#include <stdlib.h> |
||||
|
||||
EXEC SQL include ../regression; |
||||
|
||||
EXEC SQL typedef long mmInteger; |
||||
EXEC SQL typedef char mmChar; |
||||
EXEC SQL typedef short mmSmallInt; |
||||
|
||||
exec sql type string is char[11]; |
||||
typedef char string[11]; |
||||
|
||||
exec sql type c is char reference; |
||||
typedef char* c; |
||||
|
||||
EXEC SQL BEGIN DECLARE SECTION; |
||||
struct TBempl |
||||
{ |
||||
mmInteger idnum; |
||||
mmChar name[21]; |
||||
mmSmallInt accs; |
||||
}; |
||||
EXEC SQL END DECLARE SECTION; |
||||
|
||||
int |
||||
main (void) |
||||
{ |
||||
EXEC SQL BEGIN DECLARE SECTION; |
||||
struct TBempl empl; |
||||
string str; |
||||
c ptr = NULL; |
||||
struct varchar_vc |
||||
{ |
||||
int len; |
||||
char text[10]; |
||||
} vc; |
||||
EXEC SQL END DECLARE SECTION; |
||||
|
||||
EXEC SQL var vc is varchar[10]; |
||||
ECPGdebug (1, stderr); |
||||
|
||||
empl.idnum = 1; |
||||
EXEC SQL connect to REGRESSDB1; |
||||
if (sqlca.sqlcode) |
||||
{ |
||||
printf ("connect error = %ld\n", sqlca.sqlcode); |
||||
exit (sqlca.sqlcode); |
||||
} |
||||
|
||||
EXEC SQL create table empl |
||||
(idnum integer, name char(20), accs smallint, string1 char(10), string2 char(10), string3 char(10)); |
||||
if (sqlca.sqlcode) |
||||
{ |
||||
printf ("create error = %ld\n", sqlca.sqlcode); |
||||
exit (sqlca.sqlcode); |
||||
} |
||||
|
||||
EXEC SQL insert into empl values (1, 'user name', 320, 'first str', 'second str', 'third str'); |
||||
if (sqlca.sqlcode) |
||||
{ |
||||
printf ("insert error = %ld\n", sqlca.sqlcode); |
||||
exit (sqlca.sqlcode); |
||||
} |
||||
|
||||
EXEC SQL select idnum, name, accs, string1, string2, string3 |
||||
into :empl, :str, :ptr, :vc |
||||
from empl |
||||
where idnum =:empl.idnum; |
||||
if (sqlca.sqlcode) |
||||
{ |
||||
printf ("select error = %ld\n", sqlca.sqlcode); |
||||
exit (sqlca.sqlcode); |
||||
} |
||||
printf ("id=%ld name='%s' accs=%d str='%s' ptr='%s' vc='%10.10s'\n", empl.idnum, empl.name, empl.accs, str, ptr, vc.text); |
||||
|
||||
EXEC SQL disconnect; |
||||
exit (0); |
||||
} |
@ -0,0 +1,97 @@ |
||||
#include <stdlib.h> |
||||
#include <string.h> |
||||
|
||||
exec sql include ../regression; |
||||
|
||||
exec sql whenever sqlerror sqlprint; |
||||
|
||||
exec sql type c is char reference; |
||||
typedef char* c; |
||||
|
||||
exec sql type ind is union { int integer; short smallint; }; |
||||
typedef union { int integer; short smallint; } ind; |
||||
|
||||
#define BUFFERSIZ 8 |
||||
exec sql type str is varchar[BUFFERSIZ]; |
||||
|
||||
exec sql declare cur cursor for |
||||
select name, born, age, married, children from family; |
||||
|
||||
int |
||||
main (void) |
||||
{ |
||||
exec sql struct birthinfo { long born; short age; }; |
||||
exec sql begin declare section; |
||||
struct personal_struct { str name; |
||||
struct birthinfo birth; |
||||
} personal, *p; |
||||
struct personal_indicator { int ind_name; |
||||
struct birthinfo ind_birth; |
||||
} ind_personal, *i; |
||||
ind ind_children; |
||||
exec sql end declare section; |
||||
|
||||
exec sql char *married = NULL; |
||||
exec sql long ind_married; |
||||
exec sql ind children; |
||||
|
||||
char msg[128]; |
||||
|
||||
ECPGdebug(1, stderr); |
||||
|
||||
strcpy(msg, "connect"); |
||||
exec sql connect to REGRESSDB1; |
||||
|
||||
strcpy(msg, "create"); |
||||
exec sql create table family(name char(8), born integer, age smallint, married date, children integer); |
||||
|
||||
strcpy(msg, "insert"); |
||||
exec sql insert into family(name, married, children) values ('Mum', '19870714', 3); |
||||
exec sql insert into family(name, born, married, children) values ('Dad', '19610721', '19870714', 3); |
||||
exec sql insert into family(name, age) values ('Child 1', 16); |
||||
exec sql insert into family(name, age) values ('Child 2', 14); |
||||
exec sql insert into family(name, age) values ('Child 3', 9); |
||||
|
||||
strcpy(msg, "commit"); |
||||
exec sql commit; |
||||
|
||||
strcpy(msg, "open"); |
||||
exec sql open cur; |
||||
|
||||
exec sql whenever not found do break; |
||||
|
||||
p=&personal; |
||||
i=&ind_personal; |
||||
memset(i, 0, sizeof(ind_personal)); |
||||
while (1) { |
||||
strcpy(msg, "fetch"); |
||||
exec sql fetch cur into :p:i, :married:ind_married, :children.integer:ind_children.smallint; |
||||
printf("%8.8s", personal.name.arr); |
||||
if (i->ind_birth.born >= 0) |
||||
printf(", born %ld", personal.birth.born); |
||||
if (i->ind_birth.age >= 0) |
||||
printf(", age = %d", personal.birth.age); |
||||
if (ind_married >= 0) |
||||
printf(", married %s", married); |
||||
if (ind_children.smallint >= 0) |
||||
printf(", children = %d", children.integer); |
||||
putchar('\n'); |
||||
|
||||
free(married); |
||||
married = NULL; |
||||
} |
||||
|
||||
strcpy(msg, "close"); |
||||
exec sql close cur; |
||||
|
||||
strcpy(msg, "drop"); |
||||
exec sql drop table family; |
||||
|
||||
strcpy(msg, "commit"); |
||||
exec sql commit; |
||||
|
||||
strcpy(msg, "disconnect"); |
||||
exec sql disconnect; |
||||
|
||||
return (0); |
||||
} |
Loading…
Reference in new issue