About CAST function in oracle
Now iam migrating my system from SQL to ORACLE 9i.
The sql select query has the following code
CAST(0 as integer)
since Oracle doesnt have integer datatype , how should i change the above code??
should i use number datatype???
CAST( 0 as number) : Is this correct??? or should i use
CAST(0 as number(10,0))
Note: This CASTED value will be stored in a field that is of type INT
If you have:
then the resultant column is of type NUMBER(38) and you can insert into it any number, and rely on Oracle to round to an integer. If you want to do this before inserting, for some reason, then you could just use the ROUND() function.
create table t (col1 int);
Having said that, this also works if you're more comfortable with it:
SQL> select cast(1.49 as number(38)) from dual;
SQL> select cast(1.5 as number(38)) from dual;
Click Here to Expand Forum to Full Width