Could someone post a full example of using SQL & bytea to store/retrieve image data - Mailing list pgsql-general

From Reid Thompson
Subject Could someone post a full example of using SQL & bytea to store/retrieve image data
Date
Msg-id 3DC141F6.7080204@ateb.com
Whole thread Raw
List 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 by date:

Previous
From: Reynard Hilman
Date:
Subject: handling 20,000 connection?
Next
From: Fernando Nasser
Date:
Subject: Re: Can't start rhdb-admin