Results 1 to 4 of 4
  1. #1
    Join Date
    May 2004
    Posts
    184

    Unanswered: Differences between slash '/' and semicolon

    I encountered a problem in script the other day where I ended the script with with '; new-line /'. So, I just want to make sure I understand the differences between a slash '/' and a semicolon in PL/SQL.

    If I understand it correctly, most of the time these two characters are used interchangably to end a command. However from what I've observed, only semicolons may be used inside of blocks of code that follows a DECLARE...BEGIN...END format.

    Am I correctly understanding the differences between these two? Is there a place in the documentation that covers these subtle differences? I tried searching Google and the Oracle PLS/SQL documentation the other day but couldn't find anything pertinenet and thought this is such a basic concept, it must be covered somewhere.

    Also, I'm used to adding -- comment lines to the right of code in my PL/SQL scripts, however, this caused a script to not work with SQL+ the other day. When I moved the comment to the next line by itself, everything worked fine. Is this typical?

    Thank you.

    Robert

  2. #2
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    Semicolon terminates the SQL statement in both SQL*Plus and PL/SQL. However, if the PL/SQL block ends only with semicolon, it won't run as it requires additional slash at the end (behind the last semicolon).

    You noticed correctly - it is possible to run multiple SQL statements in SQL*Plus environment ending each of them with either semicolon or slash. PL/SQL will not, as you also noticed, accept slash as statement terminator within the PL/SQL block.

    Comments can be added using double minus sign (--) or REM keyword. This is usually used to comment a single line. Multiple comment lines are usually enclosed into /* and */ signs.
    Strange behaviour in your script is, well, strange to me. I didn't notice it before. Personally, I prefer adding comments to their own lines instead of right of code lines - it makes them easier to notice and read.

  3. #3
    Join Date
    May 2004
    Posts
    184
    Littlefoot,

    Thank you very much.

    However, if the PL/SQL block ends only with semicolon, it won't run as it requires additional slash at the end (behind the last semicolon).
    I think I know what you mean, but just to be sure you mean...

    Code:
    DECLARE
    ...
    BEGIN
    ...
    END;
    /
    Correct?

    Thank you.

    Robert

  4. #4
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    Correct

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •