Your SQL*Plus session has substitution variables turned off, so the '&a' is being treated as a literal string, and it isn't prompting you for the value. In a simplified version:
set define off
declare
i integer := to_number('&a');
begin
null;
end;
/
declare
*
ERROR at line 1:
ORA-06502: PL/SQL: numeric or value error: character to number conversion error
ORA-06512: at line 2
To fix it, turn substitution variables back on:
set define &
Then it works:
declare
i integer := to_number('&a');
begin
null;
end;
/
Enter value for a:
If I enter 1:
PL/SQL procedure successfully completed.
You don't need the quotes, or the to_number(), unless you're using group seperators (and then you'd need to supply a format model too). You can just do:
declare
i integer := &a;
begin
null;
end;
/
As you have it you're doing an unnecessary implicit string-to-number conversion.
If you haven't explicitly turned them off, then you probably have a site or user profile that is doing the set define off, among other configuration settings. it's probably doing that for a reason, but if you currently only have a site profile then you could create your own user profile to override that. Just be aware of the effect of anything you change; you may have other scripts that rely on it being off, e.g. if you have data that has ampersands and it's been disabled to prevent issues interpreting those.
aandbin both cases; and why are you quoting them in the assignment if they are numbers? If the values have group or decimal separators (though decimal doesn't make sense if they are integers), are your NLS settings the same, particularly NLS_NUMERIC_CHARACTERS?NLS_NUMERIC_CHARACTERS. When I searched the net, they are providing commands for changing the character. What is the command to check for the current character.select value from nls_session_parameters where parameter = 'NLS_NUMERIC_CHARACTERS';. It's only relevant if you're entering a value with a separator, e.g.1,001or1.001rather than just1001. That NLS setting will determine whether it's interpreted as one thousand and one, or one and a little bit. Is that what you're doing? It might explain the error - if you're passing a group separator then you will get that error. Please show what values you are using.NLS_NUMERIC_CHARACTERS. and when I execute the command,.,is the output in both places.show definehave in SQL*Plus? Sounds like it might be off, and it's trying to convert the&ato a number with treating it as a substitution variable.