I cannot touch the VB Code to make this part easier on myself. It's handled by a very small number of Devs out of State. So this is a SQL issue only. I know I could make the change in VB (so don't throw that as a solution) but, us Analysts can't. It's a multi billion dollar Corp and changes like this would go through a rigorous Approval process and would probably be denied. But, we have the freedom to make Custom Tables/Fields [in the Application] and Edits on a DB Level.
My Goal is to Create a function that Grabs RAW SQL from a Field on the Front End and pass it through as an Argument to prove if it's valid to "Print a Document". It returns True or False. If True, the document prints.
Example:
The Script: This will take the SQL as hmy from property where scode = '26thst'
in the Argument.
The Function: Grabs the SQL and just needs to check if the SQL Exists and pass back True or False
I have made the Function and it's legal but, does not seem to produce results. The Document gets skipped. I'm kind of stumped on an OOP process for SQL to prove True/False on an Execute @SQL
CASE
WHEN ISNULL(RS1.sdocument1, '') <> '' AND RS1.balwaysprint1 = 'NO'
AND NYSQLFUNCTION(RS1.SSQL1) = 'TRUE' THEN RS1.RS1.DOCUMENT1
WHEN ISNULL(RS1.sdocument1, '') <> '' AND RS1.balwaysprint1 = 'YES'
THEN RS1.RS1.DOCUMENT1
END "_FILE_1"
CREATE FUNCTION NYSQLFUNCTION(@SQLTEXT NVARCHAR(MAX))
RETURNS VARCHAR(500)AS BEGIN
DECLARE @FILEPRINT AS VARCHAR(5)
IF EXISTS(SELECT @SQLTEXT)
SET @FILEPRINT = 'TRUE'
ELSE
SET @FILEPRINT = 'FALSE'
RETURN @FILEPRINT END;