Examine the description of the EMPLOYEES table:
NLS_DATE_FORMAT is set to DD-MON-YY.
Which query requires explicit data type conversion?
Examine the description of the EMPLOYEES table:
NLS_DATE_FORMAT is set to DD-MON-YY.
Which query requires explicit data type conversion?
In the query option D, SELECT SUBSTR(join_date, 1, 2) - 10 FROM employees, an explicit data type conversion is required. This is because join_date is of DATE data type and the SUBSTR function operates on strings, not dates. Therefore, the DATE data type needs to be explicitly converted to a VARCHAR2 string format using a function like TO_CHAR before performing the SUBSTR operation. Additionally, after extracting the substring, it’s intended to be used in arithmetic operations, which further necessitates conversion to a numeric type.
https://www.examtopics.com/discussions/oracle/view/13453-exam-1z0-071-topic-1-question-296-discussion/
A is correct
Provided answer is wrong! The base! :-) part VIII
what about Option D?: SELECT SUBSTR(join_date, 1, 2) - 10 FROM employees; This query is attempting to perform a substring operation on a DATE type, which is not valid without first converting the date to a string. Oracle does not support taking substrings directly from DATE data types. The date must be converted to a string using TO_CHAR before SUBSTR can be used. Furthermore, subtracting 10 from a substring of a date does not make sense unless the substring represents a number, which is not the case here since join_date is a date and not a string of numbers. Therefore, explicit conversion is necessary, and the query itself is somewhat nonsensical without additional context or correction. This makes Option D the most clearly incorrect and the one that certainly requires explicit data type conversion to even make sense as a SQL statement.
AC is correct. A returns: SELECT join_date FROM employees WHERE join_date > '10-02-2018'; SELECT join_date FROM employees WHERE join_date > '10-02-2018' * ERROR at line 1: ORA-01843: not a valid month C returns: SQL> SELECT salary+'120.50' FROM employees; SELECT salary+'120.50' FROM employees * ERROR at line 1: ORA-01722: invalid number
Let me correct my suggestion, please. Only C is correct. Datatype conversion in A does not make the query valid. SQL> SELECT join_date FROM employees WHERE TO_DATE(join_date,'DD-MM-YYYY') > '10-02-2018'; SELECT join_date FROM employees WHERE TO_DATE(join_date,'DD-MM-YYYY') > '10-02-2018' * ERROR at line 1: ORA-01843: not a valid month Only altering session variable NLS_DATE_FORMAT with ALTER SESSION SET nls_date_format='DD-MM-YY'; makes the A query to return valid response. So there´s no datatype conversion, just altering session variable, therefore A is false.
C tested