
Explanation:
This question highlights the difference between the RETURN and RETURNS keywords in SQL function creation. The RETURNS keyword specifies the type of the return value (e.g., STRING, INT), while the RETURN keyword is used to define the actual return value. Additionally, if a function does not accept any arguments, its name should be followed by empty brackets (e.g., print_details()). Understanding these distinctions is crucial for correctly answering such questions on the exam.
Ultimate access to all questions.
A data engineer is tasked with creating a function named print_details that outputs the name of the current catalog and database, separated by a space. Which of the following statements correctly creates this function?
A
CREATE FUNCTION print_details() RETURNS STRING RETURN concat(current_catalog(),‘ ‘,current_database());
B
CREATE FUNCTION print_details(STRING) RETURNS concat(current_catalog(),‘ ‘,current_database());
C
CREATE FUNCTION print_details RETURNS STRING RETURN concat(current_catalog(),‘ ‘,current_database());
D
CREATE FUNCTION print_details(STRING) RETURN concat(current_catalog(),‘ ‘,current_database());
E
CREATE FUNCTION print_details() RETURNS concat(current_catalog(),‘ ‘,current_database());
No comments yet.