Could someone post a full example of using SQL & bytea to store/retrieve image data

Поиск
Список
Период
Сортировка
Искать

Could someone post a full example of using SQL & bytea to store/retrieve image data

От:
Reid Thompson <reid.thompson@ateb.com>
Дата:
Say I have a jpg image at /tmp/junk/thisimage.jpg, and I wish to use the 
ecpg preprocessor.  Can someone post an example of the embedded SQL 
required to store/retrieve said image?

Assuming CREATE TABLE images (
image_name                  VARCHAR,
binary_image                bytea
);

Is special handling required, or can I:
assuming appropriate prior declarations for variables
assuming char buffer name_buffer contains the image name(thisimage.jpg)
assuming char buffer image_buffer contains the image binary data

EXEC SQL INSERT INTO images(image_name, binary_image) VALUES 
(name_buffer, image_buffer);
     (should name_buffer/image_buffer be :name_buffer/:image_buffer ?)

EXEC SQL SELECT binary_image INTO :image_buffer FROM images WHERE 
image_name = 'thisimage.jpg';


thanks,
reid


FAQ