pictures & postgresql

Forum related to PostgreSQL

Moderators: gto, cipto_kh, EgonHugeist, olehs

Post Reply
jose fermin
Fresh Boarder
Fresh Boarder
Posts: 12
Joined: 27.03.2007, 14:35

pictures & postgresql

Post by jose fermin »

How friends!!

I have the follow problem:

I created a table using postgresql

CREATE TABLE prueba
(
id serial NOT NULL,
picture bytea,
PRIMARY KEY (id)
) ;

and I have a picture in c:\pictures\mypicture.jpg

insert into prueba(picture)
values('c/pictures/mypicture.jpg');

But, I can't show the pictures in DBGrid. I used DBImage too, but nothing happend.

How can I show the pictures??

Thanks!!
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Hi Jose,

I think you just stored some string (file name) into the picture field. So don't try any longer to display pictures from this field. The coding you need to do the insert has to do something with BLOB values, I believe. I never did it myself, so :

'Anybody around who stored blobs using zeoslib?'

Mark
Image
User avatar
cipto_kh
Senior Boarder
Senior Boarder
Posts: 83
Joined: 28.09.2005, 11:22
Location: Indonesia
Contact:

Post by cipto_kh »

Try to look in here (but in that article I use Firebird, but I think same solution with MySQL):
ZeosDBO BLOB
User avatar
aebi
Fresh Boarder
Fresh Boarder
Posts: 24
Joined: 02.05.2006, 10:26

Post by aebi »

Hi,

I try to use "bytea" - but with some problems at the moment (PostgreSQL 8.1, Zeos 6.5.1-alpha, Delphi 7).

What I did is :
o created a textfile with ASCII-Characters 0x00 to 0x63
o load this file into a TMemoryStream
o "post" this Stream with

TBlobField (FieldByName ('Daten')).LoadFromStream (Daten)


When I try to read this field with

TBlobField (FieldByName ('Daten')).SaveToStream (Daten)

into a TMemoryStream, the character "\" (which is inside the data, 0x5C) is missing !
Also : the original number of bytes was 100, the result only has 97. I think, the backslash is treated in a special way.

Any ideas to get a "real" binary without interpretation ?
btrewern
Expert Boarder
Expert Boarder
Posts: 193
Joined: 06.10.2005, 18:51

Post by btrewern »

See the small patch I posted here: http://zeos.firmos.at/viewtopic.php?t=1641&highlight=
I've been using it and it seems to work. Try it and see how you get on.

Regards,

Ben
User avatar
aebi
Fresh Boarder
Fresh Boarder
Posts: 24
Joined: 02.05.2006, 10:26

Post by aebi »

Hi Ben,

ok, I've tried it, but my version (8.5.1) doesn't know about "DecodeBYTEA".
Is there some compatible function ? As I saw in the source of 6.6.x, this function(s) are new !

Regards

Andreas
User avatar
aebi
Fresh Boarder
Fresh Boarder
Posts: 24
Joined: 02.05.2006, 10:26

Post by aebi »

Hi again,

for the moment I have a solution :

original :
if (GetMetadata.GetColumnType(ColumnIndex) = stAsciiStream) then

added :

if (GetMetadata.GetColumnType(ColumnIndex) = stAsciiStream) or
(GetMetadata.GetColumnType(ColumnIndex) = stBinaryStream) then

(in unit ZDbcPostgreSqlResultSet, TZPostgreSQLResultSet.GetBlob)

I will have a look if it works with other data.

Regards
Andreas
Post Reply