Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Write a blob with ODBC : driver crashes

Write a blob with ODBC : driver crashes

From: David RIO <david.rio_at_azimail.com>
Date: Tue, 11 May 1999 09:12:24 GMT
Message-ID: <7h8s9n$l7c$1@nnrp1.deja.com>


Hello

I am using Oracle 8.0.5 and I try to write a blob using ODBC in this table

SQL> desc types_rapport;

 Name                            Null?    Type
 ------------------------------- -------- ----
 LOGIN_UTIL                      NOT NULL VARCHAR2(50)
 ID_RAP                          NOT NULL VARCHAR2(50)
 EST_PRIVE_RAP                   NOT NULL NUMBER(1)
 DESC_RAP                                 VARCHAR2(2000)
 FICHIER_RAP                              VARCHAR2(50)
 DONNEES_RAP                              BLOB


I am using Oracle ODBC driver 8.0.5.5 with NT 4. I want to read a file and send it to the blob column. As my files can be big, I dont want to read them in one time. I want to read 5ko, send this buffer to the driver and loop until the whole file as been sent. My function works fine with a long raw. But with a blob, the driver crashes in the last SQLParamData.

I have tryed to read the whole file in one time and then call SQLExecute and it works. But I dont like at all this solution.

In consequence, I have several questions : * the driver I use comes from Oracle on their ftp server but it doesn't seem to be available ont their web site (the last version on the web site ius 8.0.5.1b). Why ? Is it a beta driver ? (it doesn't work with 8.0.5.1b too) * is their a bug in my function or a problem with the driver ? Net 8 ?

Thancks a lot for your help
(please forward answer to email)

Here is my function :

#define TAILLE_BUFFER 5000

void FichierVersBdd(CString select, CString from, CString where, CFile &dest)
{

CDatabase*	db = theApp.GetConnexionODBC();
HDBC		hdbc = db->m_hdbc;
HSTMT		hstmt;

SQLRETURN	retcode;
SQLINTEGER	NumBytes;
SQLPOINTER	pToken;
SQLINTEGER	BinaryLenOrInd;

SQLCHAR		Buffer[TAILLE_BUFFER];

::SQLAllocHandle(SQL_HANDLE_STMT, hdbc, &hstmt);

CString requete;
requete.Format(SQL_UPDATE_GENERIQUE, from, select, where);

::SQLPrepare(hstmt, (unsigned char*)(LPCTSTR)requete, SQL_NTS);

::SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT,

	   SQL_C_BINARY, SQL_ORCL_BLOB,
              0, 0, (SQLPOINTER) 1, 0, &BinaryLenOrInd);

BinaryLenOrInd = SQL_LEN_DATA_AT_EXEC(0);

retcode = ::SQLExecute(hstmt);

while ( (retcode = SQLParamData(hstmt, &pToken)) == SQL_NEED_DATA)

{	if (pToken==(SQLPOINTER)1)
	while ((NumBytes=dest.Read(Buffer, TAILLE_BUFFER)) != 0) {

		::SQLPutData(hstmt, Buffer, NumBytes);

		if (NumBytes < TAILLE_BUFFER) break;
        }

}

::SQLCloseCursor(hstmt);

::SQLFreeHandle(SQL_HANDLE_STMT, hstmt);
}

--
David RIO

--== Sent via Deja.com http://www.deja.com/ ==-- ---Share what you know. Learn what you don't.--- Received on Tue May 11 1999 - 04:12:24 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US