#include "WorkingDialog.h" int SaPutBlob(int vendor, char *sv, char *db, char *tab, char *col, int coltype, char *where, int totsize, void *chunk int chunksize, int flag);
SA_TEXT
for text blobs or SA_BINARY
for binary (image) blobswhere
clause that is guaranteed to return a unique row in a table when used with a select statement.totsize
.SaPutBlob
will insert data incrementally into a blob column of a single row in a given table. The flag options are:totsize
and chunksize
should be the same.BLOB_PART
flag. This flag is not necessary when using the BLOB_ALL
flag because BLOB_ALL
inserts an entire blob in one pass.SA_TEXT
as the coltype
.
To insert binary blobs, use SA_BINARY
as the coltype
.
/* Using the BLOB_ALL flag */ #include "WorkingDialog.h" ... #define SIZE 2048000 int status; char *blob; if(!(blob = (char *)malloc(SIZE))) return; read(file_descriptor, blob, SIZE); status = SaPutBlob( SGESYBASE, "CEZANNE", "pubs2", "blurbs", "copy", SA_TEXT, "where au_id = `192-748-2293'", SIZE, blob, SIZE, BLOB_ALL); free(blob); if(status == 0) printf("Success!\n"); else printf("Failure inserting blob.\n"); ...
/* Using the BLOB_PART and BLOB_DONE flags */ #include "WorkingDialog.h" ... #define SIZE 1024000 #define BIGSIZE 4*SIZE int status, i; char *blob; if(!(blob = (char *)malloc(BIGSIZE))) return; read(file_descriptor, blob, BIGSIZE); for(i = 0; i < 4; i++) { /* insert first chunk */ status = SaPutBlob( SGESYBASE, "CEZANNE", "pubs2", "blurbs", "copy", SA_TEXT, "where au_id = `192-748-2293'", BIGSIZE, blob + (i * SIZE), SIZE, BLOB_PART); if(status) { /* SaPutBlob returned failure status */ printf("Failure inserting blob.\n"); free(blob); return; } /* reset blob insertion mechanism */ SaPutBlob( SGESYBASE, "CEZANNE", "pubs2", "blurbs", "copy", SA_TEXT, "where au_id = `192-748-2293'", BIGSIZE, NULL, SIZE, BLOB_DONE); free(blob); printf("Success!\n"); ...