pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: lothar.behrens@lollisoft.de <lothar.behrens@lollisoft.de>
To: pgsql-odbc@postgresql.org
Subject: Long data and SQLPutData ?
Date: Tue, 07 Aug 2007 15:40:37 -0700
Message-ID: <1186526437.329947.95800@22g2000hsm.googlegroups.com> (raw)

Hi,

I need some advice how to update a BLOB column. Reading it with
SQLGetData seems to be easier :-)

Do I need the commented code to 'shift' the bigger memory block into
the bound buffer while calling
SQLParamData and SQLPutData ?

I do set multiple column data before I do a SQLSetPos. So I have bound
columns therefore.
Do I get trouble, when I update some BLOB columns in between ?

Are there other issues with that code ?

Thanks, Lothar

Here I have code developed yet:

lbErrCodes LB_STDCALL lbQuery::setBinaryData(int column,
lb_I_BinaryData* value) {
	// Declare a binary buffer to send 5000 bytes of data at a time.
	SQLCHAR       BinaryPtr[5000];
	SQLINTEGER	  longDataLen;
	SQLRETURN     rc, retcode;

       // The size may be more than 5000
	longDataLen = SQL_LEN_DATA_AT_EXEC(value->getSize());

	rc = SQLBindCol(hstmt, column, SQL_C_BINARY, (void *)BinaryPtr, 0,
&longDataLen);

	retcode = SQLSetPos(hstmt, 1, SQL_UPDATE, SQL_LOCK_NO_CHANGE);

	if (retcode == SQL_NEED_DATA)
	{
		retcode = SQLParamData(hstmt, (void **)  &BinaryPtr);
		while(retcode == SQL_NEED_DATA)
		{

/*
                    //This code should be here to 'shift' the
datapieces.

                     void* peace = value->getNextDataPiece(5000);
                     long len = value->getCurrentPieceSize();
                     memcpy(BinaryPtr, piece, len);

*/

			retcode = SQLPutData(hstmt, BinaryPtr, SQL_NTS);
			/* check for error here */
			retcode = SQLParamData(hstmt, (void **)  &BinaryPtr);
		}

	}

	return ERR_NONE;
}




Message-ID: <1186526437.329947.95800@22g2000hsm.googlegroups.com>
Permalink:  ../1186526437.329947.95800@22g2000hsm.googlegroups.com/
Also on:    postgresql.org/message-id/1186526437.329947.95800@22g2000hsm.googlegroups.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-odbc@postgresql.org
  Cc: lothar.behrens@lollisoft.de
  Subject: Re: Long data and SQLPutData ?
  In-Reply-To: <1186526437.329947.95800@22g2000hsm.googlegroups.com>
  References: <1186526437.329947.95800@22g2000hsm.googlegroups.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox