I have a situation to call the same stored procedure from inside the same procedure. For example, let's say I have a procedure called ConverSubPlans with some parameters. I am doing some validations inside that procedure and based on those, I need to call ConverSubPlans once again within ConverSubPlans. Is it advisable?
You sure can call a procedure from within that same procedure. Such an operation is called "recursion". One procedure recursively calls itself. The big thing to keep in mind is that you need an ending point otherwise the recursive calls will be infinite and never stop. A common recursive procedure or function is to compute the factorial of a number. N factorial (written N!) is defined as N*(N-1)*(N-2)*...*2*1. This also means that N! = N*(N-1)!. So a recursive function is born. Such a recursive function would appear as follows:
CREATE FUNCTION fact (n NUMBER) RETURN NUMBER IS returnVal NUMBER; BEGIN IF (n = 1) THEN returnVal := 1; ELSE returnVal := n*fact(n-1); END IF; RETURN returnVal; END; /
Notice that in the above example, I have a terminating condition (n=1). If this condition is not met, then the function is called again. The same concept applies to procedures. But ensure that you have a terminating condition!