Page 1 of 1

pictures & postgresql

Posted: 06.02.2008, 21:24
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!!

Posted: 06.02.2008, 22:50
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

Posted: 08.02.2008, 08:57
by cipto_kh
Try to look in here (but in that article I use Firebird, but I think same solution with MySQL):
ZeosDBO BLOB

Posted: 04.03.2008, 13:38
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 ?

Posted: 05.03.2008, 10:58
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

Posted: 06.03.2008, 11:59
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

Posted: 06.03.2008, 12:43
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