Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Mon, 28 Nov 2005 @ 16:26:46 GMT


     
  <Prev Next>   <<First <Prev Next> Last>>  


Subj:   Re: Exit From Stored Procedure
 
From:   Hough, David

You need to put a label on the first (outermost) BEGIN statement and then use LEAVE to transfer to that label:

     replace procedure p(out returncode integer)

     exit_label:
     begin

     ...

      if (condition) then -- fails
       returncode = 0;
       leave exit_label;
      end if;

     ...

     end;

The LEAVE statement by default (no label) exits only the current block. You can exit any number of levels by targeting specific labels, and you can make the code pretty obscure if you're not careful. I tend to put a single exit label on the first begin and stop there.

The documentation is unclear on this topic - it took us a long time to figure out why the examples in the manual tended to have a lot of labels on BEGIN statements. Apparently, the authors felt they should be there as place holders for future leave statements.


/dave hough



     
  <Prev Next>   <<First <Prev Next> Last>>  
 
 
 
 
 
 
 
 
  
  Top Home Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 15 Jun 2023