#include<stdio.h>
#include<string.h>
EXEC SQL BEGIN DECLARE SECTION;
char SQLSTATE[6];
char SQLMSG[256];
struct _tbl {
short number;
SQL TYPE IS BLOB(10K) image1;
SQL TYPE IS BLOB(10K) image2;
};
short number;
EXEC SQL END DECLARE SECTION;
void putmsgx(void);
short get_10_data( void * );
short set_10_data( void * );
main(void){
short execute;
struct _tbl *buff;
EXEC SQL WHENEVER SQLERROR GOTO :CONNECT_ERROR;
EXEC SQL CONNECT TO 'DB01';
buff = (struct _tbl *)malloc( sizeof( struct _tbl ) );
get_10_data( (void *)buff );
set_10_data( (void *)buff );
EXEC SQL WHENEVER SQLERROR CONTINUE;
EXEC SQL COMMIT WORK;
EXEC SQL DISCONNECT 'DB01';
return 1;
CONNECT_ERROR:
putmsgx();
return 1;
}
void putmsgx( void ) {
int i;
for ( i = sizeof(SQLMSG) - 2 ; SQLMSG[i] == ' ' ; i-- );
SQLMSG[++i] = '\0';
SQLSTATE[5]='\0';
printf( "SQLMSG:%s\n" , SQLMSG );
printf( "SQLSTATE:%s\n" , SQLSTATE );
return;
}
short get_10_data( void *data0 )
{
EXEC SQL BEGIN DECLARE SECTION;
struct _tbl *outdata;
EXEC SQL END DECLARE SECTION;
outdata = (struct _tbl *)data0;
EXEC SQL SELECT DATANO,IMAGE1,IMAGE2 INTO :outdata
FROM SCH01.TBL01;
return 0;
}
short set_10_data( void *data0 )
{
EXEC SQL BEGIN DECLARE SECTION;
struct _tbl *indata;
EXEC SQL END DECLARE SECTION;
indata = (struct _tbl *)data0;
EXEC SQL UPDATE SCH01.TBL01 SET IMAGE = :indata->image1
WHERE DATANO = :indata->number;
return 0;
}
|