Commenting out SQL code [message #18648] |
Fri, 08 February 2002 07:58 |
Brian H
Messages: 2 Registered: February 2002
|
Junior Member |
|
|
When working with MS-SQL server, if a double hyphen "--" is inserted into a SQL statement, it effectively comments out the remaining SQL code...so for example:
SELECT * FROM TABLE 1-- WHERE FIELD1="TEST"
will be understood by MS-SQL server as "Select * FROM TABLE1". I was told that Oracle DB Server does not have this functionality, and when using the SQL*PLUS utility, it infact generates an error message.
However, when running queries from an ASP or PHP page, I have noticed that the "--" appears to have the same effect as in MS-SQL server, effectively ignoring the remaining SQL code. Does anyone out there know if this is a feature or Oracle? Im thinking that is is just like MS-SQL server's comment feature, but that clients like SQL*PLUS just don't support that feature. Please respond.
Thanks,
- Brian
|
|
|
Re: Commenting out SQL code [message #18649 is a reply to message #18648] |
Fri, 08 February 2002 09:16 |
INTROV
Messages: 20 Registered: February 2002
|
Junior Member |
|
|
It sure does work in SQL*PLUS.
SQL> select * from tab -- where tname="Test";
TNAME TABTYPE CLUSTERID
------------------------------ ------- ----------
ACTIVE1 VIEW
ADOORACLE TABLE
AMD_LINK TABLE
AMEND_V VIEW
AMEND VIEW
ANALYSTS TABLE
ANALYST_V VIEW
I am not sure what exactly the problem is. Can you be more specific.
|
|
|
Re: Commenting out SQL code [message #18660 is a reply to message #18649] |
Sat, 09 February 2002 16:06 |
Brian H
Messages: 2 Registered: February 2002
|
Junior Member |
|
|
Your example is correct, but if you were to replace tname with an invalid column name, then SQL*PLUS will respond with a "Invalid Column" message, suggesting that it is actually trying to process the commented out section.
Basically, I am just looking to confirm that the "--" is a documented feature of Oracle's supported SQL syntax like it is with MS-SQL server. Is it?
This is for a study I am doing that compares SQL syntax for various database platforms. Does anyone know of any other DB's that support the "--" SQL comment?
|
|
|