Kaydet (Commit) fd336cf9 authored tarafından Jean-Pierre Ledure's avatar Jean-Pierre Ledure

Access2Base - PATCH-01 Field.setValue

setValue gives erroneously an error message when argument is Null and field is nullable
https://forum.openoffice.org/en/forum/viewtopic.php?f=47&t=61447&sid=48e231a12084933d9da1b47e50b186ea#p323714

Change-Id: Ic96e50f4c752f5fa38e8f40e80692f166fd88e4a
üst bfd2e828
......@@ -523,86 +523,87 @@ Dim oParent As Object
With com.sun.star.sdbc.DataType
If IsNull(pvValue) Then
If Column.IsNullable = com.sun.star.sdbc.ColumnValue.NULLABLE Then Column.updateNull() Else Goto Trace_Null
End If
Select Case Column.Type
Case .BIT, .BOOLEAN
If Not Utils._CheckArgument(pvValue, iArgNr, vbBoolean, , False) Then Goto Trace_Error_Value
Column.updateBoolean(pvValue)
Case .TINYINT
If Not Utils._CheckArgument(pvValue, iArgNr, Utils._AddNumeric(), , False) Then Goto Trace_Error_Value
If pvValue < -128 Or pvValue > +127 Then Goto Trace_Error_Value
Column.updateShort(CInt(pvValue))
Case .SMALLINT
If Not Utils._CheckArgument(pvValue, iArgNr, Utils._AddNumeric(), , False) Then Goto Trace_Error_Value
If pvValue < -32768 Or pvValue > 32767 Then Goto trace_Error_Value
Column.updateInt(CLng(pvValue))
Case .INTEGER
If Not Utils._CheckArgument(pvValue, iArgNr, Utils._AddNumeric(), , False) Then Goto Trace_Error_Value
If pvValue < -2147483648 Or pvValue > 2147483647 Then Goto trace_Error_Value
Column.updateInt(CLng(pvValue))
Case .BIGINT
If Not Utils._CheckArgument(pvValue, iArgNr, Utils._AddNumeric(), , False) Then Goto Trace_Error_Value
Column.updateLong(pvValue) ' No proper type conversion for HYPER data type
Case .FLOAT
If Not Utils._CheckArgument(pvValue, iArgNr, Utils._AddNumeric(), , False) Then Goto Trace_Error_Value
If Abs(pvValue) < 3.402823E38 And Abs(pvValue) > 1.401298E-45 Then Column.updateFloat(CSng(pvValue)) Else Goto trace_Error_Value
Case .REAL, .DOUBLE
If Not Utils._CheckArgument(pvValue, iArgNr, Utils._AddNumeric(), , False) Then Goto Trace_Error_Value
'If Abs(pvValue) < 1.79769313486232E308 And Abs(pvValue) > 4.94065645841247E-307 Then Column.updateDouble(CDbl(pvValue)) Else Goto trace_Error_Value
Column.updateDouble(CDbl(pvValue))
Case .NUMERIC, .DECIMAL
If Not Utils._CheckArgument(pvValue, iArgNr, Utils._AddNumeric(), , False) Then Goto Trace_Error_Value
If Utils._hasUNOProperty(Column, "Scale") Then
If Column.Scale > 0 Then
'If Abs(pvValue) < 1.79769313486232E308 And Abs(pvValue) > 4.94065645841247E-307 Then Column.updateDouble(CDbl(pvValue)) Else Goto trace_Error_Value
Column.updateDouble(CDbl(pvValue))
Else
Select Case Column.Type
Case .BIT, .Boolean
If Not Utils._CheckArgument(pvValue, iArgNr, vbBoolean, , False) Then Goto Trace_Error_Value
Column.updateBoolean(pvValue)
Case .TINYINT
If Not Utils._CheckArgument(pvValue, iArgNr, Utils._AddNumeric(), , False) Then Goto Trace_Error_Value
If pvValue < -128 Or pvValue > +127 Then Goto Trace_Error_Value
Column.updateShort(CInt(pvValue))
Case .SMALLINT
If Not Utils._CheckArgument(pvValue, iArgNr, Utils._AddNumeric(), , False) Then Goto Trace_Error_Value
If pvValue < -32768 Or pvValue > 32767 Then Goto trace_Error_Value
Column.updateInt(CLng(pvValue))
Case .Integer
If Not Utils._CheckArgument(pvValue, iArgNr, Utils._AddNumeric(), , False) Then Goto Trace_Error_Value
If pvValue < -2147483648 Or pvValue > 2147483647 Then Goto trace_Error_Value
Column.updateInt(CLng(pvValue))
Case .BIGINT
If Not Utils._CheckArgument(pvValue, iArgNr, Utils._AddNumeric(), , False) Then Goto Trace_Error_Value
Column.updateLong(pvValue) ' No proper type conversion for HYPER data type
Case .FLOAT
If Not Utils._CheckArgument(pvValue, iArgNr, Utils._AddNumeric(), , False) Then Goto Trace_Error_Value
If Abs(pvValue) < 3.402823E38 And Abs(pvValue) > 1.401298E-45 Then Column.updateFloat(CSng(pvValue)) Else Goto trace_Error_Value
Case .REAL, .Double
If Not Utils._CheckArgument(pvValue, iArgNr, Utils._AddNumeric(), , False) Then Goto Trace_Error_Value
'If Abs(pvValue) < 1.79769313486232E308 And Abs(pvValue) > 4.94065645841247E-307 Then Column.updateDouble(CDbl(pvValue)) Else Goto trace_Error_Value
Column.updateDouble(CDbl(pvValue))
Case .NUMERIC, .DECIMAL
If Not Utils._CheckArgument(pvValue, iArgNr, Utils._AddNumeric(), , False) Then Goto Trace_Error_Value
If Utils._hasUNOProperty(Column, "Scale") Then
If Column.Scale > 0 Then
'If Abs(pvValue) < 1.79769313486232E308 And Abs(pvValue) > 4.94065645841247E-307 Then Column.updateDouble(CDbl(pvValue)) Else Goto trace_Error_Value
Column.updateDouble(CDbl(pvValue))
Else
Column.updateString(CStr(pvValue))
End If
Else
Column.updateString(CStr(pvValue))
End If
Else
Column.updateString(CStr(pvValue))
End If
Case .CHAR, .VARCHAR, .LONGVARCHAR
If Not Utils._CheckArgument(pvValue, iArgNr, vbString, , False) Then Goto Trace_Error_Value
Column.updateString(pvValue) ' vbString
Case .DATE
If Not Utils._CheckArgument(pvValue, iArgNr, vbDate, , False) Then Goto Trace_Error_Value
vTemp = New com.sun.star.util.Date
With vTemp
.Day = Day(pvValue)
.Month = Month(pvValue)
.Year = Year(pvValue)
End With
Column.updateDate(vTemp)
Case .TIME
If Not Utils._CheckArgument(pvValue, iArgNr, vbDate, , False) Then Goto Trace_Error_Value
vTemp = New com.sun.star.util.Time
With vTemp
.Hours = Hour(pvValue)
.Minutes = Minute(pvValue)
.Seconds = Second(pvValue)
'.HundredthSeconds = 0 ' replaced with Long nanoSeconds in LO 4.1 ??
End With
Column.updateTime(vTemp)
Case .TIMESTAMP
If Not Utils._CheckArgument(pvValue, iArgNr, vbDate, , False) Then Goto Trace_Error_Value
vTemp = New com.sun.star.util.DateTime
With vTemp
.Day = Day(pvValue)
.Month = Month(pvValue)
.Year = Year(pvValue)
.Hours = Hour(pvValue)
.Minutes = Minute(pvValue)
.Seconds = Second(pvValue)
'.HundredthSeconds = 0
End With
Column.updateTimestamp(vTemp)
' Case .BINARY, .VARBINARY, .LONGVARBINARY
' Case .BLOB
' Case .CLOB
Case Else
Goto trace_Error
End Select
Case .CHAR, .VARCHAR, .LONGVARCHAR
If Not Utils._CheckArgument(pvValue, iArgNr, vbString, , False) Then Goto Trace_Error_Value
Column.updateString(pvValue) ' vbString
Case .Date
If Not Utils._CheckArgument(pvValue, iArgNr, vbDate, , False) Then Goto Trace_Error_Value
vTemp = New com.sun.star.util.Date
With vTemp
.Day = Day(pvValue)
.Month = Month(pvValue)
.Year = Year(pvValue)
End With
Column.updateDate(vTemp)
Case .TIME
If Not Utils._CheckArgument(pvValue, iArgNr, vbDate, , False) Then Goto Trace_Error_Value
vTemp = New com.sun.star.util.Time
With vTemp
.Hours = Hour(pvValue)
.Minutes = Minute(pvValue)
.Seconds = Second(pvValue)
'.HundredthSeconds = 0 ' replaced with Long nanoSeconds in LO 4.1 ??
End With
Column.updateTime(vTemp)
Case .TIMESTAMP
If Not Utils._CheckArgument(pvValue, iArgNr, vbDate, , False) Then Goto Trace_Error_Value
vTemp = New com.sun.star.util.DateTime
With vTemp
.Day = Day(pvValue)
.Month = Month(pvValue)
.Year = Year(pvValue)
.Hours = Hour(pvValue)
.Minutes = Minute(pvValue)
.Seconds = Second(pvValue)
'.HundredthSeconds = 0
End With
Column.updateTimestamp(vTemp)
' Case .BINARY, .VARBINARY, .LONGVARBINARY
' Case .BLOB
' Case .CLOB
Case Else
Goto trace_Error
End Select
End If
End With
Case Else
Goto Trace_Error
......
......@@ -8,7 +8,7 @@ REM ============================================================================
Option Explicit
REM Access2Base -----------------------------------------------------
Global Const Access2Base_Version = "1.1.0f"
Global Const Access2Base_Version = "1.1.0g"
REM AcCloseSave
REM -----------------------------------------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment