Friday, September 5, 2008

Funny thing when use a package global variable through select

update ( select /*+ ALL_ROWS */ t.discography_intf_id, t.intf_status_id, t.err_mesg from da_discography_intf t, artist t1 where t.primary_artist_id = t1.artist_id and t.primary_artist_name <> t1.display_name ) set intf_status_id = (select da_discography_utl.get_intf_status_id( da_discography_constants.gc_intf_status_load_err) from dual), err_mesg = (select da_discography_constants.gc_intf_status_wrong_art_msg from dual);

This query causes ora-06502 error. My guess is when you use select from dual to get a constant value, it loses the sense of the length of the value, so will give a numeric error.
So don't select a function with a global constant.

1 comment:

Fudong Li said...

I found out it was caused by a package constant, which I defined with 16 characters but actually has more than 16 characters. It is funny Oracle did not display this as an error. But when you run it, it will give you error for one time a session.