× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On 24-Sep-2015 15:08 -0600, Justin Taylor wrote:
If a field is blank, I want to write a null when I do an INSERT.
There could be one or more nulls. Is there a good way to do this?
The only way I've found so far is a bunch of different INSERT
statements and IF/ELSE's.

Not sure what is the scenario; DDL and some example data might be more clear.

But if I understand correctly what was attempted to be expressed in that text, I think the following might assist; presumes an INSERT with VALUES clause:

INSERT INTO the_lib/the_table VALUES
( nullif( '' , :F1_value )
, nullif( '' , :F2_value )
)

The NULLIF scalar will produce a NULL-result if the value of the host variable named F1_value equates with the empty-string [varlen] or equates with all blanks for a fixed-length field. Thus the determination whether the NULL-value is the effect, is pushed into the database rather than being coded separately\before in the host-language.

From the description in the OP [above], seems unclear whether the IF\ELSE work is being used to set the NULL indicators, and perhaps the host-indicator-variables are already being supplied; e.g.:

INSERT INTO the_lib/the_table VALUES
( :F1_value :F1_ind )
, :F2_value :F2_ind )
)


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.