Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: substr() woes in GERMAN_GERMANY.WE8MSWIN1252
> Experts,
> I have code like the following which works when NLS_LANG env variable
is
> not set but the moment I set my nls_lang variable to
> GERMAN_GERMANY.WE8MSWIN1252, it fails with " ORA-06502: PL/SQL: numerisch
> oder Wertefehler : Fehler bei Konvertierung von Zeichen zu Zahl "
> Any ides on how to overcome this.
>
> function get_major_version(p_version_str in varchar2)
> return pls_integer as
> l_position integer;
> l_version_int integer;
> begin
> l_position := instr(p_version_str, '.');
> l_version_int := to_number(substr(p_version_str, 1, l_position));
> return l_version_int;
> end;
>
> Thanks,
> Sunil.
>
>
Angelo solved my problem with :
l_version_int := to_number(substr(p_version_str, 1, l_position - 1));
If the '.' is in Position 5, you have to take 4 characters with substr to get the first number in a version-vumber.
Gruss,
Angelo