Question
Ernst&Young
SV
Last activity: 21 Dec 2017 11:16 EST
How translate a SQL function into a SQL alias in Pega to be used in a report definition?
Hello.
I have created a SQL function which gives me the reverse of a string and what I want to do is translate that function into a SQL function alias and used it in a report definition.
The SQL function is this one:
CREATE FUNCTION reverse (@instr varchar(40))
RETURNS VARCHAR(40)
AS
begin
declare @revstr varchar(40), @reststr varchar(40), @len int
SET @reststr = @instr
SET @len = len(@instr)
WHILE @len > 0
BEGIN
SET @revstr = CONCAT(SUBSTRING(@reststr, 1, 1) , @revstr)
SET @reststr = SUBSTRING(@reststr, 2, @len - 1)
SET @len = @len - 1
END
RETURN @revstr
END
Then, I save the rule with the previous sql function and don't get any error but when I execute the report definition I get the next SQLSTATE = 42601.
I attached an image with my SQL function.
Thanks