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

Поиск
Список
Период
Сортировка
От Reid Thompson
Тема Could someone post a full example of using SQL & bytea to store/retrieve image data
Дата
Msg-id 3DC141F6.7080204@ateb.com
обсуждение исходный текст
Список pgsql-general
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



В списке pgsql-general по дате отправления:

Предыдущее
От: Reynard Hilman
Дата:
Сообщение: handling 20,000 connection?
Следующее
От: Fernando Nasser
Дата:
Сообщение: Re: Can't start rhdb-admin