w3resource

PL/SQL Fundamentals Exercises: PL/SQL block to show an invalid case-insensitivity

PL/SQL Fundamentals: Exercise-2 with Solution

Write a PL/SQL block to show an invalid case-insensitive reference to a quoted and without quoted user-defined identifier.

When identifier is enclosing with double quotation and reference to the identifier is also double quoted but in different case:

PL/SQL Code:

DECLARE
  "WELCOME" varchar2(10) := 'welcome'; -- identifier with quotation 
BEGIN
  DBMS_Output.Put_Line("Welcome"); --reference to the identifier with quotation and different case
END;
/

Sample Output:

ORA-06550: line 4, column 25:
PLS-00201: identifier 'Welcome' must be declared
ORA-06550: line 4, column 3:
PL/SQL: Statement ignored

2.   "WELCOME" varchar2(10) := 'welcome'; 
3. BEGIN
4.   DBMS_Output.Put_Line("Welcome"); 
5. END;
6. /

When identifier is enclosing without quotation and reference to the identifier is also double quoted but in different case:

PL/SQL Code:

DECLARE
  WELCOME varchar2(10) := 'welcome'; -- identifier without quotation
BEGIN
  DBMS_Output.Put_Line("Welcome"); --reference to the identifier with quotation and different case
END;
/

Sample Output:

ORA-06550: line 4, column 25:
PLS-00201: identifier 'Welcome' must be declared
ORA-06550: line 4, column 3:
PL/SQL: Statement ignored

2.   WELCOME varchar2(10) := 'welcome'; 
3. BEGIN
4.   DBMS_Output.Put_Line("Welcome"); 
5. END;
6. /

Flowchart:

Flowchart: PL/SQL Fundamentals Exercise - Block to learn how to declare a character type variable

Improve this sample solution and post your code through Disqus

Previous: Write a PL/SQL block to calculate the incentive of an employee whose ID is 110.
Next: Write a PL/SQL block to show a reserved word can be used as a user-define identifier.

What is the difficulty level of this exercise?



Follow us on Facebook and Twitter for latest update.