Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Help !!!ORA-06502: PL/SQL: numeric or value error: character to number conversion error
Hey JC,
Terry is correct. You're trying to cast a varchar2 (which is a string
field) into a number.
You'll need to convert it (mcn) to a number before selecting it into a
number field (colvalue).
Try doing:
select to_number(mcn) into colvalue from lotz where lot_id=lotid and
rowid=mrn;
Also, when declaring variables, and you know you'll be selecting them or inserting them into a known table, you should declare them as the underlying type of the table you're pulling them from or inserting into:
Instead of declaring:
colvalue number;
You should try:
colvalue lot_final_values_com.ASSAY_VALUE%type; <--this is the
underlying type of the column you'll be using this variable for
This way if you change the datatype in a table, the code that
references it changes implicitly. Believe me, this is an important
practice to follow!!!
If the datatype of lot_final_values_com.ASSAY_VALUE changes eventually,
you'll have to open up this code and modify it.
Hope that helps,
Lisa Ashley Rafter
Received on Tue Mar 28 2006 - 16:15:23 CST