Exception Handling

Ivan Smahin ivan_smahin at paradigmasoft.com
Mon Feb 16 08:19:30 CST 2009


Hello Bart,

Monday, February 16, 2009, 3:32:48 PM, you wrote:

> 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 ?
Exception which is not caught will be thrown to "upper level"
So if you omit "other" block and something happen - execution will be stopped
and you will get that exception.


> 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 ?

Sure, because you have "when other" block which is for "any exception"

Any not 56503 exception will be caught in "when others" block.
But the only chance to stop looping is raising 56503.
So it will continue iterate cursor until 56503 state reached.



-- 
Best regards,
Ivan Smahin 
Senior Software Engineer
Paradigma Software, Inc
Valentina - The Ultra-Fast Database
http://www.valentina-db.com



More information about the Valentina mailing list