Skip Menu |

This queue is for tickets about the DBD-DB2 CPAN distribution.

Report information
The Basics
Id: 60636
Status: resolved
Priority: 0/
Queue: DBD-DB2

People
Owner: Nobody in particular
Requestors: henrytu [...] us.ibm.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: bug
Date: Mon, 23 Aug 2010 09:55:58 -0400
To: bug-DBD-DB2 [...] rt.cpan.org
From: Henry Turco <henrytu [...] us.ibm.com>
Hello Praveen, We are in the process of migrating from DB2 v8 to DB2 v9.5 on an s390x GNU/Linux system. I installed the latest DBD module (DBD-DB2-1.79) and we are running perl v5.8.8. One of the problems I ran into was with LOB data. If you select a LOB column in an outer loop and then do another query inside the loop, the LOB ID was getting invalidated. It worked for the first row fetched, then all subsequent rows were messed up (i.e. the LOB data was coming back undefined but the other non-LOB columns were coming back fine.) After much trial and error, I decided to switch all the LOB processing to work like you had the XML processing. So I used SQLGetData() instead of SQLGetLength() and SQLGetSubString(). That way I eliminated using the LOB IDs altogether. But I was wondering if that was a bad approach? It seems to be working ok in our initial tests. But I was wondering why you didn't do it this way from the start. static SQLRETURN bind_lob_column_helper( imp_fbh_t *fbh, SQLINTEGER col_num ) { switch( fbh->dbtype ) { case SQL_CLOB: fbh->ftype = SQL_C_CHAR; break; case SQL_BLOB: fbh->ftype = SQL_C_BINARY; break; case SQL_DBCLOB: fbh->ftype = SQL_C_CHAR; break; case SQL_XML: fbh->ftype = SQL_C_BINARY; break; } fbh->rlen = fbh->bufferSize = fbh->dsize = 0; return SQL_SUCCESS; } in static int dbd_describe() I removed this: else if(SQL_BLOB == fbh->dbtype || SQL_CLOB == fbh->dbtype || SQL_DBCLOB == fbh->dbtype) { fbh->ftype = fbh->dbtype; fbh->rlen = bufferSizeRequired = fbh->dsize = fbh->prec; } else if (SQL_XML == fbh->dbtype) { fbh->ftype = SQL_C_BINARY; fbh->rlen = bufferSizeRequired = fbh->dsize = -1; } and replaced it with this: else if(SQL_CLOB == fbh->dbtype|| SQL_DBCLOB == fbh->dbtype) { fbh->ftype = SQL_C_CHAR; fbh->rlen = bufferSizeRequired = fbh->dsize = -1; } else if (SQL_XML == fbh->dbtype || SQL_BLOB == fbh->dbtype) { fbh->ftype = SQL_C_BINARY; fbh->rlen = bufferSizeRequired = fbh->dsize = -1; } static SQLRETURN get_lob_length( imp_fbh_t *fbh, SQLINTEGER col_num, SQLHANDLE hdbc ){ SQLHANDLE new_hstmt; SQLRETURN rc; if( fbh->loc_ind == SQL_NULL_DATA ) { /* If column value is NULL then set rlen to -1 and return SQL_SUCCESS */ fbh->rlen = -1; return SQL_SUCCESS; } switch( fbh->dbtype ) { case SQL_CLOB: fbh->ftype = SQL_C_CHAR; break; case SQL_BLOB: fbh->ftype = SQL_C_BINARY; break; case SQL_DBCLOB: fbh->ftype = SQL_C_CHAR; break; case SQL_XML: fbh->ftype = SQL_C_BINARY; } rc = SQLGetData( fbh->imp_sth->phstmt, col_num, fbh->ftype, NULL, 0, &fbh->rlen ); return rc; } static SQLRETURN get_lob_data( imp_fbh_t *fbh, SQLINTEGER col_num, SQLHANDLE hdbc ){ SQLRETURN rc; SQLINTEGER out_length = 0; switch( fbh->dbtype ) { case SQL_CLOB: fbh->ftype = SQL_C_CHAR; break; case SQL_BLOB: fbh->ftype = SQL_C_BINARY; break; case SQL_DBCLOB: fbh->ftype = SQL_C_CHAR; break; case SQL_XML: fbh->ftype = SQL_C_BINARY; } rc = SQLGetData( fbh->imp_sth->phstmt, col_num, fbh->ftype, fbh->buffer, fbh->bufferSize+1, &out_length ); fbh->rlen = out_length; return rc; } I was wondering if anybody else ran into this problem? I know it's a bit obscure... -Henry

Message body is not shown because it is too large.

Hi Henry, Check this bug report https://rt.cpan.org/Ticket/Display.html?id=57614 The issue you are facing is same as logged in ticket 57614. Make changes as per the suggestion in the ticket and your problem should be resolved. -- Thanks Praveen IBM OpenSource Application Development Team India Software Labs, Bangalore (India)
Marking the defect resolved. -- Thanks Praveen IBM OpenSource Application Development Team India Software Labs, Bangalore (India)