Exam 1z0-071 All QuestionsBrowse all questions from this exam
Question 68

Which two statements execute successfully? (Choose two.)

A.

B.

C.

D.

E.

    Correct Answer:

    To determine which two statements execute successfully, we need to examine each SQL statement to ensure it adheres to the correct syntax and logic for Oracle SQL date and character functions. Statement A: ``` SELECT TO_DATE('2019-DEC-25 15:30', 'YYYY-MON-DD HH24:MI', 'NLS_DATE_LANGUAGE = AMERICAN') FROM DUAL; ``` This statement converts the given string into a date using the specified format. It includes the `NLS_DATE_LANGUAGE` parameter to ensure the month abbreviation is interpreted correctly. This statement should execute successfully because it follows the correct syntax for TO_DATE conversion with the specified NLS parameter. Statement B: ``` SELECT TO_CHAR(TO_DATE('2019-DEC-25 03:30', 'YYYY-MON-DD HH12:MI')) FROM DUAL; ``` This statement first converts the string into a date and then converts it back to a character string. This should also execute successfully because both functions are used correctly and the format matches the input string. Statement C: ``` SELECT TO_DATE(TO_CHAR('2019-DEC-25 03:30', 'YYYY-MON-DD HH12:MI')) FROM DUAL; ``` This statement contains an error. `TO_CHAR` is intended to convert a date to a character string, not to format a given string. This leads to a syntax issue. Statement D: ``` SELECT TO_CHAR('2019-DEC-25 15:30', 'YYYY-MON-DD HH24:MI') FROM DUAL; ``` This statement is attempting to convert a character string to another character string without first converting it to a date. This will result in an ORA-01722 invalid number error. Statement E: ``` SELECT TO_CHAR('2019-DEC-25 15:30', 'YYYY-MON-DD HH24:MI', 'NLS_DATE_LANGUAGE = AMERICAN') FROM DUAL; ``` Similar to Statement D, this statement attempts to convert a character string directly to another character string using the TO_CHAR function without first converting it to a date. This will also result in an invalid number error. Therefore, the two correct statements that execute successfully are: A and B.

Discussion
zouve

AB tested

DrunkenMonkey

how did u extract only text from this text image

yaya32

https://www.editpad.org/tool/extract-text-from-image

Poke90

why is D wrong?

Eltelwany

It gives this error ORA-01722: invalid number. Also, there is no point in converting this to char, It can not parse it correctly. This needs to be converted to date first.