Question
A sample ESQL/C program to insert data into a BLOB (TEXT) column using ESQL/C.
Answer
The attached program can be used as a reference for understanding the locator structure and how one can insert blob data via an ESQL/C program. This program is meant to be used only as a reference and no error checking has been taken into consideration. For example, the program will not check if the specified col1 number is valid or not. It is up to the programmer to put error checks into the code.
The Locator Structure
In an ESQL/C program, a locator structure is used to access simple-large-object values. The locator structure is the host variable for TEXT and BYTE columns when they are stored in or retrieved from the database. This structure describes the location of a simple-large-object value for the following two database operations:
- When the program inserts the simple large object into the database, the locator structure identifies the source of the simple-large-object data to insert.
- When the program selects the simple large object from the database, the locator structure identifies the destination of the simple-large-object data.
The locator.h header file defines the locator structure, called loc_t. ESQL/C does not automatically include the locator.h header file in an ESQL/C program. The locator.h header file must be explicitly included in any ESQL/C program that defines simple-large-object variables.
The loc_loctype identifies the location of the simple large object data. When you setloc_bufsize to -1, ESQL/C allocates the memory buffer on a fetch or select. ESQL/C uses themalloc() system call to allocate the memory buffer to hold a single simple-large-object value.
Compilation
- 1. Save the attached program as getblob.ec.
2. Compile using the following syntax:
- esql putblob.ec -o putblob
- > putblob
Enter a Catalog number :1
Enter the description :
Test insert
Successful insert
Disclaimer: This code has been tested on Solaris only. Behavior on any other operating system is not guaranteed. |
'Informix > informix reference' 카테고리의 다른 글
Determining how many CPUs you have under AIX (0) | 2013.04.02 |
---|---|
(작성중) (0) | 2013.02.20 |
How to determine the number of concurrent connection/users on Informix server? (0) | 2013.01.29 |
Using Informix Dynamic Server backup and restore filters (0) | 2013.01.15 |
How to check the real memory used by locks in different Informix Server versions (0) | 2012.11.18 |