database:procedures:pears_mergequestionnaire



pears.MergeQuestionnaire

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

CREATE PROCEDURE "pears"."MergeQuestionnaire"( 
  /* Application Maintained Function / Procedure - DO NOT EDIT*/
  IN "slikelocation" CHAR(3),IN "ssourceid" CHAR(20),IN "stargetid" CHAR(20) ) 
BEGIN
  UPDATE "tagvalue" AS "tv" KEY JOIN "tag"
    SET "tv"."id" = "stargetid"
    WHERE "tag"."tagtype" IN( 'L','S','G' ) 
    AND "tv"."taglocation" LIKE "slikelocation" AND "tv"."id" = "ssourceid"
    AND NOT EXISTS(SELECT "id" FROM "tagvalue"
      WHERE "taglocation" = "tv"."taglocation" AND "tagid" = "tv"."tagid" AND "tagchoiceid" = "tv"."tagchoiceid"
      AND "id" = "stargetid");
  UPDATE "tagvalue" AS "tv" KEY JOIN "tag"
    SET "tv"."id" = "stargetid"
    WHERE "tag"."tagtype" NOT IN( 'L','S','G' ) 
    AND "tv"."taglocation" LIKE "slikelocation" AND "tv"."id" = "ssourceid"
    AND NOT EXISTS(SELECT "id" FROM "tagvalue"
      WHERE "taglocation" = "tv"."taglocation" AND "tagid" = "tv"."tagid"
      AND "id" = "stargetid");
  DELETE FROM "tagvalue" WHERE "taglocation" LIKE "slikelocation" AND "id" = "ssourceid"
END
GO
 
COMMENT TO PRESERVE FORMAT ON PROCEDURE "pears"."MergeQuestionnaire" IS 
{CREATE PROCEDURE MergeQuestionnaire 
 
/* Application Maintained Function / Procedure - DO NOT EDIT*/
 
(IN slikelocation CHAR(3),IN ssourceid CHAR(20),IN stargetid CHAR(20))
BEGIN
  UPDATE tagvalue AS tv KEY JOIN tag SET
    tv.id=stargetid
    WHERE tag.tagtype IN('L','S','G')
    AND tv.taglocation LIKE slikelocation AND tv.id=ssourceid
    AND NOT EXISTS(SELECT id FROM tagvalue
      WHERE taglocation=tv.taglocation AND tagid=tv.tagid AND tagchoiceid=tv.tagchoiceid
      AND id=stargetid);
  UPDATE tagvalue AS tv KEY JOIN tag SET
    tv.id=stargetid
    WHERE tag.tagtype NOT IN('L','S','G')
    AND tv.taglocation LIKE slikelocation AND tv.id=ssourceid
    AND NOT EXISTS(SELECT id FROM tagvalue
      WHERE taglocation=tv.taglocation AND tagid=tv.tagid
      AND id=stargetid);
  DELETE FROM tagvalue WHERE taglocation LIKE slikelocation AND id=ssourceid
END
}
  • database/procedures/pears_mergequestionnaire.txt
  • Last modified: 2026/08/07 19:24
  • by 127.0.0.1