How to insert data with single qoute

INSERT INTO TABLE - SINGLE QUOTE

If a field has a ' (single quote) in it, it will be considered as an end of string when appended right? How do we prevent this?

INSERT INTO TABLE VALUES ('DE''SE'); -> This will insert values DE’SE into the database…

One More Scenario:

Generally in Oracle you also have issue when you are trying to INSERT –

INSERT INTO TABLE VALUES ('DE&P'); - Coz “&” is used for Substitution…

Solution: INSERT INTO TABLE VALUES ('DE\&P'); - “\” ill act as escape char…

Else we can use SET SCAN OFF and the INSERT INTO TABLE VALUES ('DE&P'); -> In this case no escape sequence is required…


 

0 comments: