create PROCEDURE B2C_CM
DYNAMIC RESULT SETS 1
if ((v_StartDate = 0 or v_EndDate = 0) and v_CID <> 0) then
select a.CID, a.ContactDate_ID GrantDate_ID, a.NumberOfPoints NumOfGoldTokens
from DWH.DW_Contacts a
where a.CampaignCode = 1111
and a.ContactDate_ID >= 20170329
and a.CID = v_CID
and a.GlobalContactType_ID = 43
and a.OfferCode_ID = 495
order by CID,GrantDate_ID;
select CID from DWH.DW_Contacts a
Please help with this error - i don't understand what's wrong...
I thing in stored procedure when you use SELECT keyword, it can't be use alone (without inserting to table or variable).
hi, tnx, but i think the problem is in this lines:
select CID=0, GrantDate_ID=0, NumOfGoldTokens=0
To return a result set, you must declare a cursor for the SELECT statement and OPEN the cursor.