Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Database query problem

71 views
Skip to first unread message

bruno.b...@gmail.com

unread,
Feb 5, 2013, 8:47:11 AM2/5/13
to
Hi,

I have the following query to a MySQL server running on Linux:

con := (DBConnection new) dsn: 'Orbeon';
uid: 'orbeon'; pwd: 'xxxx';
connect.

rs := con query: 'select xml from orbeon_form_definition'.

The table "orbeon_form_definition" has 2 rows but answer an empty DBResultSet.

The problem is that XML field is a long field and the query fails here:
DBField>>asString
asString
"Private - Answer the receiver's buffer as a <String>."
^buffer copyStringFrom: 1 to: self length

buffer size is 65536 but "self length" answer 95236.

The fix is:
DBField>>asString
asString
"Private - Answer the receiver's buffer as a <String>."
^(buffer size < self length)
ifTrue: [buffer asString]
ifFalse: [buffer copyStringFrom: 1 to: self length]

It is working now, but anyone see any problem with this fix.

Regards,
Bruno

bruno.b...@gmail.com

unread,
Feb 5, 2013, 8:56:57 AM2/5/13
to
The fix only works at DBResultSet level, because now the DBResultSet is not empty.

But the xml string obtained from the DB is complete.

Still working on this.

Regards,
Bruno

bruno.b...@gmail.com

unread,
Feb 5, 2013, 8:58:52 AM2/5/13
to
But the xml string obtained from the DB is NOT complete. It was cut by the fix.

Working on this

bruno.b...@gmail.com

unread,
Feb 5, 2013, 9:07:59 AM2/5/13
to
Also i find this fix in the archieve:

DBField>>asString
"Private - Answer the receiver's buffer as a <String>."
^buffer copyStringFrom: 1 to: buffer size-1

https://groups.google.com/forum/?fromgroups=#!searchin/comp.lang.smalltalk.dolphin/DBField/comp.lang.smalltalk.dolphin/G3nNOCavMGg/_aT3HPUs2skJ

But it has the same problem is cutting the data of XML field in the DB.

Still working.

Regards,
Bruno

fxga...@gmail.com

unread,
Feb 5, 2013, 9:44:19 AM2/5/13
to
Hi Bruno:

I have bellow methods patched. Hope this helps

"Filed out from Dolphin Smalltalk X6.1"!

!DBBoundBuffer methodsFor!

bind: aDBStatement
"Private - Bind the receiver's field buffers to columns in the result table."

| hStmt |
hStmt := super bind: aDBStatement.
self contents with: columns
do:
[:eachField :eachColumn |
aDBStatement dbCheckException: (ODBCLibrary default
sqlBindCol: hStmt
columnNumber: eachColumn columnNumber
targetType: eachColumn cType
targetValuePtr: eachField fieldBuf
bufferLength: (##(2 raisedTo: 17) min: eachField fieldSize)
strLenOrInd: eachField lengthBuf)].
^hStmt! !
DBBoundBuffer setPackageFor: #bind: to: 'Dolphin Patches' !
!DBBoundBuffer categoriesFor: #bind:!operations!private! !

!DBField methodsFor!

initializeForColumn: aDBColAttr
"Private - Initialize the receiver to represent a value from
the database column described by the <DBColAttr> argument.
Answer the receiver."

lengthBuf := SDWORD fromInteger: SQL_NULL_DATA.
column := aDBColAttr.
buffer := ByteArray new: (##(2 raisedTo: 17) min: aDBColAttr lengthC).
^self! !
DBField setPackageFor: #initializeForColumn: to: 'Dolphin Patches' !
!DBField categoriesFor: #initializeForColumn:!accessing!private! !

bruno.b...@gmail.com

unread,
Feb 5, 2013, 10:51:47 AM2/5/13
to
Gallego,

It worked very well.

You save me from diging in the field initialization.

Thanks again.

Regards,
Bruno
0 new messages