|
On 24-Sep-2015 15:22 -0600, Luis Rodriguez wrote:
You could use a CASE statement for each field you want to test.
Something like this:
INSERT INTO MYLIB.MYFILE(
Field1
, Field2
, Field3
)
VALUES(
(Case :newfield1 when ' ' THEN null else :newfield1 END)
, (Case :newfield2 when ' ' THEN null else :newfield2 END)
, (Case :newfield3 when ' ' THEN null else :newfield3 END)
)
;
To be clear, what was shown coded above are examples of the scalar
CASE-expression; an important distinction, from the CASE-statement.
And for that simple effect of a CASE-expression, the NULLIF scalar
is much simpler and succinct; i.e. code instead for each value:
NULLIF('',:newfield#)
[http://www.ibm.com/support/knowledgecenter/ssw_ibm_i_72/db2/rbafzcaseexp.htm]
IBM i 7.2->Database->Reference->SQL reference->Language
elements->Expressions->
_CASE expression_
<<SNIP>>
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.