sql - Convert Variable varchar2 to number or vice versa | ORA-01722: invalid number -
this question has answer here:
- check if “it's number” function in oracle 15 answers
i'm migrating column 1 sql table update command. while updating below query, ora-01722: invalid number error
. issue pid
field in project table has varchar2 datatype , xproject_id in docmeta table has number data type. options have migrate data now.
begin x in(select projecttype,pid project) loop update docmeta d set d.xprojecttype=x.projecttype d.xproject_id=x.pid , x.projecttype not null; end loop; end;
you can catch exception:
begin x in (select projecttype ,pid project procecttype not null) loop begin update docmeta d set d.xprojecttype = x.projecttype d.xproject_id = x.pid; exception when others if sqlcode = -1722 null; else raise; end if; end; end loop; end;
also note have moved filter on non-null projecttype query.
Comments
Post a Comment