DEA-C02 · Question #136
A Data Engineer has created two SQL User-Defined Functions (UDFs) with the same name: The following function call is made: select plus5(to_date('2024-01-25')); What will be the output of this call?
The correct answer is D. The SQL compilation error: error line 1 at position 7 Invalid argument types. Option D is correct because the two overloaded plus5 UDFs are defined to accept specific types (typically one for NUMBER and one for VARCHAR), and to_date('2024-01-25') returns a DATE - a type that matches neither UDF signature, so the SQL engine cannot resolve which function…
Question
A Data Engineer has created two SQL User-Defined Functions (UDFs) with the same name:
The following function call is made:
select plus5(to_date(‘2024-01-25’)); What will be the output of this call?
Exhibit
Options
- A2024-01-30
- B2024-01-255
- C2024-01-25'5'
- DThe SQL compilation error: error line 1 at position 7 Invalid argument types
How the community answered
(38 responses)- A3% (1)
- B8% (3)
- C16% (6)
- D74% (28)
Explanation
Option D is correct because the two overloaded plus5 UDFs are defined to accept specific types (typically one for NUMBER and one for VARCHAR), and to_date('2024-01-25') returns a DATE - a type that matches neither UDF signature, so the SQL engine cannot resolve which function to call and throws a compilation error at parse time. Option A (2024-01-30) is tempting but wrong because it assumes a date-aware UDF exists that adds 5 days; no such signature is defined. Options B and C represent impossible string-concatenation artifacts that no valid UDF logic would produce, making them easy eliminations. The key insight for exam takers: UDF overloading resolution is strict - the engine matches by argument type, and passing a DATE where only NUMBER or VARCHAR signatures exist causes a compile-time failure, not a runtime one, so the query never even executes. Remember this with the phrase "wrong type, won't even try" - SQL won't attempt implicit DATE conversion to resolve an ambiguous overload.
Topics
Community Discussion
No community discussion yet for this question.
