You create the following PL/SQL block: DECLARE var1 CONSTANT NUMBER := 50; var2 NUMBER := 0; BEGIN SELECT acctno INTO var2 FROM bank_acct WHERE name = 'JORDAN'; var1 :=var2 + 2000; END; Which of the following lines in this block of PL/SQL code will produce an error?

  1. var2 NUMBER := 0;

  2. INTO var2

  3. WHERE name = 'JORDAN';

  4. var1 :=var2 + 2000;

  5. There are no errors in this PL/SQL block


Correct Option: D

AI Explanation

To answer this question, let's go through each option to understand why it is correct or incorrect:

Option A) var2 NUMBER := 0; - This line is correct. It declares a variable var2 of type NUMBER and initializes it with a value of 0. There is no error in this line.

Option B) INTO var2 - This line is correct. It is part of the SELECT statement and specifies that the result of the SELECT query should be stored in the variable var2. There is no error in this line.

Option C) WHERE name = 'JORDAN'; - This line is correct. It is part of the SELECT statement and specifies the condition for the WHERE clause. It filters the rows based on the value of the name column equal to 'JORDAN'. There is no error in this line.

Option D) var1 :=var2 + 2000; - This line will produce an error. The variable var1 is declared as a constant using the CONSTANT keyword. Constants cannot be assigned new values once they are declared. Therefore, trying to assign a new value to var1 will result in an error.

Option E) There are no errors in this PL/SQL block - This option is incorrect. As explained above, the line var1 :=var2 + 2000; will produce an error. Therefore, there is an error in this PL/SQL block.

The correct answer is D. This line (var1 :=var2 + 2000;) will produce an error because var1 is declared as a constant and cannot be assigned a new value.

Find more quizzes: