pears.getword
Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace.
Original SQL
CREATE FUNCTION "pears"."getword"( /* Application Maintained Function / Procedure - DO NOT EDIT*/ IN "s1" long VARCHAR,IN "ln1" SMALLINT ) RETURNS CHAR(200) BEGIN DECLARE "i" SMALLINT; DECLARE "ln" SMALLINT; DECLARE "s" CHAR(200); SET "ln" = "ln1"; SET "s" = "s1"; "loop1": loop SET "ln" = "ln"-1; IF "ln" <= 0 THEN leave "loop1" END IF; SET "i" = "charindex"("char"(32),"s"); IF "i" > 0 THEN SET "s" = "stuff"("s",1,"i",'') ELSE SET "s" = '' END IF END loop "loop1"; SET "i" = "charindex"("char"(32),"s"); IF "i" > 0 THEN SET "s" = "left"("s","i"-1) END IF; RETURN("s") END