diff options
author | Jean-Pierre Ledure <jp@ledure.be> | 2015-11-15 17:30:12 +0100 |
---|---|---|
committer | Jean-Pierre Ledure <jp@ledure.be> | 2015-11-15 17:30:12 +0100 |
commit | 001174135b03adc513777453875a49ae23c60cae (patch) | |
tree | dd128612bc73fd6f03c3f6f1cb8a8cf675a91b44 /wizards | |
parent | 44aa71792bace19bfee54ccf95126ca964fabccf (diff) |
Access2Base - Return null values correctly in Recordset.GetRows method
Use .wasNull() rather than not trustable .IsNullable() in _getResultSetColumnValue routine
Change-Id: I1d1783841414193347cca588209153b5aa9b56cd
Diffstat (limited to 'wizards')
-rw-r--r-- | wizards/source/access2base/Utils.xba | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/wizards/source/access2base/Utils.xba b/wizards/source/access2base/Utils.xba index 3a2420e3c22c..dcc1b4cfe400 100644 --- a/wizards/source/access2base/Utils.xba +++ b/wizards/source/access2base/Utils.xba @@ -191,20 +191,17 @@ REM Modified from Roberto Benitez's BaseTools REM get the data for the column specified by ColIndex REM get type name from metadata -Dim vValue As Variant, sType As String, vDateTime As Variant -Dim bNullable As Boolean, bNull As Boolean, oValue As Object +Dim vValue As Variant, sType As String, vDateTime As Variant, oValue As Object On Local Error Goto 0 ' Disable error handler vValue = Null ' Default value if error sType = poResultSet.MetaData.getColumnTypeName(piColIndex) With poResultSet - bNullable = ( .MetaData.IsNullable(piColIndex) = com.sun.star.sdbc.ColumnValue.NULLABLE ) Select Case sType Case "ARRAY": vValue = .getArray(piColIndex) Case "BINARY", "VARBINARY", "LONGVARBINARY" Set oValue = .getBinaryStream(piColIndex) - If bNullable Then bNull = .wasNull() - If Not bNull Then vValue = CLng(oValue.getLength()) ' Return length, not content + If Not .wasNull() Then vValue = CLng(oValue.getLength()) ' Return length, not content oValue.closeInput() Case "BLOB": vValue = .getBlob(piColIndex) Case "BIT", "BOOLEAN": vValue = .getBoolean(piColIndex) @@ -212,8 +209,7 @@ Dim bNullable As Boolean, bNull As Boolean, oValue As Object Case "BYTES": vValue = .getBytes(piColIndex) Case "CLOB": vValue = .getClob(piColIndex) Case "DATE": vDateTime = .getDate(piColIndex) - If bNullable Then bNull = .wasNull() - If Not bNull Then vValue = DateSerial(CInt(vDateTime.Year), CInt(vDateTime.Month), CInt(vDateTime.Day)) + If Not .wasNull() Then vValue = DateSerial(CInt(vDateTime.Year), CInt(vDateTime.Month), CInt(vDateTime.Day)) Case "DOUBLE", "REAL": vValue = .getDouble(piColIndex) Case "FLOAT": vValue = .getFloat(piColIndex) Case "INTEGER", "SMALLINT": vValue = .getInt(piColIndex) @@ -225,18 +221,15 @@ Dim bNullable As Boolean, bNull As Boolean, oValue As Object Case "SHORT", "TINYINT": vValue = .getShort(piColIndex) Case "CHAR", "VARCHAR", "LONGVARCHAR": vValue = .getString(piColIndex) Case "TIME": vDateTime = .getTime(piColIndex) - If bNullable Then bNull = .wasNull() - If Not bNull Then vValue = TimeSerial(vDateTime.Hours, vDateTime.Minutes, vDateTime.Seconds)', vDateTime.HundredthSeconds) + If Not .wasNull() Then vValue = TimeSerial(vDateTime.Hours, vDateTime.Minutes, vDateTime.Seconds)', vDateTime.HundredthSeconds) Case "TIMESTAMP": vDateTime = .getTimeStamp(piColIndex) - If bNullable Then bNull = .wasNull() - If Not bNull Then vValue = DateSerial(CInt(vDateTime.Year), CInt(vDateTime.Month), CInt(vDateTime.Day)) _ + If Not .wasNull() Then vValue = DateSerial(CInt(vDateTime.Year), CInt(vDateTime.Month), CInt(vDateTime.Day)) _ + TimeSerial(vDateTime.Hours, vDateTime.Minutes, vDateTime.Seconds)', vDateTime.HundredthSeconds) Case Else 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 bNullable Then bNull = .wasNull() - If bNull Then vValue = Null + If .wasNull() Then vValue = Null End With _getResultSetColumnValue = vValue |