Skip site navigation (1) Skip section navigation (2)

ODBC, Delphi and BLOBs (images)

From: "Andrzej Szydlo" <andrzej(at)gv(dot)edu(dot)pl>
To: pgsql-interfaces(at)hub(dot)org
Subject: ODBC, Delphi and BLOBs (images)
Date: 1998-08-18 13:39:21
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-interfaces

I'm trying to access PostgreSQL database from Delphi via ODBC. 
Everything works fast and reliably. The only problem are BLOBs, 
images in this case.

I created the "lo" type according to the FAQ:

     create type lo (
     internallength=4,  externallength=10,
     input=int4in, output=int4out,
     default='',  passedbyvalue

and then created a table and an index:
CREATE TABLE test_tab(nr int4, img lo);
CREATE UNIQUE INDEX test_inx ON test_tab (nr);

I attached a DBImage control to the "img" field and DBEdit to "nr"

When I insert "images" to the table manually (copy a *.bmp image file 
to an appropiate file and insert an appropriate number to the table) 
Delphi displays it without any problem.

When I try to insert any image from Dephi, the value "0" is inserted 
instead of an object number, which causes

 "Unrecognized return value from copy_and_convert_field."

on a select attempt.

What can  causes "0" to be inserted instead of any value, say 16648?
Have anyone ever had similar problem? How can it be solved?

It seems that the problem is caused by the Delphi-ODBC interaction. 
With Access everything works well.

If the information I gave here is not precise enough or unclear, 
please ask me any for extra details. I'd appreciate any suggestions 
pointing me to the right direction.

Here are software versions and logs:

Delphi: 2.0
BDE: 4.51
Postgres - ODBC: 6.30.0248
Postgres: 6.3.2
ODBC Admin:

In case of UPDATE the psqlodbc.log looks like this:

conn=44173436, query='SELECT "img" FROM "test_tab" WHERE "nr"=255'
    [ fetched 1 rows ]
conn=44173436, query='BEGIN'
conn=44173436, query='UPDATE "test_tab" SET "img"=0 WHERE "nr"=255'
                                             why 0?
conn=44173436, query='COMMIT'
conn=44173436, query='SELECT "img" FROM "test_tab" WHERE "nr"=255'
    [ fetched 1 rows ]
STATEMENT ERROR: func=SQLFetch, desc='', errnum=8, errmsg='Unrecognized return
value from copy_and_convert_field.'


pgsql-interfaces by date

Next:From: Thomas G. LockhartDate: 1998-08-18 15:07:02
Subject: iodbc interface on Unix
Previous:From: Dr. HerreraDate: 1998-08-18 08:33:31
Subject: Query size limit using JDBC?

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group