Validating conversions
The data to be stored in the database can originate from various sources. For example, by loading the values from CSV files, a textual representation is present, requiring the system to convert the data to the proper format and data type. Thus, before processing and storing values, it is always necessary to ensure the value can be mapped to the desired data type. Moreover, for the date and time values, the format mask (mapping) must also be applicable. To test the conversion opportunities, instead of hardcoding using PL/SQL and exception handling, the validate_conversion
function, introduced by the Oracle database, can be used. It takes an expression and the output data type (output_data_type
), optionally extended by the format mask (format_mapping
) and NLS parameters (nls_parameters
) for the date and time values. The syntax of the validate_conversion
function is shown in the following code block:
validate_conversion ( ...