summaryrefslogtreecommitdiff
path: root/wizards/source/access2base/Utils.xba
diff options
context:
space:
mode:
Diffstat (limited to 'wizards/source/access2base/Utils.xba')
-rw-r--r--wizards/source/access2base/Utils.xba55
1 files changed, 46 insertions, 9 deletions
diff --git a/wizards/source/access2base/Utils.xba b/wizards/source/access2base/Utils.xba
index 6f9135cce559..8390deea6045 100644
--- a/wizards/source/access2base/Utils.xba
+++ b/wizards/source/access2base/Utils.xba
@@ -198,28 +198,48 @@ Dim oPip As Object, sLocation As String
End Function ' ExtensionLocation
REM -----------------------------------------------------------------------------------------------------------------------
-Private Function _getResultSetColumnValue(poResultSet As Object, Byval piColIndex As Integer) As Variant
+Private Function _getResultSetColumnValue(poResultSet As Object _
+ , ByVal piColIndex As Integer _
+ , Optional ByVal pbReturnBinary As Boolean _
+ ) As Variant
REM Modified from Roberto Benitez's BaseTools
REM get the data for the column specified by ColIndex
+REM If pbReturnBinary = False (default) then return length of binary field
REM get type name from metadata
Dim vValue As Variant, sType As String, vDateTime As Variant, oValue As Object
+Dim bNullable As Boolean, lSize As Long
+Const cstMaxTextLength = 65535
+Const cstMaxBinlength = 2 * 65535
On Local Error Goto 0 ' Disable error handler
vValue = Null ' Default value if error
- sType = poResultSet.MetaData.getColumnTypeName(piColIndex)
+ If IsMissing(pbReturnBinary) Then pbReturnBinary = False
With poResultSet
+ sType = .MetaData.getColumnTypeName(piColIndex)
+ bNullable = ( .MetaData.IsNullable(piColIndex) = com.sun.star.sdbc.ColumnValue.NULLABLE )
Select Case sType
Case "ARRAY": vValue = .getArray(piColIndex)
- Case "BINARY", "VARBINARY", "LONGVARBINARY"
+ Case "BINARY", "VARBINARY", "LONGVARBINARY", "BLOB"
Set oValue = .getBinaryStream(piColIndex)
- If Not .wasNull() Then vValue = CLng(oValue.getLength()) ' Return length, not content
+ If bNullable Then
+ If Not .wasNull() Then
+ If Not _hasUNOMethod(oValue, "getLength") Then ' When no recordset
+ lSize = cstMaxBinLength
+ Else
+ lSize = CLng(oValue.getLength())
+ End If
+ If lSize <= cstMaxBinLength And pbReturnBinary Then
+ vValue = Array()
+ oValue.readBytes(vValue, lSize)
+ Else ' Return length of field, not content
+ End If
+ End If
+ End If
oValue.closeInput()
- Case "BLOB": vValue = .getBlob(piColIndex)
Case "BIT", "BOOLEAN": vValue = .getBoolean(piColIndex)
Case "BYTE": vValue = .getByte(piColIndex)
Case "BYTES": vValue = .getBytes(piColIndex)
- Case "CLOB": vValue = .getClob(piColIndex)
Case "DATE": vDateTime = .getDate(piColIndex)
If Not .wasNull() Then vValue = DateSerial(CInt(vDateTime.Year), CInt(vDateTime.Month), CInt(vDateTime.Day))
Case "DOUBLE", "REAL": vValue = .getDouble(piColIndex)
@@ -231,7 +251,22 @@ Dim vValue As Variant, sType As String, vDateTime As Variant, oValue As Object
Case "OBJECT": vValue = Null ' .getObject(piColIndex) does not work that well in Basic ...
Case "REF": vValue = .getRef(piColIndex)
Case "SHORT", "TINYINT": vValue = .getShort(piColIndex)
- Case "CHAR", "VARCHAR", "LONGVARCHAR": vValue = .getString(piColIndex)
+ Case "CHAR", "VARCHAR": vValue = .getString(piColIndex)
+ Case "LONGVARCHAR", "CLOB"
+ Set oValue = .getCharacterStream(piColIndex)
+ If bNullable Then
+ If Not .wasNull() Then
+ If Not _hasUNOMethod(oValue, "getLength") Then ' When no recordset
+ lSize = cstMaxTextLength
+ Else
+ lSize = CLng(oValue.getLength())
+ End If
+ oValue.closeInput()
+ If lSize <= cstMaxBinLength Then vValue = .getString(piColIndex) Else vValue = ""
+ End If
+ Else
+ oValue.closeInput()
+ End If
Case "TIME": vDateTime = .getTime(piColIndex)
If Not .wasNull() Then vValue = TimeSerial(vDateTime.Hours, vDateTime.Minutes, vDateTime.Seconds)', vDateTime.HundredthSeconds)
Case "TIMESTAMP": vDateTime = .getTimeStamp(piColIndex)
@@ -241,12 +276,14 @@ Dim vValue As Variant, sType As String, vDateTime As Variant, oValue As Object
vValue = .getString(piColIndex) 'GIVE STRING A TRY
If IsNumeric(vValue) Then vValue = Val(vValue) 'Required when type = "", sometimes numeric fields are returned as strings (query/MSAccess)
End Select
- If .wasNull() Then vValue = Null
+ If bNullable Then
+ If .wasNull() Then vValue = Null
+ End If
End With
_getResultSetColumnValue = vValue
-End Function ' getResultSetColumnValue V 1.1.0
+End Function ' getResultSetColumnValue V 1.5.0
REM -----------------------------------------------------------------------------------------------------------------------
Public Function _FinalProperty(psShortcut As String) As String