====== pears.BlobstoreRead ======
Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace.
===== Original SQL =====
COMMENT TO PRESERVE FORMAT ON PROCEDURE "pears"."BlobstoreRead" IS
{create function BlobstoreRead
/* Application Maintained Function / Procedure - DO NOT EDIT*/
(in blobclass char(1),in blobid char(20),in requestedby char(15))
returns integer
not deterministic
begin
declare z integer;
declare xpath char(250);
declare dat long binary;
select isnull(zipped,0),trim(externalfilepath),blob into z,xpath,dat from blobstore where class = blobclass and id = blobid;
if z is null then
return null // No row
end if;
if dat is null and isnull(xpath,'') <> '' then
set dat=xp_read_file(BlobstoreFullPath(xpath))
end if;
if dat is null then
return null // No blob
end if;
if varexists('iqblobtemp') = 0 then
create variable iqblobtemp long binary
end if;
set iqblobtemp=dat;
if requestedby is not null then
update blobstore set accessedby = requestedby,accessedat = current timestamp where class = blobclass and id = blobid
end if;
return z
end
}