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)
|
||||||
|
Case "N" '-------N = numeric but should probably be N for numeric----
|
||||||
If tbl(j, i) = "" Then
|
If tbl(j, i) = "" Then
|
||||||
rec = rec & "NULL"
|
rec = rec & "NULL"
|
||||||
Else
|
Else
|
||||||
rec = rec & Replace(tbl(j, i), "'", "''")
|
rec = rec & Replace(tbl(j, i), "'", "''")
|
||||||
End If
|
End If
|
||||||
Else
|
Case "S" '-------S = string------------------------------------------
|
||||||
If trim Then
|
If trim Then
|
||||||
rec = rec & "'" & LTrim(RTrim(Replace(tbl(j, i), "'", "''"))) & "'"
|
rec = rec & "'" & LTrim(RTrim(Replace(tbl(j, i), "'", "''"))) & "'"
|
||||||
Else
|
Else
|
||||||
rec = rec & "'" & Replace(tbl(j, i), "'", "''") & "'"
|
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
|
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