pears.GetCompanyGroup
Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace.
Original SQL
CREATE FUNCTION "pears"."GetCompanyGroup"( /* Application Maintained Function / Procedure - DO NOT EDIT*/ IN "coid" CHAR(20) ) RETURNS long VARCHAR BEGIN DECLARE "res" long VARCHAR; DECLARE "pid" CHAR(20); DECLARE "I" INTEGER; SET "I" = 1; SELECT "GetCompanyMainParent"("coid") INTO "pid"; IF "pid" IS NOT NULL THEN SET "res" = ''''+"pid"+'''' ELSE SET "res" = ''''+"coid"+'''' END IF; IF "pid" IS NOT NULL THEN CALL "GetLinkedCompanyList"("pid","res","I") ELSE CALL "GetLinkedCompanyList"("coid","res","I") END IF; RETURN "res" exception WHEN others THEN RETURN '''error''' END