2. Which of the following declarations is invalid? Mark for Review (1) Points



Similar documents
What is the value of SQL%ISOPEN immediately after the SELECT statement is executed? Error. That attribute does not apply for implicit cursors.

Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Handling Exceptions. Copyright 2008, Oracle. All rights reserved.

Oracle Database: SQL and PL/SQL Fundamentals

Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Oracle Database: SQL and PL/SQL Fundamentals NEW

Oracle Database: SQL and PL/SQL Fundamentals

Duration Vendor Audience 5 Days Oracle End Users, Developers, Technical Consultants and Support Staff

Recognizing PL/SQL Lexical Units. Copyright 2007, Oracle. All rights reserved.

Database Programming with PL/SQL: Learning Objectives

Oracle SQL. Course Summary. Duration. Objectives

Handling Exceptions. Copyright 2006, Oracle. All rights reserved. Oracle Database 10g: PL/SQL Fundamentals 8-1

Oracle Database 12c: Introduction to SQL Ed 1.1

A basic create statement for a simple student table would look like the following.

Oracle Internal & Oracle Academy

ORACLE 9I / 10G / 11G / PL/SQL COURSE CONTENT

Writing Control Structures

PL / SQL Basics. Chapter 3

Handling Exceptions. Schedule: Timing Topic 45 minutes Lecture 20 minutes Practice 65 minutes Total

Oracle For Beginners Page : 1

Oracle Database: SQL and PL/SQL Fundamentals NEW

STUDY OF PL/SQL BLOCK AIM: To Study about PL/SQL block.

Creating PL/SQL Blocks. Copyright 2007, Oracle. All rights reserved.

PL/SQL MOCK TEST PL/SQL MOCK TEST I

Programming with SQL


Using Variables in PL/SQL. Copyright 2007, Oracle. All rights reserved.

Oracle Database 10g: Introduction to SQL

PL/SQL Programming Concepts: Review. Copyright 2004, Oracle. All rights reserved.

Answers to the Try It Yourself Sections

Handling Exceptions. Schedule: Timing Topic. 45 minutes Lecture 20 minutes Practice 65 minutes Total

Retrieving Data Using the SQL SELECT Statement. Copyright 2006, Oracle. All rights reserved.

Oracle Database 11g SQL

Oracle Database: Introduction to SQL

1 Stored Procedures in PL/SQL 2 PL/SQL. 2.1 Variables. 2.2 PL/SQL Program Blocks

Oracle Database: Introduction to SQL

Oracle Database: Introduction to SQL

Training Guide. PL/SQL for Beginners. Workbook

Darshan Institute of Engineering & Technology PL_SQL

Oracle PL/SQL Language. CIS 331: Introduction to Database Systems

Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Oracle 10g PL/SQL Training

Course -Oracle 10g SQL (Exam Code IZ0-047) Session number Module Topics 1 Retrieving Data Using the SQL SELECT Statement

COMS20700 DATABASES 13 PL/SQL. COMS20700 Databases Dr. Essam Ghadafi

Handling PL/SQL Errors

Information and Computer Science Department ICS 324 Database Systems Lab#11 SQL-Basic Query

Oracle For Beginners Page : 1

Appendix A Practices and Solutions

Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

When an exception occur a message which explains its cause is received. PL/SQL Exception message consists of three parts.

Triggers & Packages. {INSERT [OR] UPDATE [OR] DELETE}: This specifies the DML operation.

OPP ODTUG Kaleidoscope. An ODTUG SP* Oracle PL/SQL Programming Conference. WOW-Wide Open World, Wide Open Web!

Oracle For Beginners Page : 1

Making the Most of Oracle PL/SQL Error Management Features

Oracle PL/SQL Best Practices

Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Oracle Database 10g: PL/SQL Fundamentals

Oracle Database 10g Express

Oracle Database 10g: Program with PL/SQL

Oracle Database: Develop PL/SQL Program Units

Oracle9i: Develop PL/SQL Program Units

Introduction to PL/SQL Programming

GENERAL PROGRAMMING LANGUAGE FUNDAMENTALS

MOC 20461C: Querying Microsoft SQL Server. Course Overview

PL/SQL (Cont d) Let s start with the mail_order database, shown here:

Oracle Database: Program with PL/SQL

Oracle 11g PL/SQL training

An Introduction to PL/SQL. Mehdi Azarmi

