I ended up creating following function by connecting to Data Dictionary but I got the error.
CREATE FUNCTION GetReport_Meds ( PID varchar(15) ) RETURNS String BEGIN DECLARE Meds String; DECLARE CurMeds cursor AS SELECT med_code from medication where patient = TRIM(PID) and end_date is null; Meds = ""; OPEN CurMeds; WHILE FETCH CurMeds DO Meds = TRIM(Meds)+TRIM(CurMeds.med_code)+","; END WHILE; CLOSE CurMeds; RETURN LEFT(Meds,LEN(Meds)-1); END;
poQuery: Error 7200: AQE Error: State = HY000; NativeError = 5054; [iAnywhere Solutions][Advantage SQL][ASA] Error 5054: The command cannot be completed with the current user permissions. Cannot create function object in the data dictionary.
I have requested the company who created this db/app to add this function in the db so I can use it, lets see where I land.