Traditional "Doubling-Up" of Single Quotes
BEGIN
DBMS_OUTPUT.put_line ('That''s a really funny ''joke''.');
END;
Using Paired Symbols
BEGIN
DBMS_OUTPUT.PUT_LINE (
q'[What's a quote among friends?]');
END;
Replacement for Single Quote
BEGIN
DBMS_OUTPUT.PUT_LINE (
q'!What's a quote among friends?!');
END;
BEGIN
DBMS_OUTPUT.put_line (q'(That's a really funny 'joke'.)');
END;
Can't Use One Symbol from Pair
BEGIN
DBMS_OUTPUT.put_line (q'(That''s a really funny ''joke''.(');
END;
BEGIN
DBMS_OUTPUT.put_line (q'#That's a really funny 'joke'.#');
END;
Mismatch!
BEGIN
DBMS_OUTPUT.put_line (q'#That's a really funny 'joke'.$');
END;
Works in SQL, Too
SELECT q''All the President's men''
FROM DUAL
Q''ALLTHEPRESIDENT'SMEN'' | All the President's men |
---|
SELECT q'#All the President's men#'
FROM DUAL
Q'#ALLTHEPRESIDENT'SMEN#' | All the President's men |
---|
Can't Use a Space
SELECT q' All the President's men '
FROM DUAL
Can't Use Closing Symbol for Opening
SELECT q'>All the President's men>'
FROM DUAL
Q'>ALLTHEPRESIDENT'SMEN>' | All the President's men |
---|
SELECT q'>All the President's men<'
FROM DUAL
SELECT q'<All the President's men<'
FROM DUAL
Use Alternative Character Inside String!
BEGIN
dbms_output.put_line (q'PAll the President's menP');
END;
Works with Dynamic SQL
DECLARE
l_men_or_women VARCHAR2(5) := 'men';
BEGIN
EXECUTE IMMEDIATE
q'|BEGIN
dbms_output.put_line('All the President''s |'||l_men_or_women||q'|');
END;
|';
END;
BEGIN
DBMS_OUTPUT.put_line (q'['Hello,' said the man, who didn't like goodbyes.]');
END;
BEGIN
DBMS_OUTPUT.put_line (q'{'Hello,' said the man, who didn't like goodbyes.}');
END;
BEGIN
DBMS_OUTPUT.put_line (Q'('Hello,' said the man, who didn't like goodbyes.)');
END;
BEGIN
DBMS_OUTPUT.put_line (q'<'Hello,' said the man, who didn't like goodbyes.>');
END;