Multi line comment in oracle sqlplus

I have ran the below statements in sqlplus. It inserts duplicate of row 2. In log I have found that i row created after the comment line as well.
So, here I am asking the multi line comment should have a space between /* and comment and */ ?

insert into table values (1);  
insert into table values (2);  
/*comments here*/  
insert into table values (3);  
commit;  

Log:

SQL> insert into table values (1); 

1 row created.  

SQL> insert into table values (2);  

1 row created.  

**SQL> /*comments here*/  

1 row created.**  

SQL> insert into table values (3);  

1 row created.  

select A from table;  
A  
------------  
1  
2  
2  
3  

2 answers

  • answered 2018-04-17 06:12 Littlefoot

    I presume that your code contains an extra forward slash. Have a look:

    SQL> create table test (id number);
    
    Table created.
    
    SQL> insert into test values (1);
    
    1 row created.
    
    SQL> insert into test values (2);
    
    1 row created.
    
    SQL> /* comments
    SQL> here
    SQL> */
    SQL> /                   --> this one; it executes the last command in buffer ...
    
    1 row created.           --> ... and results with yet another "2" begin inserted
    
    SQL> insert into test values (3);
    
    1 row created.
    
    SQL> select * from test;
    
            ID
    ----------
             1
             2
             2
             3
    
    SQL>
    

    Without it, everything is OK:

    SQL> truncate table test;
    
    Table truncated.
    
    SQL> insert into test values (1);
    
    1 row created.
    
    SQL> insert into test values (2);
    
    1 row created.
    
    SQL> /* comments
    SQL> here
    SQL> */
    SQL> insert into test values (3);
    
    1 row created.
    
    SQL> select * from test;
    
            ID
    ----------
             1
             2
             3
    
    SQL>
    

  • answered 2018-04-17 06:54 CHANDRU S

    All,

    I have tried in sqlplus. We need to give the space or new line between /* and following characters. So it treated as multi line comment.

    correct syntax:

    /* comments here */

    or

    /* comments here */

    Wrong syntax:

    /*comments here*/