November 09 2011
How to test INSERT/UPDATE in Informix BYTE column?
Tagged Under : BLOB, blobload, BYTE, Client-SDK, CSDK, Informix, INSERT, UPDATE
Question:
How to test INSERT/UPDATE in Informix BYTE column?
Preparation:
1. Informix IDS is online and running
2. Informix Client-SDK installed
3. Prepare 2 object files (image1.pdf, image2.pdf)
4. create table testbyte1 (num integer,
file byte);
create unique index byte_idx1 on testbyte1(num) ;
5. Compile “blobload” utility.
– set environment variable $INFORMIXDIR
(where CSDK installed)
– set environment variable PATH=$INFORMIXDIR/bin:$PATH
– you may find “blobload.ec” in $INFORMIXDIR/demo/esqlc
– compile “esql -o blobload blobload.ec”, will get executable binary “blobload”
Test INSERT/UPDATE BYTE column:
6. To get syntax on usage, just type “./blobload”
Usage: blobload {-i | -u} — choose insert or update
-f filename — file containing the blob data
-d database_name — database to open
-t table_name — table to modify
-b blob_column — name of target column
-k key_column key_value — name of key column and a value
-v — verbose documentary output
All parameters except -v are required.
Parameters may be given in any order.
As many as 8 -k parameter pairs may be specified.
7. INSERT BYTE testing.
$ ./blobload -i -f ./image1.pdf -d mytestdb -t testbyte -b file -k num 1001 -v
prepared stmt =
INSERT INTO testblob1( file, num) VALUES( ?, “1001”);
1 row(s) inserted.
8. UPDATE BYTE testing.
$ ./blobload -u -f ./image2.pdf -d mytestdb -t testbyte -b file -k num 1001 -v
prepared stmt =
UPDATE testblob1 SET file = ? WHERE num = “1001”;
1 row(s) updated.
9. Check number of rows:
SQL> select * from testbyte1;
num 1001
file
1 row(s) retrieved.