Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Line Comment

Status
Not open for further replies.

WILLIEWANKA

Technical User
May 22, 2003
42
0
0
US
I'm running into unexpected results when I use a line comment at the end of a line

Code:
sel trim('a') || trim('     ') || trim('b') || '    ' || substr('0000000000', 1,4)

Will give me expected results, but

Code:
sel trim('a') || trim('     ') || trim('b') || '    ' || substr('0000000000', 1,4)  --'98.3';

Will do some funky things. Why does a line comment at the end of a line not do what it should do? The manual says teradata should know that anything after "--" is conisdered a null statement.


 
I've noticed this too.

If the expression on the left of -- can be implicitily converted as a number, or is a number (see below), TD might interpret -- as "minus unaryminus expression", which is of course same as plus.

SELECT 8+12 --4

This problem can be avoided by having always an extra hyphen, with numbers too, like this

Code:
sel trim('a') || trim('     ') || trim('b') || '    ' || substr('0000000000', 1,4)  --' '98.3'

Code:
sel trim('a') || trim('     ') || trim('b') || '    ' || substr('0000000000', 1,4)  --' 98.3

So, using --' as the comment token should work.

Cheers

[blue]Backup system is as good as the latest recovery[/blue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top