Oracle PL[s]SQL by Example

In order to test your progress, you should be able to answer the following questions.

1)

Which of the following are valid methods to initialize value for a variable?

  1. _____ Declare a sequence

  2. _____ The ":=" syntax

  3. _____ SET SERVEROUTPUT ON

  4. _____ SELECT INTO statement

2)

Which of the following are valid DML or DDL statements in a PL/SQL Block?

  1. _____ INSERT

  2. _____ CREATE TABLE

  3. _____ CREATE SEQUENCE

  4. _____ UPDATE

3)

Complete the following statement with the correct syntax for inserting a sequence in a PL/SQL BLOCK.

INSERT INTO STUDENT (student_id, last_name)

  1. _____ VALUES (student_id_seq.currval, 'Smith');

  2. _____ VALUES ('Smith', student_id_seq.currval);

  3. _____ VALUES (student_id_seq.nextval, 'Smith');

  4. _____ VALUES (nextval, 'Smith');

4)

Which of the following are true statements about an Oracle sequence?

  1. _____ It can use a DML statement only in stand-alone SQL, not in a PL/SQL block.

  2. _____ It is a database object.

  3. _____ It is useful for generating contiguous numbers for invoicing .

  4. _____ It can be used to generate unique primary keys.

Answers appear in Appendix A, Section 4.1 .

Категории