Explicit and implict convertion of datatypes
Oracle implicitly converts datatypes during assignment if not explicitly specified. Which in your opinion should we adhere to when coding, implicit conversion done by oracle or explicitly specified by the developer?
eg:
declare
l_chr varchar2(10);
l_num number(10);
begin
l_num := 100;
l_chr := l_num; -- implicit conversion (or)
l_chr := to_char(l_num); -- explicit conversion
dbms_output.put_line(l_chr);
.....
end;
Oracle's conversion methodology may change over the releases. For example the following is the result of different behaviour in Oracle versions. White space assigned to a number was acceptable in Oracle 7.3, but not so in Oracle 8i.
eg:
declare
l_num number;
begin
l_num := ' ';
end;
In oracle 7.3.4, the above code returns:
PL/SQL procedure successfully completed.
In Oracle 8.1.7, the above code returns:
ERROR at line 1:
ORA-06502: PL/SQL: numeric or value error: character to number conversion error
ORA-06512: at line 4
Oracle recommends to carry out explicit conversion.
Tell your code what it has to do, be explicit.
Best viewed in medium text size. Please refresh this page (F5) to view the latest information. This page was created on 15-dec-2000 and last updated on 15-dec-2000.
please forward all queries to amar_padhi@fastmail.fm