pears.GetLinkedCompanyList

Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace.

CREATE PROCEDURE "pears"."GetLinkedCompanyList"( 
  /* Application Maintained Function / Procedure - DO NOT EDIT*/
  IN "ParentCompID" CHAR(20),INOUT "CurrentList" long VARCHAR,INOUT "lc" INTEGER ) 
BEGIN
  -- terminating condition
  IF NOT EXISTS(SELECT "companyid" FROM "company" WHERE "parentcompanyid" = "ParentCompID") THEN
    RETURN
  END IF;
  IF "lc" > 1000 THEN
    RETURN
  END IF;
  -- recursive calls in cursor
  FOR "companies" AS "compcursor" no scroll cursor FOR
    SELECT "companyid" AS "cid"
      FROM "company"
      WHERE "parentcompanyid" = "ParentCompID" FOR READ ONLY do
    SET "lc" = "lc"+1;
    IF "CurrentList" IS NOT NULL THEN SET "CurrentList" = "CurrentList"+','
    END IF;
    SET "CurrentList" = "CurrentList"+''''+"cid"+'''';
    CALL "GetLinkedCompanyList"("cid","CurrentList","lc")
  END FOR
END
GO
 
COMMENT TO PRESERVE FORMAT ON PROCEDURE "pears"."GetLinkedCompanyList" IS 
{CREATE PROCEDURE GetLinkedCompanyList 
 
/* Application Maintained Function / Procedure - DO NOT EDIT*/
 
(IN ParentCompID CHAR(20),INOUT CurrentList long VARCHAR,INOUT lc INTEGER)
BEGIN
  -- terminating condition
  IF NOT EXISTS(SELECT companyid FROM company WHERE parentcompanyid = ParentCompID) THEN
    RETURN
  END IF;
  IF lc > 1000 THEN
    RETURN
  END IF;
  -- recursive calls in cursor
  FOR companies AS compcursor no scroll cursor FOR
    SELECT companyid AS cid FROM
      company WHERE
      parentcompanyid = ParentCompID FOR READ ONLY do
    SET lc=lc+1;
    IF CurrentList IS NOT NULL THEN SET CurrentList=CurrentList+','
    END IF;
    SET CurrentList=CurrentList+''''+cid+'''';
    CALL GetLinkedCompanyList(cid,CurrentList,lc) END FOR
END
}
  • database/procedures/pears_getlinkedcompanylist.txt
  • Last modified: 2026/08/07 19:24
  • by 127.0.0.1