SQL/PSM. Outline. Database Application Development Oracle PL/SQL. Why Stored Procedures? Stored Procedures PL/SQL. Embedded SQL Dynamic SQL

Guide to SQL Programming: SQL:1999 and Oracle Rdb V7.1

Examine the structure of the EMPLOYEES table: EMPLOYEE_ID NUMBER Primary Key FIRST_NAME VARCHAR2(25) LAST_NAME VARCHAR2(25)

Oracle Database: Program with PL/SQL

Duration Vendor Audience 5 Days Oracle Developers, Technical Consultants, Database Administrators and System Analysts

Embedded SQL programming

Intro to Embedded SQL Programming for ILE RPG Developers

Where? Originating Table Employees Departments

Topics Advanced PL/SQL, Integration with PROIV SuperLayer and use within Glovia

Oracle Database: Program with PL/SQL

Oracle Database: Program with PL/SQL


Lab # 5. Retreiving Data from Multiple Tables. Eng. Alaa O Shama

DbSchema Tutorial with Introduction in SQL Databases

T-SQL STANDARD ELEMENTS

Handling PL/SQL Errors

Oracle Database: Program with PL/SQL

GET DATA FROM MULTIPLE TABLES QUESTIONS

SQL - QUICK GUIDE. Allows users to access data in relational database management systems.

5. CHANGING STRUCTURE AND DATA

Microsoft Access Lesson 5: Structured Query Language (SQL)

Developing SQL and PL/SQL with JDeveloper

PL/SQL Programming. Oracle Database 12c. Oracle Press ORACLG. Michael McLaughlin. Mc Graw Hill Education

D61830GC30. MySQL for Developers. Summary. Introduction. Prerequisites. At Course completion After completing this course, students will be able to:

Overview of PL/SQL. About PL/SQL

Oracle Database 11g SQL and PL/SQL: A Brief Primer

VARRAY AND NESTED TABLE

Chapter 9 Joining Data from Multiple Tables. Oracle 10g: SQL

The Sins of SQL Programming that send the DB to Upgrade Purgatory Abel Macias. 1 Copyright 2011, Oracle and/or its affiliates. All rights reserved.

Instant SQL Programming

PL/SQL Overview. Basic Structure and Syntax of PL/SQL

Transcription:

Mid Term Exam Semester 1 - Part 1 1. 1. Null 2. False 3. True 4. 0 Which of the above can be assigned to a Boolean variable? 2 and 3 2, 3 and 4 1, 2 and 3 (*) 1, 2, 3 and 4 2. Which of the following declarations is invalid? v_count PLS_INTEGER:=0; college_name VARCHAR2(20):='Harvard'; v_pages CONSTANT NUMBER; (*) v_start_date DATE := sysdate+1; 3. A variable must have a value if NOT NULL is specified. True or False? True (*) False 4. Variables can be used in the following ways in a PL/SQL block. (Choose two.) (Choose all correct answers) To store data values. (*) To rename tables and columns.

To refer to a single data value several times. (*) To comment code. 5. Evaluate the following declaration. Determine whether or not it is legal. maxsalary NUMBER(7) = 5000;. Not correct. (*) Mid Term Exam Semester 1 - Part 1 6. Is the following variable declaration correct or not? display_qty CONSTANT NUMBER;. Not correct. (*) 7. Variables can be assigned a value in both the Executable and Declaration sections of a PL/SQL program. True or False? True (*) False 8. Assignment statements can continue over several lines in PL/SQL. True or False? True (*) False

9. Which of these are PL/SQL data types? (Choose three.) Mark for Review (Choose all correct answers) Scalar (*) Identifier Delimiter Composite (*) LOB (*) 10. are meant to store large amounts of data. Variables Scalar data types LOBs (*) 11. Which statement most closely describes "data type"? It is the value of a variable. It specifies a storage format, constraints, and a valid range of values for a variable. (*) It allows different kinds of data to be stored in a single variable. It is used to test if errors have occurred. 12. You declare an implicit cursor in the section of a PL/SQL block. True or False? True False (*) Incorrect. Refer to Section 3.

13. There are no employees in Department 77. What will happen when the following block is executed? DELETE FROM employees WHERE department_id=77; DBMS_OUTPUT.PUT_LINE(SQL%ROWCOUNT) A NO_DATA_FOUND exception is raised. A NULL is displayed. A zero (0) is displayed. (*) An exception is raised because the block does not contain a COMMIT statement. Incorrect. Refer to Section 3. 14. Which is the correct way to erase one row from a table? Mark for Review REMOVE employee_id=100 FROM employees; DROP TABLE employees WHERE employee_id=100; TRUNCATE employees WHERE employee_id=100; DELETE FROM employees WHERE employee_id=100; (*) Incorrect. Refer to Section 3. 15. Delimiters are that have special meaning to the Oracle database. identifiers variables

