Update build SQL to have a select case for each data type and add as cast to date on null
This commit is contained in:
parent
99a5318f4d
commit
51f35f9337
@ -1877,19 +1877,32 @@ Public Function ADOp_BuildInsertSQL(ByRef tbl() As String, target As String, tri
|
|||||||
rec = rec & "("
|
rec = rec & "("
|
||||||
For j = 0 To UBound(tbl, 1)
|
For j = 0 To UBound(tbl, 1)
|
||||||
If j <> 0 Then rec = rec & ","
|
If j <> 0 Then rec = rec & ","
|
||||||
If ftype(0)(j) <> "S" Then
|
Select Case ftype(0)(j)
|
||||||
If tbl(j, i) = "" Then
|
Case "N" '-------N = numeric but should probably be N for numeric----
|
||||||
rec = rec & "NULL"
|
If tbl(j, i) = "" Then
|
||||||
Else
|
rec = rec & "NULL"
|
||||||
rec = rec & Replace(tbl(j, i), "'", "''")
|
Else
|
||||||
End If
|
rec = rec & Replace(tbl(j, i), "'", "''")
|
||||||
Else
|
End If
|
||||||
If trim Then
|
Case "S" '-------S = string------------------------------------------
|
||||||
rec = rec & "'" & LTrim(RTrim(Replace(tbl(j, i), "'", "''"))) & "'"
|
If trim Then
|
||||||
Else
|
rec = rec & "'" & LTrim(RTrim(Replace(tbl(j, i), "'", "''"))) & "'"
|
||||||
rec = rec & "'" & Replace(tbl(j, i), "'", "''") & "'"
|
Else
|
||||||
End If
|
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) & "'"
|
||||||
|
End If
|
||||||
|
Case Else '-------Assume text------------------------------------------
|
||||||
|
If trim Then
|
||||||
|
rec = rec & "'" & LTrim(RTrim(Replace(tbl(j, i), "'", "''"))) & "'"
|
||||||
|
Else
|
||||||
|
rec = rec & "'" & Replace(tbl(j, i), "'", "''") & "'"
|
||||||
|
End If
|
||||||
|
End Select
|
||||||
Next j
|
Next j
|
||||||
rec = rec & ")"
|
rec = rec & ")"
|
||||||
sql = sql & rec
|
sql = sql & rec
|
||||||
@ -1898,3 +1911,4 @@ Public Function ADOp_BuildInsertSQL(ByRef tbl() As String, target As String, tri
|
|||||||
ADOp_BuildInsertSQL = sql
|
ADOp_BuildInsertSQL = sql
|
||||||
|
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user