From b4b3b7a25a8c3e8b0dcb1e945666aca090ad36d2 Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Thu, 5 May 2022 09:38:13 -0400 Subject: [PATCH] cat empty to null depending on new flag --- PriceLists.bas | 4 ++-- TheBigOne.cls | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/PriceLists.bas b/PriceLists.bas index 8430c07..352b52a 100644 --- a/PriceLists.bas +++ b/PriceLists.bas @@ -233,7 +233,7 @@ Sub price_load_plcore() Next i sql = "DELETE FROM rlarp.plcore WHERE listcode in (" & sql & ");" sql = sql & vbCrLf & "INSERT INTO rlarp.plcore" - sql = sql & vbCrLf & x.SQLp_build_sql_values(load, True, True, PostgreSQL, False, "S", "S", "S", "S", "S", "S", "S", "N", "N", "S", "N", "N") & ";" + sql = sql & vbCrLf & x.SQLp_build_sql_values(load, True, True, PostgreSQL, False, False, "S", "S", "S", "S", "S", "S", "S", "N", "N", "S", "N", "N") & ";" If Not x.ADOp_Exec(0, sql, 1, True, PostgreSQLODBC, "usmidlnx01", False, login.tbU, login.tbP, "Port=5030;Database=ubm") Then MsgBox (x.ADOo_errstring) @@ -254,7 +254,7 @@ End Sub -Sub build_upload() +Sub build_csv() Dim x As New TheBigOne Dim pl() As String diff --git a/TheBigOne.cls b/TheBigOne.cls index b4df16c..ee865d1 100644 --- a/TheBigOne.cls +++ b/TheBigOne.cls @@ -2460,7 +2460,7 @@ Function MISCe_col_to_letter(ByRef x As Long) As String End Function -Public Function SQLp_build_sql_values(ByRef tbl() As String, trim As Boolean, headers As Boolean, syntax As SQLsyntax, ByRef quote_headers As Boolean, ParamArray typeflag()) As String +Public Function SQLp_build_sql_values(ByRef tbl() As String, trim As Boolean, headers As Boolean, syntax As SQLsyntax, ByRef quote_headers As Boolean, empty_as_null As Boolean, ParamArray typeflag()) As String Dim i As Long @@ -2553,7 +2553,7 @@ Public Function SQLp_build_sql_values(ByRef tbl() As String, trim As Boolean, he End If Case "S" '-------S = string------------------------------------------ rx.Pattern = strip_text - If LTrim(RTrim(tbl(j, i))) = "" Then + If LTrim(RTrim(tbl(j, i))) = "" And empty_as_null Then rec = rec & "CAST(NULL AS " & nullText & ")" Else If trim Then @@ -2565,7 +2565,7 @@ Public Function SQLp_build_sql_values(ByRef tbl() As String, trim As Boolean, he End If Case "A" '-------A = string but dont apply any regex------------------ rx.Pattern = strip_text - If LTrim(RTrim(tbl(j, i))) = "" Then + If LTrim(RTrim(tbl(j, i))) = "" And empty_as_null Then rec = rec & "CAST(NULL AS " & nullText & ")" Else If trim Then @@ -2584,7 +2584,7 @@ Public Function SQLp_build_sql_values(ByRef tbl() As String, trim As Boolean, he End If Case Else '-------Assume text------------------------------------------ rx.Pattern = strip_text - If LTrim(RTrim(tbl(j, i))) = "" Then + If LTrim(RTrim(tbl(j, i))) = "" And empty_as_null Then rec = rec & "CAST(NULL AS " & nullText & ")" Else If trim Then