0% found this document useful (0 votes)
775 views4 pages

Retrieving Data in PLSQL

This document summarizes key guidelines for retrieving data in PL/SQL blocks: 1) PL/SQL variables can have the same name as database columns. 2) An invalid guideline is to not use a WHERE clause in SELECT statements. 3) A SELECT statement used in a PL/SQL block must return exactly one row.

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)
775 views4 pages

Retrieving Data in PLSQL

This document summarizes key guidelines for retrieving data in PL/SQL blocks: 1) PL/SQL variables can have the same name as database columns. 2) An invalid guideline is to not use a WHERE clause in SELECT statements. 3) A SELECT statement used in a PL/SQL block must return exactly one row.

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/ 4

Test: Quiz: Retrieving Data in PL/SQL 1.

Does PL/SQL allow you to have a variable with the same name as a databa se column? Mark for Review (1) Points No Yes (*)

Correct 2. Which of the following is NOT a valid guideline for retrieving data in PL/SQL? Mark for Review (1) Points Terminate the SQL statement with a semicolon (;) Do NOT use a WHERE clause in SELECT statements. (*) Where possible, declare variables using the %TYPE attribute. Specify the same number of variables in the INTO clause as database colu mns in the SELECT clause.

Correct 3. When used in a PL/SQL block, which SQL statement must return exactly on e row? Mark for Review (1) Points INSERT UPDATE SELECT (*) MERGE DELETE

Correct

4. Which one of these SQL statements can be directly included in a PL/SQL executable block? Mark for Review (1) Points IF... THEN...; INSERT INTO...; (*) SELECT * FROM DUAL; SHOW USER;

Correct 5. What will happen when the following block is executed? DECLARE v_last employees.last_name%TYPE; v_first employees.first_name%TYPE; v_salary employees.salary%TYPE; BEGIN SELECT first_name, last_name INTO v_first, v_last, v_salary FROM employees WHERE employee_id=100; END; Mark for Review (1) Points The block will fail because the SELECT statement returns more than one r ow. The block will fail because the SELECT is trying to read two columns int o three PL/SQL variables. (*) The block will fail because V_LAST was declared before V_FIRST. The block will execute successfully, and the V_SALARY variable will be s et to NULL.

Correct 6. Look at this PL/SQL block: DECLARE v_count NUMBER; BEGIN SELECT COUNT(*) INTO v_count FROM employees WHERE salary > 50000; END;

No employees earn more than $50000. Which of the following statements are true? (Choose two). Mark for Review (1) Points (Choose all correct answers) The SELECT will return value 0 into V_COUNT. (*) The SELECT will fail because it does NOT return exactly one row. The block will fail because variable V_SALARY was not declared. The SELECT returns exactly one row. (*) The block will fail because no results are displayed to the user.

Correct 7. It is good programming practice to create identifiers having th e same name as column names. True or False? Mark for Review (1) Points True False (*)

Correct 8. Which SQL statements can be used directly in a PL/SQL block? (Choose tw o.) Mark for Review (1) Points (Choose all correct answers) GRANT EXECUTE ON ... SELECT * INTO ... (*) REVOKE SELECT ON ... UPDATE employees SET... (*)

ALTER TABLE employees ...

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