Search Postgresql Archives

Re: How to store and load images in PostgreSQL db?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



It may be as simple as making sure that:

bytea_output = escape

is present in postgresql.conf

9.0 changed the default to hex

No idea on the Table/Query aspect but at least in JDBC query parameters are
generic (i.e., "?") and you tell the API what type of value is being sent -
letting the API do the appropriate conversions.  Occasionally putting an
explicit cast on the parameter (i.e., ?::int) can be handy if you are
dealing with, say, strings in code but the parameter needs to be something
else.

If necessary you could decode your image into some textual representation
and then encode into back into binary once it is in the server (using
appropriate PostgreSQL functions).

David J.

> (PSQLTable1 is on the form.)
> This works fine until the Post procedure is called. A db error near "\"
> appears.
> 
> Instead of using a table I would rather use a Query, but I can't get to
work
> that at all.
> 
>   Query := TPSQLQuery.Create(nil);
>   Query.DataBase := Db;
>   BlobField := TBlobField.Create(nil);
>   try
>     BlobField.LoadFromFile('picture.bmp');
>     Query.SQL.Text := Format ('insert into "tblImage" ("Picture_Bytea")
values
> (%s)', [QuotedStr(BlobField.Value)]);
>     Query.Open;
>   finally
>     Query.Free;
>     BlobField.Free;
>   end;
> 
> Apparantly it is not allowed to create a TBlobField this way and I don't
think
> it's a good idea to format a bytea-field as a string (%s) either.
> 
> Sorry for my newbie question. I hope someone will be able to point me in
> the right direction to get this working as I have been searching all over
the
> internet, but have not been able to find a solution. Even finding a
correct
> forum to post this question is difficult as there does not seem to be a
> PostgreSQL forum for Delphi users.
> 
> Thanks in advance!
> 
> --
> View this message in context:
> http://postgresql.1045698.n5.nabble.com/How-to-store-and-load-images-
> in-PostgreSQL-db-tp4424778p4424778.html
> Sent from the PostgreSQL - general mailing list archive at Nabble.com.
> 
> --
> Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make
> changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux