A is definitly correct.
Without explicit conversion:
SELECT join_date FROM employees WHERE join_date > '10-02-2020';
ORA-01843: not a valid month
With explicit conversion:
SELECT join_date FROM employees WHERE join_date > TO_DATE('10-02-2020', 'DD-MM-YYYY');
-> Returns correct join_date on my test table.
All other options return a result without explicit conversion.
Tested on livesql.oracle.com
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.
This section is not available anymore. Please use the main Exam Page.1z0-082 Exam Questions
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
gmirnichtaufdieeier
2 months, 1 week agoOracle2020
6 months, 1 week agopsycrotic5
10 months, 2 weeks agonautil2
1 year, 1 month agonautil2
1 year, 1 month agoauwia
1 year, 3 months agoPivoine
1 year, 3 months agoivanadj
1 year, 8 months ago