pears.BlobstoreDeleteExternal

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

Original SQL

CREATE FUNCTION "pears"."BlobstoreDeleteExternal"( 
  /* Application Maintained Function / Procedure - DO NOT EDIT*/
  IN "xpath" CHAR(250) ) 
RETURNS INTEGER
NOT deterministic
BEGIN
  DECLARE "delcmd" CHAR(10);
  IF "isnull"("xpath",'') <> '' THEN
    IF "right"("BlobstoreDbFolder"(),1) = '/' THEN -- sp_delete_file AVs if file does not exist so avoid
      SET "delcmd" = 'rm '
    ELSE
      SET "delcmd" = 'del '
    END IF;
    RETURN "xp_cmdshell"("delcmd"+"BlobstoreFullPath"("xpath"),'no_output') -- Will be 0 if the file was successfully deleted 
  ELSE
    RETURN 0
  END IF
END