symbols (*) 16. Which of the following are PL/SQL lexical units? (Choose two.) Mark for Review (Choose all correct answers) Identifiers (*) Table Columns Reserved Words (*) Anonymous Blocks SQL Workshop 17. Which statements about lexical units are true? (Choose two.) Mark for Review (Choose all correct answers) They are named objects stored in the database They are the building blocks of every PL/SQL program (*) They are optional but can make a PL/SQL block execute faster They are sequences of characters including letters, digits, tabs, returns and symbols (*) 18. Examine the following code. At Line A, we want to assign a value of 22 to the outer block's variable v_myvar. What code should we write at Line A? <<outer_block>> v_myvar NUMBER; <<inner_block>> v_myvar NUMBER := 15; -- Line A

outer_block.v_myvar := 22; (*) v_myvar := 22; <<outer_block>>.v_myvar := 22; v_myvar(outer_block) := 22; We cannot reference the outer block's variable because both variables have the same name 19. What will be displayed when the following code is executed? vara NUMBER := 12; varb NUMBER := 8; vara := vara + varb; DBMS_OUTPUT.PUT_LINE(varB); 8 12 Nothing, the block will fail with an error (*) 20 VarB 20. Examine the following code. Line A causes an exception. What will be displayed when the block is executed? var_a NUMBER := 6; var_b DATE; var_a := var_a * 2; var_b := '28 December 2006'; -- Line A var_a := var_a * 2;

EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.PUT_LINE(var_a); 12 (*) 24 6 Nothing will be displayed Test: Mid Term Exam Semester 1 - Part I Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer. Mid Term Exam Semester 1 - Part 1 21. What will be displayed when the following code is executed? x VARCHAR2(6) := 'Chang'; x VARCHAR2(12) := 'Susan'; x := x x; DBMS_OUTPUT.PUT_LINE(x); Susan Chang (*) ChangChang SusanChang The code will fail with an error 22. When an exception occurs within a PL/SQL block, the remaining statements in the executable section of the block are skipped. True or False?

True (*) False 23. Which statements are optional in a PL/SQL block? (Choose two.) (Choose all correct answers) (*) EXCEPTION (*) 24. Every PL/SQL anonymous block must start with the keyword. True or False? True False (*) 25. Which PL/SQL block type must return a value? Anonymous Function (*) Procedure Test: Mid Term Exam Semester 1 - Part I Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Mid Term Exam Semester 1 - Part 1 26. What is the purpose of using DBMS_OUTPUT.PUT_LINE in a PL/SQL block? To perform conditional tests To allow a set of statements to be executed repeatedly To display results to check if our code is working correctly (*) To store new rows in the database 27. Errors are handled in the Exception part of the PL/SQL block. True or False? True (*) False 28. Which keywords must be included in every PL/SQL block? (Choose two.) (Choose all correct answers) (*) EXCEPTION (*) DBMS_OUTPUT.PUT_LINE 29. In which part of the PL/SQL block are declarations of variables defined? Executable Exception

Declarative (*) Definition Incorrect. Refer to Section 1. 30. Which lines of code will correctly display the message "The cat sat on the mat"? (Choose two.) (Choose all correct answers) DBMS_OUTPUT.PUT_LINE('The cat sat on the mat'); (*) DBMS_OUTPUT.PUT_LINE(The cat sat on the mat); DBMS_OUTPUT.PUT_LINE('The cat' 'sat on the mat'); DBMS_OUTPUT.PUT_LINE('The cat sat ' 'on the mat'); (*) Incorrect. Refer to Section 1. Test: Mid Term Exam Semester 1 - Part I Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer. Mid Term Exam Semester 1 - Part 1 31. When you use a function to convert data types in a PL/SQL program, it is called conversion. Explicit (*) Implicit TO_CHAR 32. The DECODE function is available in PL/SQL procedural statements. True or False? True False (*)

