Why do C-style comments make insert statement run twice?

后端 未结 1 1646

To make a long story short, I started getting ORA-00001 primary key violations and I tracked down the issue to the fact that some of my INSERT INTO statements were

相关标签:
1条回答
  • 2021-01-23 20:33
    /* This is a comment */
    

    Just make sure you have a space after /* ,
    So it is treated as a single/multi line comment. And not mean to execute the last stored PL/SQL or SQL

    To put it in detail.

    What ever SQL*Plus interprets after / is ignored and it blindly pushes it's cached block into the server. Except for /* followed by a new line or space.

    SQL> SELECT * FROM DUAL;
    
    D
    -
    X
    
    SQL> /*t*/
    
    D
    -
    X
    
    SQL> /*
    SQL> */
    SQL> /
    
    D
    -
    X
    
    SQL> /*s
    
    D
    -
    X
    

    From Document:

    You must enter a space after the slash-asterisk(/*) beginning a comment.

    0 讨论(0)
提交回复
热议问题