If I run the following statement: //create a watcom function CREATE OR REPLACE FUNCTION "DBA"."TEST1" (@val INT) RETURNS INTEGER BEGIN IF (@val = 1) THEN SET @val = 2; ENDIF; RETURN @Val; END; //create a t-sql function CREATE OR REPLACE FUNCTION "DBA"."TEST2" (@val INT) RETURNS INTEGER AS BEGIN IF @val = 1 BEGIN SET @val = 2; END RETURN @Val; END; It runs fine, no errors. But if I run this: //create a t-sql function CREATE OR REPLACE FUNCTION "DBA"."TEST1" (@val INT) RETURNS INTEGER AS BEGIN IF (@val = 1) BEGIN SET @val = 2; END RETURN @Val; END; //create a t-sql function CREATE OR REPLACE FUNCTION "DBA"."TEST2" (@val INT) RETURNS INTEGER AS BEGIN IF @val = 1 BEGIN SET @val = 2; END RETURN @Val; END; It throws: Could not execute statement. Syntax error near 'FUNCTION' on line 14 (Transact-SQL) SQLCODE=-131, ODBC 3 State="42000" Line 15 Line 14 is where the second function declaration starts, so it's like it's reading off the end of the first function because of the BEGIN/END statement in the IF clause. Am I writing bad code and/or is there something I'm missing? I write most of my procedure/functions in t-sql and use IF/ELSE quite a bit. If run the CREATE FUNCTION statements individually they don't throw errors. Any help would be appreciated. SQL Anywhere 17 17.0.10.5963 |