33. What is wrong with this assignment statement? myvar := 'To be or not to be'; 'That is the question'; An assignment statement must be a single line of code Nothing is wrong, the statement is fine An assignment statement must have a single semicolon at the end (*) "myvar" is not a valid name for a variable Character literals should not be enclosed in quotes 34. PL/SQL can convert a VARCHAR2 value containing alphabetic characters to a NUMBER value. True or False? True False (*) 35. Single row character functions are valid SQL functions in PL/SQL. True or False? True (*) False 36. If today's date is 14th June 2007, which statement will correctly convert today's date to the value: June 14, 2007? TO_CHAR(sysdate) TO_DATE(sysdate) TO_DATE(sysdate,'Month DD, YYYY')

TO_CHAR(sysdate, 'Month DD, YYYY') (*) 37. TO_NUMBER, TO_CHAR, and TO_DATE are all examples of: Mark for Review Implicit conversion functions Explicit conversion functions (*) Character functions Operators 38. What is the output when the following program is executed? set serveroutput on a VARCHAR2(10) := '333'; b VARCHAR2(10) := '444'; c PLS_INTEGER; d VARCHAR2(10); c := TO_NUMBER(a) + TO_NUMBER(b); d := a b; DBMS_OUTPUT.PUT_LINE(c); DBMS_OUTPUT.PUT_LINE(d); Nothing. The code will result in an error. c=777 and d=333444 (*) c=777 and d=777 c=333444 and d=777 39. Which of the following are valid assignment statements? (Choose two.) (Choose all correct answers) v_string = 'Hello';

v_string := Hello; v_number := 17 + 34; (*) v_string := 'Hello'; (*) v_date := 28-DEC-06; 40. Examine the following code. What is the final value of V_MYBOOL? v_mynumber NUMBER; v_mybool BOOLEAN ; v_mynumber := 6; v_mybool := (v_mynumber BETWEEN 10 AND 20); v_mybool := NOT (v_mybool); True (*) False 41. The following code will return the last name of the employee whose employee id is equal to 100: True or False? v_last_name employees.last_name%type; employee_id employees.employee_id%type := 100; SELECT last_name INTO v_last_name FROM employees WHERE employee_id = employee_id; True False (*) 42. Which of the following is NOT a good guideline for retrieving data in PL/SQL? Declare the receiving variables using %TYPE

The WHERE clause is optional in nearly all cases. (*) Specify the same number of variables in the INTO clause as database columns in the SELECT clause. THE SELECT statement should fetch exactly one row. Incorrect. Refer to Section 3. 43. A variable is declared as: v_holdit employees.last_name%type;... Which of the following is a correct use of the INTO clause? SELECT * INTO v_holdit FROM employees; SELECT last_name INTO v_holdit FROM employees; SELECT last_name INTO v_holdit FROM employees WHERE employee_id=100; (*) SELECT salary INTO v_holdit FROM employees WHERE employee_id=100; 44. Given this first section of code: v_result employees.salary%type; Which statement will always return exactly one value? SELECT salary INTO v_result

FROM employees; SELECT salary INTO v_result FROM employees WHERE last_name ='Smith'; SELECT salary INTO v_result FROM employees WHERE department_id = 80; SELECT SUM(salary) INTO v_result FROM employees; (*) Incorrect. Refer to Section 3. 45. Which one of these SQL statements can be directly included in a PL/SQL executable block? SELECT last_name FROM employees WHERE employee_id=100; DESCRIBE employees; UPDATE employees SET last_name='smith'; (*) DROP TABLE employees; 46. The following anonymous block of code is run: INSERT INTO countries (id, name) VALUES ('XA', 'Xanadu'); INSERT INTO countries (id, name) VALUES ('NV','Neverland'); COMMIT; COMMIT; ROLLBACK; What happens when the block of code finishes?

You have nothing new; the last ROLLBACK undid the INSERTs. You have the rows added twice; there are four new rows. You have the two new rows added. (*) You get an error; you cannot COMMIT twice in a row. Incorrect. Refer to Section 3. 47. How many DML statements can be included in a single transaction? Only one None. A transaction cannot include DML statements. A maximum of four DML statements As many as needed (*) Incorrect. Refer to Section 3. 48. PL/SQL extends SQL by including all of the following except: Mark for Review variables conditional statements reusable program units constants nonprocedural constructs (*) Incorrect. Refer to Section 1. 49. A program which specifies a list of operations to be performed sequentially to achieve the desired result can be called: Mark for Review declarative nondeclarative procedural (*)

low level 50. SQL is a common access language for many types of databases, including Oracle. True or False? True (*) False