add explicit cast-null to any empty cell or cells that evaluate to
This commit is contained in:
parent
1b2cdf854b
commit
d2e3fc3cd8
@ -2208,27 +2208,35 @@ Public Function SQLp_build_sql_values(ByRef tbl() As String, trim As Boolean) As
|
||||
Select Case type_flag(j)
|
||||
Case "N" '-------N = numeric but should probably be N for numeric----
|
||||
If tbl(j, i) = "" Then
|
||||
rec = rec & "NULL"
|
||||
rec = rec & "CAST(NULL AS NUMERIC)"
|
||||
Else
|
||||
rec = rec & Replace(tbl(j, i), "'", "''")
|
||||
End If
|
||||
Case "S" '-------S = string------------------------------------------
|
||||
If trim Then
|
||||
rec = rec & "'" & LTrim(RTrim(Replace(tbl(j, i), "'", "''"))) & "'"
|
||||
If LTrim(RTrim(tbl(j, i))) = "" Then
|
||||
rec = rec & "CAST(NULL AS VARCHAR(255))"
|
||||
Else
|
||||
rec = rec & "'" & Replace(tbl(j, i), "'", "''") & "'"
|
||||
If trim Then
|
||||
rec = rec & "'" & LTrim(RTrim(Replace(tbl(j, i), "'", "''"))) & "'"
|
||||
Else
|
||||
rec = rec & "'" & Replace(tbl(j, i), "'", "''") & "'"
|
||||
End If
|
||||
End If
|
||||
Case "D" '-------D = date---------------------------------------------
|
||||
If LTrim(RTrim(tbl(j, i))) = "" Then
|
||||
rec = rec & "CAST(NULL AS DATE)"
|
||||
Else
|
||||
rec = rec & "'" & tbl(j, i) & "'"
|
||||
rec = rec & "CAST('" & tbl(j, i) & "' AS DATE)"
|
||||
End If
|
||||
Case Else '-------Assume text------------------------------------------
|
||||
If trim Then
|
||||
rec = rec & "'" & LTrim(RTrim(Replace(tbl(j, i), "'", "''"))) & "'"
|
||||
If LTrim(RTrim(tbl(j, i))) = "" Then
|
||||
rec = rec & "CAST(NULL AS VARCHAR(255))"
|
||||
Else
|
||||
rec = rec & "'" & Replace(tbl(j, i), "'", "''") & "'"
|
||||
If trim Then
|
||||
rec = rec & "'" & LTrim(RTrim(Replace(tbl(j, i), "'", "''"))) & "'"
|
||||
Else
|
||||
rec = rec & "'" & Replace(tbl(j, i), "'", "''") & "'"
|
||||
End If
|
||||
End If
|
||||
End Select
|
||||
Next j
|
||||
|
Loading…
Reference in New Issue
Block a user