1

is it possible to continue after an exception is raised. I generated a little example of code which is similar to what I would like to perform. I can only get null values from the first query, the other querys always get me something back.

Case Username = InUser Then
Execute Immediate 
'select Username from Users where Fullname = ' || '''' || InUser || '''' into Varuser;
<< go_on >>
Execute Immediate    
'select Orderno from orders where requester = ' || '''' || VarUser || '''' into VarOrderno

-- other stuff and cases will happen here.

End Case;

EXCEPTION WHEN NO_DATA_FOUND THEN
VarUser := InUser;
Goto go_on;

I know, that if the first dynamic sql doesn't deliver anything, then I use the InUser. Is there something possible?

1 Answer 1

2

Wrap the dynamic select with begin/end and handle the exception there:

  Case Username = InUser Then

    begin
      Execute Immediate 
        'select Username from Users where Fullname = ' || '''' || InUser || '''' into Varuser;
    EXCEPTION WHEN NO_DATA_FOUND THEN
      VarUser := InUser;
    end;

    Execute Immediate    
      'select Orderno from orders where requester = ' || '''' || VarUser || '''' into VarOrderno

  End Case;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.