Din
Din

Reputation: 223

How to insert a value with embedded single quotes in Oracle

How to insert the following ENTIRE string to a varchar2(31) field.

u1salcd||' '||dmname

I get the following error message.

INSERT INTO EXPORTS_DEFS ( EXPORT_ID, EXPORT_ID2  ) VALUES ('ucsalcd||' '||dmname','L');
Error at Command Line:1 Column:71
Error report:
SQL Error: ORA-00917: missing comma
00917. 00000 -  "missing comma"
*Cause:    
*Action:

Upvotes: 2

Views: 56109

Answers (2)

user330315
user330315

Reputation:

This has nothing to do with the || symbol. You need to escape the embedded single quotes. This is done by using two single quotes:

INSERT INTO EXPORTS_DEFS 
 (EXPORT_ID, EXPORT_ID2  ) 
VALUES 
 ('u1salcd||'' ''||dmname','L');

Here is an SQLFiddle example: http://sqlfiddle.com/#!4/15c7f/1

Upvotes: 3

TechDo
TechDo

Reputation: 18659

Please try:

INSERT INTO EXPORTS_DEFS ( EXPORT_ID, EXPORT_ID2  ) 
VALUES ('ucsalcd||'' ''||dmname','L');

Upvotes: 4

Related Questions