Q
Problem solve Get help with specific problems with your technologies, process and projects.

Error inserting single quote into string

I'm trying to insert a single quote in my string to insert from a SQL prompt. Out of the two methods you suggested,...

one is working but the other one fails. Please help me in understanding the cause of problem.

Here is method 1:

SQL> insert into ACCESS_METHOD_TYPE values(7,'Intr''l','N');
1 row created.

Here is method 2:

SQL> set escape
SQL> insert into ACCESS_METHOD_TYPE values(7,'Intr'l','N');
ERROR:
ORA-01756: quoted string not properly terminated.

The first method works because the consective single quotes indicates that the single quote is part of the text, not a text delimiter.

The second method does not work because I mispoke. You cannot escape the single quote like I originally thought. You'll have to use the consecutive single quotes as in the first method.

Dig Deeper on Using Oracle PL-SQL

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchDataManagement

SearchBusinessAnalytics

SearchSAP

SearchSQLServer

TheServerSide.com

SearchDataCenter

SearchContentManagement

SearchHRSoftware

Close