Search code examples
hanahana-sql-script

JDBC: [337]: INTO clause not allowed for this SELECT statement


In HANA, I want to obtain the latest ID value and assign it to a variable.

DECLARE MAXID BIGINT;

SELECT MAX(ID) INTO MAXID FROM "SAPABAP1"."APPLOG";

But this returns an error saying;

SAP DBTech JDBC: [337]: INTO clause not allowed for this SELECT statement

Note that the data type of ID is also BIGINT.

Any idea why I'm getting this error and any solution to get the max ID and assign it to a variable?


Solution

  • Added DO BEGIN END and it worked.

    DO BEGIN
    
        DECLARE MAXID BIGINT;    
        SELECT MAX(ID) INTO MAXID FROM "SAPABAP1"."APPLOG";
    
    END;