Sybase's Transact SQL language and Informix's SPL will allow stored procedures to contain conditional logic. However, because Sapphire/Web requires information about data returned by a Stored Procedure, a stored procedure must be executed with dummy arguments in order to obtain this information. If conditional logic is performed based upon argument values, the information about the data could be incorrect when dummy arguments are used. Therefore, conditional logic must be performed so SELECT statements always contain the same SELECT LISTS, and one of the conditions checks for null and performs a SELECT with the same SELECT LIST.
The following is an example of a Sybase Stored Procedure using conditional logic that can be interpreted by Sapphire/Web:
CREATE PROCEDURE conlogic
(@which int)
AS
/* notice that each SELECT LIST is the same */
if ( @which = 0 )
select title, price from titles where price > 9.99
else if ( @which != 0 AND @which != null )
select title, price from titles where total_sales > @which
else if ( @which = null ) /* needed for Sapphire/Web */
select title, price from titles