Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle pl-sql escape character (for a " ' ")

When I am trying to execute INSERT statement in oracle, I got SQL Error: ORA-00917: missing comma error because there is a value as Alex's Tea Factory in my INSERT statement.

How could I escape ' ?

like image 986
Bishan Avatar asked Jul 30 '12 07:07

Bishan


People also ask

How do I escape a special character in PL SQL?

Use the backslash character to escape a single character or symbol. Only the character immediately following the backslash is escaped.

How do I escape special characters in Oracle query?

Use braces to escape a string of characters or symbols. Everything within a set of braces in considered part of the escape sequence. When you use braces to escape a single character, the escaped character becomes a separate token in the query. Use the backslash character to escape a single character or symbol.

How do I escape a character in SQL?

In ANSI SQL, the backslash character (\) is the escape character. To search for data that begins with the string \abc , the WHERE clause must use an escape character as follows: ... where col1 = '\\abc';

What is a (+) in SQL?

Outer Join Operator (+) - Oracle to SQL Server Migration Oracle outer join operator (+) allows you to perform outer joins on two or more tables. Quick Example: -- Select all rows from cities table even if there is no matching row in counties table SELECT cities. name, countries.


2 Answers

To escape it, double the quotes:

INSERT INTO TABLE_A VALUES ( 'Alex''s Tea Factory' ); 
like image 142
Codo Avatar answered Oct 11 '22 22:10

Codo


In SQL, you escape a quote by another quote:

SELECT 'Alex''s Tea Factory' FROM DUAL 
like image 21
Thilo Avatar answered Oct 11 '22 22:10

Thilo