SELECT TO_CHAR ("APDISTRIB"."DISTRIB_DATE",'MM/DD/YYYY') as DISTRIB_DATE, TRIM("APDISTRIB"."INVOICE") as INVOICE, TO_CHAR("APINVOICE"."INVOICE_DTE",'MM/DD/YYYY') as INVOICE_DTE, TRIM("APINVOICE"."VENDOR") as VENDOR, TRIM(COALESCE("APINVOICE"."PO_NUMBER",'DIRECT INVOICE')) as PO_NUMBER, TRIM("APDISTRIB"."ACTIVITY") as ACTIVITY, "APDISTRIB"."DIS_ACCOUNT", TRIM("GHAPVENMAST"."VENDOR_VNAME")as VENDOR_VNAME, "APDISTRIB"."ORIG_TRAN_AMT", TRIM(COALESCE("POLINE"."DESCRIPTION",'DIRECT INVOICE')) as DESCRIPTION
;
Haven't ran this through SQL developer yet. Our DB is Oracle.
Here is the full code:
SELECT "APDISTRIB"."DISTRIB_DATE", "APDISTRIB"."INVOICE", "APINVOICE"."INVOICE_DTE", "APINVOICE"."VENDOR", TRIM(COALESCE("APINVOICE"."PO_NUMBER",'DIRECT INVOICE')) as PO_NUMBER, "APDISTRIB"."ACTIVITY", "APDISTRIB"."DIS_ACCOUNT", "GHAPVENMAST"."VENDOR_VNAME", "APDISTRIB"."ORIG_TRAN_AMT", TRIM(COALESCE("POLINE"."DESCRIPTION", 'DIRECT INVOICE')) as DESCRIPTION
FROM (("LAWPROD"."GHAPVENMAST" "GHAPVENMAST" INNER JOIN "LAWPROD"."APDISTRIB" "APDISTRIB" ON "GHAPVENMAST"."VENDOR"="APDISTRIB"."VENDOR") INNER JOIN "LAWPROD"."APINVOICE" "APINVOICE" ON (("APDISTRIB"."COMPANY"="APINVOICE"."COMPANY") AND ("APDISTRIB"."INVOICE"="APINVOICE"."INVOICE")) AND ("APDISTRIB"."REC_STATUS"="APINVOICE"."REC_STATUS")) FULL OUTER JOIN "LAWPROD"."POLINE" "POLINE" ON (("APDISTRIB"."COMPANY"="POLINE"."COMPANY") AND ("APDISTRIB"."PO_NUMBER"="POLINE"."PO_NUMBER")) AND ("APDISTRIB"."PO_LINE_NBR"="POLINE"."LINE_NBR")
WHERE ("APDISTRIB"."ACTIVITY" LIKE '8%' OR "APDISTRIB"."ACTIVITY" LIKE 'R%') AND ("APDISTRIB"."DISTRIB_DATE">={ts '2017-03-29 00:00:00'} AND "APDISTRIB"."DISTRIB_DATE"<{ts '2017-03-29 00:00:01'})
TEXT DOCUMENT RESULT:
"Posted By David Williams on 05/12/2017 9:05 AM You can't trim null fields, so it makes sense why you'd get an error. I believe the syntax to check for null values in JavaScript is if (PO_NUMBER===null) variable ="" So on fields where a null might be possible, you need to add error trapping like this and reassign to a different variable."
I am realizing that because the fields I am dealing with that contain blank data, once I introduce an expression like TRIM they return a null value instead of being blank. What puzzles me is how to properly TRIM and get blank or null values as another value or to remain blank.