All Forums Database
paddyr1990 3 posts Joined 02/13
06 May 2015
Common COALESCE for STRING,INTEGER,DATE,TIME

Below is the statement that is a part of a stored procedure.
 
SET NOTNULLKEYLIST=' COALESCE('||OREPLACE(pkcollist,',',',''-1'') ,COALESCE(')||',''-1'') ';
 
pkcollist is a paramater passed to the Stored Procedure that contains a the names of the fields separated by commas. pkcollist can contain fileds of any data type. 
Say I pass the patameter as 'APPLICATION_NUM, ORDER_NB' , since both are integers, it doesnt throw an error. But if I pass the parameter as 'APPLICATION_NUM, ORDER_NB,EVENT_DATE' it fails throwing an error 'Datatype Mismatch in THEN/ELSE expression.'
I need to use a generic COALESCE function that can handle any data type. Can someone help me with this.
 
 

You must sign in to leave a comment.