Is this even possible. I’ve scoured the internet and can’t find an answer.
BEGIN
Declare WhereClause VarChar(4000);
Declare Main VarChar(3500);
Declare SubMain VarChar(500)
BEGIN
Select Prev_Month_St_Dt Into BegOfPrevMon From TMSR_DATA_DATES;
Select Prev_Month_End_Dt Into EndOfPrevMon From TMSR_DATA_DATES;
Select Month(Prev_Month_St_Dt) Into CurMon From TMSR_DATA_DATES;
Select Day(Prev_Month_End_Dt) Into LastDay From TMSR_DATA_DATES;
Set Main = “Yada Yada…” —about 50 lines of codes
Set SubMain to some other based on the select into values…about another 50 lines of code…
Set WhereClause = Main || SubMain;
END;
BEGIN
DECLARE C1 CURSOR WITH RETURN TO CLIENT FOR
Select yada yada yada From – 500 lines of code
Insert the WhereClause here
UNION
Select yada yada yada From – 500 lines of code
Insert the WhereClause here
OPEN C1;
END;
END!