Exit from stored procedure in sybase -


i getting parameters in stored procedure. before operating on these parameters, want validate them , if parameters not per requirement want exit stored procedure error message.

sample code:

   create proc abcd     (        zip   varchar(20),        name   varchar(20),        network varchar(1)     )      -- validation section     if (len(zip)<>5 or len(zip)<>9)     begin           print "the zip must of 5 or 9 characters"           <---- how exit here--->     end     if (len(name)<2)     begin           print "the name must of @ least 2 characters"           <---- how exit here--->     end  ---- main code 

how can exit procedure once error mentioned above?

you can use return command below

-- validation section if (len(zip)<>5 or len(zip)<>9) begin       print "the zip must of 5 or 9 characters"       return 1 end if (len(name)<2) begin       print "the name must of @ least 2 characters"       return 2 end  return 0 -- on end of procedure  

to catch result can use code:

declare @procresult int execute @procresult = abcd @zip = ..., @name...   select @procresult 

Comments

Popular posts from this blog

smartface.io - Proper way to change color scheme for whole application -

javascript - three.js lot of meshes optimization -

Email notification in google apps script -