skipping errors with insert select [message #262915] |
Tue, 28 August 2007 08:43 |
123soleil
Messages: 35 Registered: July 2006
|
Member |
|
|
Hello,
I'm trying to write a script that might give errors, but I dont want to raise an exception because then no data will be inserted.
What I need is for the script to insert all entries it can and to tell me which ones have failed (for example in a log table)
begin
INSERT INTO k.migr (i_key, i_key_id, i_key_val)
SELECT i_key,
case
when i_obj_key='IK' then '88'
when i_obj_key='SNM' then '5503'
when i_obj_key='SWI' then '73'
else -- Here i need to write some sort of error message... how?
end case,
i_key_val from k.migr_ld;
end;
Thanks!
|
|
|
|
|
Re: skipping errors with insert select [message #262942 is a reply to message #262915] |
Tue, 28 August 2007 10:04 |
123soleil
Messages: 35 Registered: July 2006
|
Member |
|
|
Thank you for your replies. I don't think I expressed myself correctly sorry.
What I am trying to do is to map data. I get codes in a string format and I wish to map them in a numerical format (IK becomes 88, SNM -> 5503, etc...). These codes will then be inserted in another table.
Now let's say I get an unexpected value (for example PKY). I would like to have an error message "Error: unexpected value PKY" (This would ideally be done in the "else" case). If I raise a custom error, it will do a rollback which is exactly what i would like to avoid... It should just skip that entry and continue.
Thanks
[Updated on: Tue, 28 August 2007 10:07] Report message to a moderator
|
|
|
|
Re: skipping errors with insert select [message #263139 is a reply to message #262962] |
Wed, 29 August 2007 03:34 |
123soleil
Messages: 35 Registered: July 2006
|
Member |
|
|
great, that seems to work thank you!
But it doesn't seem to reference the line where error occured?
Another nice-to-have feature would be to have a custom error message instead of the "divisor is equal to zero" message... is there a possibility?
thanks again
|
|
|
|
|