0% found this document useful (0 votes)
1K views

Using Functions in SQL Statements

This document contains a quiz about user-defined functions in SQL. The questions cover topics such as valid locations for function calls in SQL statements, benefits of user-defined functions, and what can be coded within a user-defined function. Some key points covered are that user-defined functions can extend SQL functionality, be reused many times, and add business rules to the database. They cannot perform the same job as built-in system functions. Valid locations for function calls include the WHERE clause of a SELECT and DELETE and the VALUES clause of an INSERT.

Uploaded by

Catalina Achim
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1K views

Using Functions in SQL Statements

This document contains a quiz about user-defined functions in SQL. The questions cover topics such as valid locations for function calls in SQL statements, benefits of user-defined functions, and what can be coded within a user-defined function. Some key points covered are that user-defined functions can extend SQL functionality, be reused many times, and add business rules to the database. They cannot perform the same job as built-in system functions. Valid locations for function calls include the WHERE clause of a SELECT and DELETE and the VALUES clause of an INSERT.

Uploaded by

Catalina Achim
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

Test: Quiz: Using Functions in SQL Statements 1.

Function DOUBLE_SAL has been created as follows: CREATE OR REPLACE FUNCTION double_sal (p_salary IN employees.salary%TYPE) RETURN NUMBER IS BEGIN RETURN(p_salary * 2); END; Which of the following calls to DOUBLE_SAL will NOT work? Mark for Review (1) Points SELECT * FROM employees WHERE double_sal(salary) > 20000; SELECT * FROM employees ORDER BY double_sal(salary) DESC; UPDATE employees SET salary = double_sal(salary); SELECT last_name, double_sal(salary) FROM employees; None of the above; they will all work (*)

Correct 2. Which of the following is NOT a benefit of user-defined functions? Mark for Review (1) Points They can add business rules to the database and can be reused many times . They can be used in a WHERE clause to filter data. They can do the same job as built-in system functions such as UPPER and ROUND. (*) They can often be used inside SQL statements.

Correct 3. User-defined functions can extend the power of SQL statements where Ora cle does not provide ready-made functions such as UPPER and LOWER. True or False ? Mark for Review (1) Points

True (*) False

Correct 4. The following function has been created: CREATE OR REPLACE FUNCTION upd_dept (p_dept_id IN departments.department_id%TYPE) RETURN NUMBER IS BEGIN UPDATE departments SET department_name = 'Accounting' WHERE department_id = p_dept_id; RETURN p_dept_id; END; Which of the following will execute successfully? Mark for Review (1) Points DELETE FROM departments WHERE department_id = upd_dept(department_id); SELECT upd_dept(department_id) FROM employees; DELETE FROM employees WHERE department_id = upd_dept(80); (*)

SELECT upd_dept(80) FROM dual;

Correct 5. Which of the following is NOT a legal location for a function call in a SQL statement? Mark for Review (1) Points FROM clause of a SELECT statement (*) WHERE clause in a DELETE statement SET clause of an UPDATE statement

VALUES clause of an INSERT statement

Correct 6. You want to create a function which can be used in a SQL statement. Whi ch one of the following can be coded within your function? Mark for Review (1) Points RETURN BOOLEAN One or more IN parameters (*) An OUT parameter COMMIT;

Correct

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy