w3resource

PL/SQL Fundamentals Exercises: PL/SQL block to Neglect Double Quotation Marks in Reserved Word Identifier

PL/SQL Fundamentals: Exercise-4 with Solution

Write a PL/SQL block to show the result to neglect double quotation marks in reserved word identifier.

In the example below  he references should be a quoted user-defined identifier which is a reserved word and also have been neglected to enclose it in double quotation marks.

PL/SQL Code:

DECLARE
  "WORLD" varchar2(20) := 'world';  -- WORLD is not a reserved word
  "DECLARE" varchar2(20) := 'declare';  -- DECLARE is a reserved word
BEGIN
  DBMS_Output.Put_Line(World);      -- Double quotation marks are optional
  DBMS_Output.Put_Line(DECLARE);      -- Double quotation marks are required
end;
/

Sample Output:

ORA-06550: line 6, column 24:
PLS-00103: Encountered the symbol "DECLARE" when expecting one of the following:

   ( ) - + case mod new not null 
    
   table continue avg count current exists max min prior sql
   stddev sum variance execute multiset the both leading
   trailing forall merge year month day hour minute second
   timezone_hour timezone_minute timezone_region timezone_abbr
   time timestamp interval date
   

4. BEGIN
5.   DBMS_Output.Put_Line(World);      -- Double quotation marks are optional
6.   DBMS_Output.Put_Line(DECLARE);      -- Double quotation marks are required
7. end;
8. /

Flowchart:

Flowchart: PL/SQL Fundamentals Exercise - PL/SQL block to Neglect Double Quotation Marks in Reserved Word Identifier

Improve this sample solution and post your code through Disqus

Previous: Write a PL/SQL block to show a reserved word can be used as a user-define identifier.
Next: Write a PL/SQL block to show the result to neglect the case sensitivity of a user defined identifier which is also a reserved word.

What is the difficulty level of this exercise?



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://www.w3resource.com/plsql-exercises/fundamentals/plsql-fundamentals-exercise-4.php