sql - Convert Variable varchar2 to number or vice versa | ORA-01722: invalid number -


this question has answer here:

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

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -