1
Insert into Les_Mills_Customers
( 
    CUSTOMER_ID         
    ,C_USERNAME       
    ,C_TITLE                  
    ,F_NAME                  
    ,L_NAME                  
    ,C_MESSAGE               
    ,C_ADDRESS               
    ,C_GENDER                 
    ,C_MOBILE                  
    ,C_NOTES                 
    ,C_PAYMENT_MODE           
    ,C_EMAIL                 
    ,C_TYPE                   
    ,C_PICTURE                       
    ,C_JOINDATE                     
    ,C_TIMETABLES
 ) 
 values 
 ( 
    50
    ,’A_Joe’
    ,’Mrs’,
    ’Allison’
    ,’Joe’
    ,’RPM’
    ,’Claudelands’
    ,’F’
    ,0273252302
    , ’RPM’
    ,’E’
    ,’123@gmail.com’
    ,'NULL'
    ,’NULL’
    ,To_DATE ('20-02-15','DD-MM-YY'),01
 )

Error at Command Line : 328 Column : 171 Error report - SQL Error: ORA-00917: missing comma 00917. 00000 - "missing comma" *Cause:
*Action:

japzdivino
  • 1,736
  • 3
  • 17
  • 25
Venky
  • 23
  • 1
  • 4
  • I'm guessing there's a... missing comma? – Jeffrey Kemp Oct 13 '15 at 04:48
  • 1
    @JeffreyKemp It's not the comma, rather it's the issue with single-quotation marks. – Lalit Kumar B Oct 13 '15 at 05:40
  • You may be right, but there was insufficient info to tell whether that was a copy-and-paste error (yes, I've seen developers use MS Word to copy-and-paste code!). I've never seen any other scenario where a developer ends up with those stupid "smart quote" characters in their code. – Jeffrey Kemp Oct 14 '15 at 00:46

3 Answers3

3

There are multiple issues with your INSERT statement:

’A_Joe’,’Mrs’,’Allison’,’Joe’,’RPM’,’Claudelands’,’F’,0273252302, 
’RPM’,’E’,’123@gmail.com’,'NULL',’NULL’,To_DATE ('20-02-15','DD-MM-YY')
  1. You must enclose the strings within single-quotation marks. is not single quote, ' is a single quote. Just like you used in the TO_DATE function.

  2. Better use YYYY format, else you will reinvent the Y2K bug.

  3. NULL should not be used within single quotes, just leave the keyword as it is. Else, you will store it as a string, and not the NULL value.

Lalit Kumar B
  • 47,486
  • 13
  • 97
  • 124
1

As noted by @Lalit, you must enclose strings with single quotes. Double quotes can be used in some databases products, with properly settings, but this configuration is not ANSI compatible and must be avoided.

Please do that only in raw SQL statements hand made. Pass strings to SQL commands in executed code will let you vulnerable to SQL injection attacks. Using SQL parameters is the right way.

And beware names like Sant'Anna, with apostrophes in them. Apostrophes are represented as single-quotes very often. In that case, double the apostrophes to represent a single apostrophe.

INSERT INTO TABLE1 (NAME) VALUE ('Sant''Anna')
jramos
  • 128
  • 1
  • 6
  • "*And beware names like Sant'Anna*" No need of all that effort from 10g on wards. See [Quoting string literal technique to avoid errors due to single-quotation marks in the string](http://lalitkumarb.com/2014/12/31/quoting-string-literal-technique-to-avoid-erros-due-to-single-quotation-marks-in-the-string/) And my answer here http://stackoverflow.com/a/27373394/3989608 – Lalit Kumar B Oct 13 '15 at 07:14
0

The INSERT INTO syntax is below, kindly modified your code, you have an issue the way you insert the values, you are not using single quotes (').

Insert into Les_Mills_Customers
( 
    CUSTOMER_ID         
    ,C_USERNAME       
    ,C_TITLE                  
    ,F_NAME                  
    ,L_NAME                  
    ,C_MESSAGE               
    ,C_ADDRESS               
    ,C_GENDER                 
    ,C_MOBILE                  
    ,C_NOTES                 
    ,C_PAYMENT_MODE           
    ,C_EMAIL                 
    ,C_TYPE                   
    ,C_PICTURE                       
    ,C_JOINDATE                     
    ,C_TIMETABLES
 ) 
 values 
 ( 
    50
    , 'A_Joe'
    , 'Mrs'
    , 'Allison'
    , 'Joe'
    , 'RPM'
    , 'Claudelands'
    , 'F'
    , 0273252302
    , 'RPM'
    , 'E'
    , '123@gmail.com'
    , NULL
    , NULL
    , To_DATE ('20-02-15','DD-MM-YY')
    , 01
 )
japzdivino
  • 1,736
  • 3
  • 17
  • 25