pears.GetInvoicePDF
Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace.
Original SQL
CREATE FUNCTION "pears"."GetInvoicePDF"( /* Application Maintained Function / Procedure - DO NOT EDIT*/ IN @InvoiceNumber CHAR(20),IN @DocumentID CHAR(20) ) RETURNS long VARCHAR BEGIN DECLARE @rootpath CHAR(250); DECLARE @AccountCode CHAR(12); DECLARE @InvoiceDate DATE; IF "isnull"(@InvoiceNumber,'') = '' AND "isnull"(@DocumentID,'') = '' THEN RETURN NULL END IF; SET @RootPath = "WPKMaintainGetSwitchValue"('PDFINDB','GLOBAL','LITERAL'); IF "right"(@rootpath,1) <> '\\' THEN SET @rootpath = "string"(@rootpath,'\\') END IF; CASE WHEN "isnull"(@InvoiceNumber,'') <> '' THEN SELECT "AccountCode","DocumentDate" INTO @AccountCode,@InvoiceDate FROM "IQACDocument" WHERE "OurRef" = @InvoiceNumber AND "DocumentClass" = 'Invoice' WHEN "isnull"(@DocumentID,'') <> '' THEN SELECT "AccountCode","DocumentDate","OurRef" INTO @AccountCode,@InvoiceDate,@InvoiceNumber FROM "IQACDocument" WHERE "DocumentID" = @DocumentID END CASE; RETURN("string"(@rootpath,@AccountCode,'\\',"dateformat"(@InvoiceDate,'yyyymmdd'),'\\',@InvoiceNumber,'.pdf')) END