Skip to Content
0

HANA FMS with variables

Nov 18, 2016 at 03:07 PM

77

avatar image

Dear experts,

We are facing an issue when translating a FMS with variables. The query is the below :

DECLARE @A NVARCHAR(10) SET @A = (SELECT $[$40.1.0]) IF @A = 'S' BEGIN SELECT N'S' +'.' +RIGHT( '00000' +CAST( INULL( CAST( RIGHT( MAX(CARDCODE) ,5) AS INT) ,0) +1 AS VARCHAR) ,5) FROM OCRD WHERE LEFT(OCRD.CARDCODE,1) = 'S' FOR BROWSE END ELSE IF @A = 'C' OR @A = 'L' BEGIN SELECT N'C' +'.' +RIGHT( '00000' +CAST( ISNULL( CAST( RIGHT( MAX(CARDCODE) ,5) AS INT) ,0) +1 AS VARCHAR) ,5) FROM OCRD WHERE LEFT(OCRD.CARDCODE,1) = 'C' FOR BROWSE END

and we have created the below HANA query

IF (SELECT $[$40.1.0] FROM "DUMMY") = 'S' ΤΗΕΝ SELECT N'S' +'.' +RIGHT( '00000' +CAST( IFNULL( CAST( RIGHT( MAX("CardCode") ,5) AS INT) ,0) +1 AS VARCHAR) ,5) FROM OCRD WHERE LEFT(OCRD."CardCode",1) = 'S' FOR BROWSE END ELSE IF (SELECT $[$40.1.0] FROM "DUMMY") = 'C' OR (SELECT $[$40.1.0] FROM "DUMMY") = 'L' ΤΗΕΝ SELECT N'C' +'.' +RIGHT( '00000' +CAST( IFNULL( CAST( RIGHT( MAX("CardCode") ,5) AS INT) ,0) +1 AS VARCHAR) ,5) FROM OCRD WHERE LEFT(OCRD."CardCode",1) = 'C' FOR BROWSE END

Unfortunatly, it doesn't work and the error message is incorrect syntax near "IF": line 1 col 1 (at pos 1).

Kind Regards,

Alexandros Karadimitropoulos

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

0 Answers