Page 1 of 1

VSQL function failing on CASE

Posted: Tue Oct 17, 2017 6:32 pm
by dmando84
Hello,

I am somewhat new to VSQL so bear with me. I am not sure why this function is failing. The issue is in the CASE statement, but I am not sure why. I set the variables and began my CASE. What am I missing?

As always, thank you all in advance for your time.

create function fn_MyFunction (AllHeaders varchar(4000)) return varchar(50)
as begin
\set subStr '"X-Forwarded-For:"'
\set strAllHeaders AllHeaders
\set p1 0
\set p2 0

case
when position(:subStr in :strAllHeaders ) > 0 then
\set p1 = position(:subStr IN cast(:strAllHeaders as varchar(4000)))+19
end

return :strAllHeaders;

end;

Syntax error at or near "case" at character 145