Saturday, 15 March 2014

Quoting a String Literals in Oracle PL/SQL

Purpose: Oracle 10g Introduces smart way to Quote String Literals. It allows us to define our own string delimiters to remove the need to double up any single quotes. Any character that is not present in the string can be used as the delimiter.

BEGIN
  -- Before 10g.
  DBMS_OUTPUT.put_line('This is Fahd''s Data!');

  -- New syntax.
  DBMS_OUTPUT.put_line(q'#This is Fahd's Data!#');
  DBMS_OUTPUT.put_line(q'[This is Fahd's Data!]');
END;
/

1 comment: