Traditional "Doubling-Up" of Single Quotes
BEGIN
DBMS_OUTPUT.put_line ('That''s a really funny ''joke''.');
END;
Statement processed.
That's a really funny 'joke'.
Using Paired Symbols
BEGIN
DBMS_OUTPUT.PUT_LINE (
q'[What's a quote among friends?]');
END;
Statement processed.
What's a quote among friends?
Replacement for Single Quote
BEGIN
DBMS_OUTPUT.PUT_LINE (
q'!What's a quote among friends?!');
END;
Statement processed.
What's a quote among friends?
BEGIN
DBMS_OUTPUT.put_line (q'(That's a really funny 'joke'.)');
END;
Statement processed.
That's a really funny 'joke'.
Can't Use One Symbol from Pair
BEGIN
DBMS_OUTPUT.put_line (q'(That''s a really funny ''joke''.(');
END;
ORA-06550: line 2, column 26: PLS-00103: Encountered the symbol "That''s a really funny ''joke''.('); END;" when expecting one of the following: ( ) - + case mod new not null <an identifier> <a double-quoted delimited-identifier> <a bind variable> 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 timestaMore Details: https://docs.oracle.com/error-help/db/ora-06550
BEGIN
DBMS_OUTPUT.put_line (q'#That's a really funny 'joke'.#');
END;
Statement processed.
That's a really funny 'joke'.
Mismatch!
BEGIN
DBMS_OUTPUT.put_line (q'#That's a really funny 'joke'.$');
END;
ORA-06550: line 2, column 26: PLS-00103: Encountered the symbol "That's a really funny 'joke'.$'); END;" when expecting one of the following: ( ) - + case mod new not null <an identifier> <a double-quoted delimited-identifier> <a bind variable> 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 timestampMore Details: https://docs.oracle.com/error-help/db/ora-06550
Works in SQL, Too
SELECT q''All the king's horses''
FROM DUAL
Q''ALLTHEKING'SHORSES'' | All the king's horses |
---|
SELECT q'#All the king's horses#'
FROM DUAL
Q'#ALLTHEKING'SHORSES#' | All the king's horses |
---|
Can't Use a Space
SELECT q' All the king's horses '
FROM DUAL
ORA-00911: invalid characterMore Details: https://docs.oracle.com/error-help/db/ora-00911
Can Use Closing Symbol for Opening
SELECT q'>All the king's horses>'
FROM DUAL
Q'>ALLTHEKING'SHORSES>' | All the king's horses |
---|
SELECT q'>All the king's horses<'
FROM DUAL
ORA-01756: quoted string not properly terminatedMore Details: https://docs.oracle.com/error-help/db/ora-01756
Can't Use Opening Symbol for Closing
SELECT q'<All the king's horses<'
FROM DUAL
ORA-01756: quoted string not properly terminatedMore Details: https://docs.oracle.com/error-help/db/ora-01756
Use Alternative Character Inside String!
BEGIN
dbms_output.put_line (q'PAll the king's horsesP');
END;
Statement processed.
All the king's horses
Works with Dynamic SQL
DECLARE
l_dogs_or_cats VARCHAR2(5) := 'cats';
BEGIN
EXECUTE IMMEDIATE
q'|BEGIN
dbms_output.put_line('All the king''s |'||l_dogs_or_cats||q'|');
END;
|';
END;
Statement processed.
All the king's cats
BEGIN
DBMS_OUTPUT.put_line (q'['Hello,' said the child, who didn't like goodbyes.]');
END;
Statement processed.
'Hello,' said the child, who didn't like goodbyes.
BEGIN
DBMS_OUTPUT.put_line (q'{'Hello,' said the child, who didn't like goodbyes.}');
END;
Statement processed.
'Hello,' said the child, who didn't like goodbyes.
BEGIN
DBMS_OUTPUT.put_line (Q'('Hello,' said the child, who didn't like goodbyes.)');
END;
Statement processed.
'Hello,' said the child, who didn't like goodbyes.
BEGIN
DBMS_OUTPUT.put_line (q'<'Hello,' said the child, who didn't like goodbyes.>');
END;
Statement processed.
'Hello,' said the child, who didn't like goodbyes.