Received: from trantor.dso.org.sg (trantor.dso.org.sg [192.190.204.1]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id f229NMx85144 for ; Fri, 2 Mar 2001 04:23:23 -0500 (EST) (envelope-from tchikeon@dso.org.sg) Received: from doorkeeper.cs.dso.org.sg (gatekeeper.dso.org.sg [192.190.205.4]) by trantor.dso.org.sg (8.10.2/8.10.2) with ESMTP id f229NqD25438 for ; Fri, 2 Mar 2001 17:23:53 +0800 (SGT) Message-Id: <4.3.2.7.0.20010302165758.00a91950@192.168.1.204> X-Sender: tchikeon@192.168.1.204 X-Mailer: QUALCOMM Windows Eudora Version 4.3.2 Date: Fri, 02 Mar 2001 17:22:03 +0800 To: pgsql-interfaces@postgresql.org From: Raymond Subject: Large Object through ODBC In-Reply-To: References: <200103012254.RAA25630@candle.pha.pa.us> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="=====================_30315810==_.ALT" X-Archive-Number: 200103/16 X-Sequence-Number: 1177 --=====================_30315810==_.ALT Content-Type: text/plain; charset="us-ascii"; format=flowed hi, i'm a newbie to PostgresQL, currently trying to use the ODBC driver. i'm connecting from my Win98 machine to a PostgresQL installation on a Linux box. i'm trying out the sample code from the MSDN concerning sending large objects through ODBC but i cannot get the code to work. What i did is create a test table with (id int, obj lo) and then just try to insert some data into it. The strange things is that after the executestatement, it does not even return a SQL_NEED_DATA even though i have binded the parameter to a SQL_LONGVARBINARY. it just finished with the executino and over at the database side, an empty large object is created, i've attached the code and logs from the ODBC driver below. Hope someone can point out what am i doing wrong here. Thanks! Code ----------------------------- retcode = SQLPrepare ( hstmt, (unsigned char*)"INSERT INTO a (id , obj) VALUES ( ? , ? ) ",SQL_NTS ); SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_ULONG, SQL_INTEGER, 0, 0, &sID, 0, &cbID); SQLBindParameter(hstmt, 2, SQL_PARAM_INPUT, SQL_C_BINARY, SQL_LONGVARBINARY, 0, 0, (SQLPOINTER)2, 0, &cbObj); cbObj = SQL_LEN_DATA_AT_EXEC(0); sID = 1; retcode = SQLExecute(hstmt); if (retcode == SQL_NEED_DATA) { printf("Need Data\n"); } ----------------------------- Log ----------------------------- conn=15272060, SQLDriverConnect( in)='DSN=POSTGRESQL;', DriverCompletion=0 DSN info: DSN='POSTGRESQL',onlyread='0',protocol='6.4',showoid='1',fakeoidindex='0',showsystable='0' conn_settings='' translation_dll='',translation_option='' Global Options: Version='06.50.0000', fetch=100, socket=4096, unknown_sizes=0, max_varchar_size=254, max_longvarchar_size=8190, disable_optimizer=1, ksqo=1, unique_index=0, use_declarefetch=0, text_as_longvarchar=1, unknowns_as_longvarchar=0, bools_as_char=1, extra_systable_prefixes='dd_;', conn_settings='' conn=15272060, query=' ' conn=15272060, query='set DateStyle to 'ISO'' conn=15272060, query='set geqo to 'OFF'' conn=15272060, query='set ksqo to 'ON'' conn=15272060, query='select oid from pg_type where typname='lo'' [ fetched 1 rows ] [ Large Object oid = 350752 ] conn=15272060, SQLDriverConnect(out)='DSN=POSTGRESQL;DATABASE=test;READONLY=0;PROTOCOL=6.4;FAKEOIDINDEX=0;SHOWOIDCOLUMN=1;ROWVERSIONING=0;SHOWSYSTEMTABLES=0;CONNSETTINGS=' conn=15272060, query='BEGIN' conn=15272060, query='COMMIT' conn=15272060, query='BEGIN' conn=15272060, query='INSERT INTO a (id , obj) VALUES ( 100 , '4157953' ) ' conn=15272060, query='COMMIT' conn=15272060, SQLDisconnect ----------------------------- --=====================_30315810==_.ALT Content-Type: text/html; charset="us-ascii" hi,
        i'm a newbie to PostgresQL, currently trying to use the ODBC driver. i'm connecting from my Win98 machine to a PostgresQL installation on a Linux box. i'm trying out the sample code from the MSDN concerning sending large objects through ODBC but i cannot get the code to work.    

        What i did is create a test table with (id int, obj lo) and then just try to insert some data into it. The strange things is that after the executestatement, it does not even return a SQL_NEED_DATA even though i have binded the parameter to a SQL_LONGVARBINARY. it just finished with the executino and over at the database side, an empty large object is created, i've attached the code and logs from the ODBC driver below. Hope someone can point out what am i doing wrong here. Thanks!

Code
-----------------------------
retcode = SQLPrepare ( hstmt, (unsigned char*)"INSERT INTO a (id , obj) VALUES ( ? , ? ) ",SQL_NTS );
SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_ULONG, SQL_INTEGER, 0, 0, &sID, 0, &cbID);
SQLBindParameter(hstmt, 2, SQL_PARAM_INPUT, SQL_C_BINARY, SQL_LONGVARBINARY, 0, 0, (SQLPOINTER)2, 0, &cbObj);

cbObj = SQL_LEN_DATA_AT_EXEC(0);                
sID = 1;
                        
retcode = SQLExecute(hstmt);       
        
if (retcode == SQL_NEED_DATA) {
        printf("Need Data\n");
}
-----------------------------

Log
-----------------------------
conn=15272060, SQLDriverConnect( in)='DSN=POSTGRESQL;', DriverCompletion=0
DSN info: DSN='POSTGRESQL',onlyread='0',protocol='6.4',showoid='1',fakeoidindex='0',showsystable='0'
          conn_settings='' translation_dll='',translation_option=''
Global Options: Version='06.50.0000', fetch=100, socket=4096, unknown_sizes=0, max_varchar_size=254, max_longvarchar_size=8190, disable_optimizer=1, ksqo=1, unique_index=0, use_declarefetch=0, text_as_longvarchar=1, unknowns_as_longvarchar=0, bools_as_char=1, extra_systable_prefixes='dd_;', conn_settings=''
conn=15272060, query=' '
conn=15272060, query='set DateStyle to 'ISO''
conn=15272060, query='set geqo to 'OFF''
conn=15272060, query='set ksqo to 'ON''
conn=15272060, query='select oid from pg_type where typname='lo''
    [ fetched 1 rows ]
    [ Large Object oid = 350752 ]
conn=15272060, SQLDriverConnect(out)='DSN=POSTGRESQL;DATABASE=test;READONLY=0;PROTOCOL=6.4;FAKEOIDINDEX=0;SHOWOIDCOLUMN=1;ROWVERSIONING=0;SHOWSYSTEMTABLES=0;CONNSETTINGS='
conn=15272060, query='BEGIN'
conn=15272060, query='COMMIT'
conn=15272060, query='BEGIN'
conn=15272060, query='INSERT INTO a (id , obj) VALUES ( 100 , '4157953' ) '
conn=15272060, query='COMMIT'
conn=15272060, SQLDisconnect
----------------------------- --=====================_30315810==_.ALT--