pears.BlobstoreRelocate
Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace.
Original SQL
CREATE FUNCTION "pears"."BlobstoreRelocate"( /* Application Maintained Function / Procedure - DO NOT EDIT*/ IN "blobclass" CHAR(1),IN "blobid" CHAR(20) ) RETURNS INTEGER NOT deterministic BEGIN DECLARE "z" INTEGER; DECLARE "xpath" CHAR(250); DECLARE "xfolder" CHAR(250); DECLARE "bAlreadyExists" INTEGER; SELECT 1,"trim"("externalfilepath") INTO "bAlreadyExists","xpath" FROM "blobstore" WHERE "class" = "blobclass" AND "id" = "blobid"; IF "bAlreadyExists" IS NULL THEN return-1 -- Row not found END IF; SET "xfolder" = "BlobStoreExtFolder"(NULL); IF "xfolder" IS NULL AND "isnull"("xpath",'') = '' THEN RETURN 0 -- Nothing to do END IF; IF "xfolder" IS NOT NULL AND "isnull"("xpath",'') <> '' THEN RETURN 0 -- Nothing to do END IF; SET "z" = "BlobstoreRead"("blobclass","blobid",NULL); IF "z" IS NULL THEN return-1 -- Row not found (redundant check) ELSE RETURN "BlobStoreWrite"("blobclass","blobid","z",NULL) END IF END