Skip to content
Advertisement

ORA-01756: quoted string not properly terminated, do i need to add quote on the phone number, why?

Can anyone explain this error for me?

Advertisement

Answer

There are two issues here :

  • you are inserting a string that contains an embedded single quote : 'Dave's Sub Shop'. The glitch shows up in any decent text editor (including SO’s). You need to escape the quote : 'Dave''s Sub Shop'

  • the phone_number column is declared as number(10), however what you are trying to insert does not look like one : 555-333-4545. You should change the column datatpe to varchar(12). Then you will need to quote the values that you insert.

Demo on DB Fiddle :

NB : another solution would be to convert the phone number to a number datatype before inserting it (by removing the embedded - for example), but I would not recommend it, since phone numbers are actually not numbers : they may have meaningful leading zeros, and may contain non-digit characters ((), +, …)

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement