-
Help converting SQL/PSM to TSQL if Possible
My boss has bought me this SQL Hierarchies book. I really want to get into it but as we are using TSQL SQL2k I need to convert his examples into code I can actually use and I'm having trouble. So if anyone could convert this to TSQL or help me out in the process then I'd be much obliged. I'm ok with some of the function conversions:
create function Reverse(in instring varchar(20))
returns varchar(20)
language sql
deterministic
begin
if char_length(instring) in (0,1)
then return (instring);
else return
(Reverse(SUBSTRING (instring FROM (CHAR_LENGTH(instring)/2 + 1))
|| Reverse(SUBSTRING (instring FROM 1 FOR CHAR_LENGTH(instring)/2))));
end if;
end;
ive got this so far
CREATE FUNCTION [udf_Reverse]
(@instring varchar(20))
RETURNS varchar(20)
AS
BEGIN
if len(@instring) in (0,1) return @instring
else
return (udf_Reverse(substring(@instring, (len(@instring)/2 + 1),len(@instring)) OR udf_Reverse(substring(@instring, 1, len(@instring)/2))))
END
which is erroring with incorrect syntax near OR which I can understand as I can't see how you can return an OR statement.
But the the SQL/PSM is correct as its been validated so I just need some help understanding what its supposed to do so I can convert it into TSQL (if its possible!?!)
Thanks in advance for help.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|