Google Search

Thursday, July 28, 2011

Quotes & Escape character

If we want to insert a string with quotes then it would be confusing to prefix many escape characters.

I want to insert 'RAGHU' with quotes; We would do as below:

INSERT INTO EMP_TT VALUES (99,'''RAGHU''','A',NULL,NULL,NULL,NULL,NULL);

In 10G and above there is a new way to do:

Just write the normal single quote and then prefix q'| and suffix |' , wherever single quotes is there it will be retained.

INSERT INTO EMP_TT VALUES (99,q'|'RAGHU'|','A',NULL,NULL,NULL,NULL,NULL);

This can be really useful when you are inserting large string with many quotes.

No comments:

Post a Comment