Exception Handling

Bart Pietercil bart.pietercil at cognosis.be
Mon Feb 16 07:32:48 CST 2009


Hi Ivan,

yes this was what I wanted.
Now I have another  question on exceptions:


let's say we have this:


declare cur1 cursor for select ......

open cur1

fetch first
loop
begin
do something
fetch next
exception
when 56503 then leave
when others then
print

end loop
close cur1
end

declare cur2 cursor for select .....
loop again.....

.....

If  an exception occurs (other then 56503) will the cursor than get  
closed.
What happens when the exception has occured ? Execution of script is  
halted ? So cur1 is still open ?
Or  are cursors automatically closed when an exception occurs ?

When an exception occurs (other than 56503) will cur2 ever be  
created ? Only if I put in the when others then.... also a leave  
command ?


tia


Bart Pietercil


On 16 Feb 2009, at 10:24, Ivan Smahin wrote:

> Hello Ivan,
>
> Monday, February 16, 2009, 10:40:28 AM, you wrote:
>
>> Hello Bart,
>
>> Friday, February 13, 2009, 5:06:18 PM, you wrote:
>
>>> Hi List, Ruslan,
>
>
>>> In an exception block within a stored procedure can I do this:
>>> begin
>
>
>>> exception
>>> when 56503 then
>>>        leave
>>> when others then
>>>        print 'Error has occured: procedurename: ' || err_name
>
>
>>> end
>
>>> the question is about the err_name; can I use err_name to have
>>> description of the exception (ie: ERR_CONSTRAINT_UNIQUE_VIOLATION) ?
>
>>> This way we could use the log to correct untrapped exceptions in  
>>> an SP
>
>> Sorry for delay.
>
>>         print 'Error has occured: procedurename: ' ||  
>> Hex(@@LastErrorNumber)
>
>
> Not exactly what you want...
>
> It should be something like this one:
>
> select fld_ErrorName from (SHOW vERRORS) WHERE fld_ErrorCode =  
> @@LastErrorNumber
>




More information about the Valentina mailing list