Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: An interest situation using "&" in PLSQL comment line
C Chang <cschang_at_maxinter.net> wrote in message news:<3D058057.2B35_at_maxinter.net>...
> When I added a new private function to the package body, I put a comment
> line at the top like :
> -- This is a function to use ID to search D&B number
> FUNCTION..
>
> However, when I compiled the package body, the compiler asked "the value
> for b:"
> After I entered a number say 5, the compiler responded with
> old 13: -- This is a function to use ID to search D&B number
> new 13: -- This is a function to use ID to search D5 number
> then compile successfully.
> Why the comment line with &B will replace the 5 that I entered? my
> ORacle PL/SQL book does not mention any about this. I thought using the
> "-- ..", compiler is supposed to ignore the line. Does any one know
> this?
>
> C Chang
I was going to say this was documentated behavior since I have known this since version 6; however, when I went to check to see if you could escape the '&' in a quick test Oracle ignored the '&' in a comment. So on version 8.1.7 it appears SQLPlus now is aware of when '&' variables are declared in commented out lines.
UT1> @test4 UT1> set echo on UT1> set verify on UT1> -- UT1> -- input variable &var1 UT1> -- input variable \&var2 UT1> -- UT1> select to_char(to_date('&var3','yyyymmdd'),'MONTH DD YYYY') fromdual;
TO_CHAR(TO_DATE('