Power to Build

Home » CodeProject » Oracle SQL*Plus – Forward Slash contd…

Oracle SQL*Plus – Forward Slash contd…



Recently while working with a coworker I saw trouble with using Forward slash, first hand. He was running some old scripts. The original developer probably ran these in some other tool (typically other tools are more pardoning than SQL*Plus.

One of the scripts had DDLs and had some code commented out. Incidentally, the original developer used C-Style comments (those in between /* … */). And inadvertently, he created a Forward slash problem!!!!

I am including a very simple script below to illustrate this:

create table t (c VARCHAR2(30));
/* drop table t;

First line there is a DDL that creates a new table. There is the C-Style comment.

SQL> create table t (c VARCHAR2(30));
/* drop table t;

create table t (c VARCHAR2(30))
ERROR at line 1:
ORA-00955: name is already used by an existing object

No way!!!! How come?? Well, you guessed it! It’s because of a Forward slash the developer left in the script inadvertently. Remember C-Style comment starts with Forward slash?? Forward slash means "RUN" to SQL*Plus. It tried to execute the previous DDL when it saw /* on the second line, thus the Error!

Funnily, this doesn’t happen in a DML nor in a PL/SQL block. So, if your scripts have DDLs beware of Forward slashes in any shape or form!!!


Comments, please?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: