Friday, July 29, 2005

Tom Kyte

Tom Kyte was at OOUG in Columbus. He's even better in person than the is at AskTom.

Here's one little gem he gave that will change your life, if you're an oracle person. Or at least hurry you to upgrade to 10g, where it can be used.

The magic is q'| |'.

INSERT INTO my_tbl(str) VALUES
(q'|I don't have to worry when I write a string like
'INSERT 'r2d2' INTO droids'|');
INSERT INTO my_tbl(str) VALUES
(q'|It's almost as good as Perl!|');

SELECT * FROM my_tbl;

STR
-----------------------------------------------------
I don't have to worry when I write a string like
'INSERT 'r2d2' INTO droids'

It's almost as good as Perl!

All those single-quote single-quote, single-quote single-quote single-quote monstrosites we used to make to get quote marks into SQL strings are history. Let the people rejoice!

No comments: