Header Ads Widget

Responsive Advertisement

Module 02: Declaring PL/SQL Variables

Declaring PL/SQL Variables 


01. Examine the code:

SET SERVER OUTPUT ON

DECLARE

v_char_val varchar2(100);

BEGIN

v_char_val:= ‘Hello World’,

DBMS_OUTPUT.PUT_LINE(v_char_val);

END;

/

SET SERVER OUTPUT OFF

This code is stored in a script file name “myproc,sql”.

Which statement executes the code in the script file? 

a. Myproc.sql

b. RUN myproc,sql

c. START myproc.sql

d. EXECUTE myproc.sql

e. BEGIN myproc.sql END; 

Answer: c

02. Which statement is valid within the executable section of PL/SQL block? 

a. BEGIN

emp_rec emp%ROWTYPE

END;

b. WHEN NO_DATA_FOUND THEN

DBMS_OUTPUT.PUT.LINE(‘No records found’);

c. SELECT ename, sal

INTO v_ename, v_sal

FROM emp

WHERE empno = 101;

d. PROCEDURE cal_max (n1 NUMBER, n2 NUMBER, p_max OUT NUMBER)

IS

BEGIN

IF n1 > n2 THEN

p_max := n1;

ELSE

p_max := n2;

END IF;

END;

Answer: c

03. Which is false for anonymous block?

a. Anonymous block are unnamed block

b. You can embed an anonymous block within a precompiled program. 

c. This block store in database for repeated execution

d. Triggers in oracle developer components consist of such block 

Answer: c

04. Which is not a PL/SQL variable?

a. Scalar variable.

b. Composite Variable.

c. Bind Variable.

d. Reference Variable.

Answer: c

05. Which is not the naming rule of a variable?

a. The name of the variables must not be longer than 30 characters.

b. The first character must be a letter.

c. The first character may be number.

Answer: c

06. In which section of a PL/SQL block could a new value be assigned to an initialized variable?

a. END.

b. Header.

c. Executable.

d. Declarative.

e. Exception handling.

Answer: c

07. Developer Janet receives an error due to the following statement in the declaration section:

Pi CONSTANT NUMBER;

The problem is because:

a. There is not enough memory in the program for the constant.

b. There is no value associated with the constant.

c. There is no datatype associated with the constant.

d. PI is reserved word.

Answer: b

08. There are ___ grid infrastructure products in the Oracle10g release:

a. One.

b. Two.

c. Three.

d. Four.

Answer: c

09. Evaluate this PL/SQL block:

DECLARE

v_id_number inventory.id_number%TYPE;

v_manufacturer_id inventory.manufacturer_id%TYPE;

c_quantity CONSTANT NUMBER := 500;

BEGIN

SELECT id_number, manufacturer_id, quantity

INTO v_id_number, v_manufacturer_id

FROM inventory

WHERE quantity > c_quantity;

END;

If you only needed to know the ID_NUMBER and MANUFACTURER_ID values of items with a QUANTITY value greater than 500, which clause contains an error?

a. From Inventory.

b. Where Quanity>q_quantity.

c. Into V_id_Number,V_manufacturer_id.

d. Select Id_number, Manufacturer_id, Quantity.

Answer: d

10. Evaluate this PL/SQL block:

DECLARE

v_quota BOOLEAN := FALSE;

v_stock BOOLEAN :=  NULL;

v_approval BOOLEAN;

BEGIN

v_approval := v_quota AND v_stock;

END;

Which value is assigned to the V_APPROVAL?

a. True.

b. Null.

c. False.

d. None.

Answer: c

11. A student is given a letter grade based on their numeric grade.

Evaluate this IF statement:

IF v_num_grade > 95 THEN

v_letter_grade := 'A';

ELSE

IF v_num_grade > 87 THEN

v_letter_grade := 'B';

ELSE

IF v_num_grade > 80 THEN

v_letter_grade := 'C';

ELSE

v_letter_grade := 'F';

END IF;

END IF;

END IF;

Which numeric grade value would cause V_LETTER_GRADE to be set to 'C'? A student 

a. Any numeric grade less then 100 and greater than 95.

b. Any numeric grade less then 96 and greater than 87.

c. Any numeric grade less then 87 and greater than 80.

d. Any numeric grade greater than 80.

Answer: c

12. Examine the following Part of PL/SQL Block.

Declare

v_salary employees.salray%TYPE NOT NULL;

v_job_id employees.job_id%TYPE;

v_raise v_salary%TYPE;

v_empno employees.employee_id%TYPE NOT NULL: = &p_empno;

Which Variable Declaration is wrong? 

a. v_salary.

b. v_job_id.

c. v_raise.

d. v_empno.

Answer: a

13. Examine the following Declarations.

Declare

x NUMBER(2) : = 1;

y NUMBER(2)  NOT NULL DEFAULT 2;

z y%TYPE;

Which Variable Declaration is wrong?

a. X.

b. Y.

c. Z.

d. None Of Them.

Answer: c

14. You have written the following SQL statement in executable section of a PL/SQL code. Assuming that all the variables are properly declared, which statement is true for the following SQL statement?

BEGIN

SELECT salary, job_id, salary*0.10 as raise

INTO v_salary, v_job_id, v_raise

FROM employees;

END;

a. The Statement will generate an exception because wrong types of variables are used.

b. The Statement will fail because an alias is used in a column.

c. You cannot use a SELECT statement to populate variables.

d. INTO clause can only refer to one variable only.

Answer: a

15. Which Declaration is wrong in the following?

DECLARE

r NUMBER (17, 2) DEFAULT 10;

pi CONSTANT r%TYPE;

Area r%TYPE NOT NULL: = 0;

a. r

b. pi

c. area

d. None of Them.

Answer: b

16. Examine the following Declarations.

DECLARE

v_name VARCHAR2 (50): = ‘CNS LIMITED’;

v_flag BOOLEAN : = (v_name IS NOT NULL);

v_date DATE DEFAULT SYSDATE + TO_DATE(’01-JAN-04’);

v_warranty INTERVAL YEAR(2) TO MONTH : = TO_YMINTERVAL(’01-06’);

Which one is wrongly declared?

a. v_name.

b. v_flag.

c. v_date.

d. v_warranty.

Answer: c

Post a Comment

0 Comments