[solved] Directly using LargeObjects-examples needed!

Forum related to PostgreSQL

Moderators: gto, cipto_kh, EgonHugeist, olehs

bulba
Fresh Boarder
Fresh Boarder
Posts: 7
Joined: 12.06.2012, 20:37

[solved] Directly using LargeObjects-examples needed!

Postby bulba » 12.06.2012, 21:07

Hello,

I've have few science applications written in Python which are gathering medical data (X-Rays) and inserts them into PostgresQL 9.1 database using LargeObject interface for further processing, and they are working fine :)
I'd like to use lo_create/lo_import/lo_export with ZEOS (svn version) and Delphi XE to access and modify this data. I've took a look at the ZEOS' forum and I've found information regarding "direct call interface", the GetPlainDriver function and I've found in the ZEOS' sources functions: OpenLargeObject, TellLargeObject and so on. Great! :)

But how can I use them? There is no examples at all and I'm little bit lost :( Could you please be so nice and provide me with small example of using LargeFile interface with TZQuery, svn's ZEOS and Delphi?
Thank you in advance! :)

Bulba Nakcharashi, MD

User avatar
EgonHugeist
Zeos Dev Team
Zeos Dev Team
Posts: 1701
Joined: 31.03.2011, 22:38

Postby EgonHugeist » 12.06.2012, 21:26

bulba,

very spezial request!

What i know is that Zeos supports that large objects if you add 'oidasblob=true' to the TZConnecton.Properties. Then Zeos is able to read thes blobs and you can access them like (TZQuery.FieldByName('x-Ray') as TBlobField).SaveToStrem/LoadFromStream.

The exact answer should be:
(TZConnection.DbcConnection.GetIZPlainDriver as IZPostgreSQLPlainDriver).OpenLargeObject(Handle: PZPostgreSQLConnect; ObjId: Oid;
Mode: Integer);

But here you need some more Parameters... which you can't get so easy like this call.

Michael
King regards, Michael

You want to help? viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image

bulba
Fresh Boarder
Fresh Boarder
Posts: 7
Joined: 12.06.2012, 20:37

Postby bulba » 13.06.2012, 09:20

Well, ZEOS i really clever software! :) However as always a little bit o black magick has to be involved ;)

So here is the receipe:
1) create example table like: create table x_breast_cancer(id serial, xray oid);
2) add oidasblob=true to the ZConnection properties
3) set TransactionIsolationLevel to tiReadCommitted - VERY IMPORTANT! While playing with LargeObject Zeos in fact creates squence of commands which MUST be done in transaction, in other case it'll fail with 'unknown OID 0' message!
4) add your binary data to the OID field (in my example: 'xray') as usuall ftBlob, you'll notice then in the table in the OID field there will be a number - kind of pointer to the binary date on server
5) if you like to retrieve data just read this OID field and you'll receive binary data :)

Well, it's the easiest way to play with LargeFiles, however it's not possible to play with Seek or Tell methods this way, I'll research it further.

Michael, thank you very much for your help! :)

Bulba Nakcharashi, MD

User avatar
EgonHugeist
Zeos Dev Team
Zeos Dev Team
Posts: 1701
Joined: 31.03.2011, 22:38

Postby EgonHugeist » 13.06.2012, 09:49

bulba,

Yes that's not supported actually. And i think that was well done. If you publish these funtions either on the PGPlainDriver or on the DbcPostgreConnection interfaces then it should be possible to have this support directly. Then you can call them with a cast like i proposed before. Example: (ZConnection.DbcConnection as IZDbcPostgeConnection).Tell/Seek(Oid: integer)..

Attach a patch and we'll add it to our repositories...

Michael
King regards, Michael

You want to help? viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image


Return to “PostgreSQL”

Who is online

Users browsing this forum: No registered users and 1 guest