Handle Null Values In Sql - Loader
: Useful if your source system uses a placeholder like "N/A" or "0". column_name NULLIF (column_name = "N/A") Use code with caution. Copied to clipboard
LOAD DATA INFILE 'data.csv' INTO TABLE employees FIELDS TERMINATED BY ',' TRAILING NULLCOLS ( emp_id, emp_name, commission_pct -- If this is missing in the file, it becomes NULL ) Use code with caution. Copied to clipboard 5. Using SQL Functions Handle Null Values In Sql Loader
By default, if a field in the data file is empty (contains no data between delimiters), SQL*Loader attempts to load it as a . However, if the column in the database has a NOT NULL constraint, the record will be rejected and moved to the .bad file. 2. Using the NULLIF Clause : Useful if your source system uses a
You can also use Oracle SQL functions within the control file to handle null logic during the load process. This is helpful for replacing nulls with a specific value (like NVL ). column_name "NVL(:column_name, 'Unknown')" Use code with caution. Copied to clipboard Summary of Key Commands NULLIF Sets column to NULL if a specific condition is met. DEFAULTIF Uses the database's default value if a condition is met. TRAILING NULLCOLS Prevents errors when the last columns in a row are missing. BLANKS Copied to clipboard 5
