CREATE FUNCTION StatuteconcatA char(4), :B char(5), :C char(25))
RETURNS char(34)
AS
BEGIN
DECLARE :chapter char(4)
DECLARE :act char(4)
DECLARE :workspace char(4)
DECLARE :workspac2 char(4)
DECLARE :workspac3 char(5)
DECLARE :actdec char(1)
DECLARE :smallest char(34)
DECLARE :vInteger Int
DECLARE :vIntege2 Int
DECLARE :flag Int
DECLARE :fla2 Int
SET :workspace = LEFTB, 4)
SET :flag = 0;
SET :fla2 = 0;
SET :vInteger = 1;
SET :vIntege2 = 1;
SET :workspac2 = '';
SET :workspac3 = '';
TestLoop:
LOOP
IF vInteger > 4) THEN
LEAVE TestLoop;
END IF;
SET :workspace = SUBSTRINGA, :vInteger, 1);
IF workspace = 0 and :flag = 0) THEN
SET :workspac2 = :workspac2 + '';
ELSE
SET :flag = 1;
SET :workspac2 = :workspac2 + :workspace;
END IF;
SET :vInteger = :vInteger + 1;
IF vInteger = 5 and :workspac2 > '') THEN
SET :workspac2 = :workspac2 + '-';
END IF;
END LOOP;
SET :vInteger = 1;
TestLoop:
LOOP
IF vInteger > 4) THEN
LEAVE TestLoop;
END IF;
SET :workspace = SUBSTRINGB, :vInteger, 1);
IF workspace = 0 and :fla2 = 0) THEN
SET :workspac3 = :workspac3 + '';
ELSE
SET :fla2 = 1;
SET :workspac3 = :workspac3 + :workspace;
END IF;
IF vInteger = 4 and :workspac3 > '') THEN
SET :workspac3 = :workspac3 + '/';
END IF;
SET :vInteger = :vInteger + 1;
END LOOP;
SET :smallest = :workspac2 + :workspac3 + :C;
RETURN :smallest;
END;
This user defined function works fine using version 9 but will not work with Version 11. I have narrowed it down to the line that says SET :workspac2 = :workspac2 + :workspace;
RETURNS char(34)
AS
BEGIN
DECLARE :chapter char(4)
DECLARE :act char(4)
DECLARE :workspace char(4)
DECLARE :workspac2 char(4)
DECLARE :workspac3 char(5)
DECLARE :actdec char(1)
DECLARE :smallest char(34)
DECLARE :vInteger Int
DECLARE :vIntege2 Int
DECLARE :flag Int
DECLARE :fla2 Int
SET :workspace = LEFTB, 4)
SET :flag = 0;
SET :fla2 = 0;
SET :vInteger = 1;
SET :vIntege2 = 1;
SET :workspac2 = '';
SET :workspac3 = '';
TestLoop:
LOOP
IF vInteger > 4) THEN
LEAVE TestLoop;
END IF;
SET :workspace = SUBSTRINGA, :vInteger, 1);
IF workspace = 0 and :flag = 0) THEN
SET :workspac2 = :workspac2 + '';
ELSE
SET :flag = 1;
SET :workspac2 = :workspac2 + :workspace;
END IF;
SET :vInteger = :vInteger + 1;
IF vInteger = 5 and :workspac2 > '') THEN
SET :workspac2 = :workspac2 + '-';
END IF;
END LOOP;
SET :vInteger = 1;
TestLoop:
LOOP
IF vInteger > 4) THEN
LEAVE TestLoop;
END IF;
SET :workspace = SUBSTRINGB, :vInteger, 1);
IF workspace = 0 and :fla2 = 0) THEN
SET :workspac3 = :workspac3 + '';
ELSE
SET :fla2 = 1;
SET :workspac3 = :workspac3 + :workspace;
END IF;
IF vInteger = 4 and :workspac3 > '') THEN
SET :workspac3 = :workspac3 + '/';
END IF;
SET :vInteger = :vInteger + 1;
END LOOP;
SET :smallest = :workspac2 + :workspac3 + :C;
RETURN :smallest;
END;
This user defined function works fine using version 9 but will not work with Version 11. I have narrowed it down to the line that says SET :workspac2 = :workspac2 + :workspace;