Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

NewLineCharacter of SQL comment in Windows and Unix

Aketi JyuuzouNov 8 2011 — edited Nov 14 2011
In SQL,There are 2 comment syntax.

1 is --
The other is /* */

ex
--This is comment
/* This is comment */
But In Windows,NewLineCharacter is CrLf.
In Unix,NewLineCharacter is LF.

My question is When I Create SQL file in Windows And Run It in Unix,
whether I must not use -- comment or not.
This post has been answered by riedelme on Nov 8 2011
Jump to Answer

Comments

riedelme
Answer
Aketi Jyuuzou wrote:
In SQL,There are 2 comment syntax.

1 is --
The other is /* */

ex
--This is comment
/* This is comment */
But In Windows,NewLineCharacter is CrLf.
In Unix,NewLineCharacter is LF.

My question is When I Create SQL file in Windows And Run It in Unix,
whether I must not use -- comment or not.
You might end up with some cr/lf wierdness depending on how you copied the files over. Generally I have not had any problems. Conversion utiltiies exist for incorrect end-of-line markers and a good editor can fix such problems automatically.

I prefer to use -- for my permanent comments for a practical reason. Once in awhile I'll have a Pl/SQL compilation or run-time error whose location is unknown. The way to solve the problem is to use block comments to eliminate large sections of code. But if you use /* */ in code, the first */ will end the block comment causing new and annoying compilation errors something like
. . .
/*
  x := 15;
  /* reassign x */ <--will end original block comment above (2nd /* will be ignored as it is commented)
  x := 35;

*/ <--will generate compilation error
. . .
Marked as Answer by Aketi Jyuuzou · Sep 27 2020
BluShadow
Aketi Jyuuzou wrote:
In SQL,There are 2 comment syntax.

1 is --
The other is /* */

ex
--This is comment
/* This is comment */
But In Windows,NewLineCharacter is CrLf.
In Unix,NewLineCharacter is LF.

My question is When I Create SQL file in Windows And Run It in Unix,
whether I must not use -- comment or not.
If you create a text file in Windows and then want to use it in Unix you would FTP that file to the unix server from Windows. In doing so you should be transferring the text file in FTP's TEXT mode and not BINARY mode, so any Windows style newlines will be converted to Unix style newlines in the transfer. So, as a result, it shouldn't make a difference.

You'll only break things if you don't transfer your text files correctly when you FTP. ;)
Marwim
You'll only break things if you don't transfer your text files correctly when you FTP
Or if you have to use SFTP, because FTP is not allowed ;-)
It won't correct your line endings.

Regards
Marcus
Aketi Jyuuzou
Thanks for replys.
I will use /* */ comment generally :-)
1 - 4
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Dec 12 2011
Added on Nov 8 2011
4 comments
498 views