Skip to Content
0
Sep 25, 2016 at 09:53 AM

Declaring variables in HANA

24852 Views

Dear Experts,

I want to convert my below SQL query to HANA.

Declare @code varchar(20)

set @code = 'C20000'

Select * From OINV T0 Where T0.CardCode = @code

Can anyone please help me for the right statement. I want to use variable in HANA Query and don't want to create procedure.

1-

code varchar(20);

code := 'C20000';

SELECT * FROM "OINV" WHERE "CardCode" = :code;

2-

Declare code varchar(20);

code := 'C20000';

SELECT * FROM "OINV" WHERE "CardCode" = :code;

Error

* Could not execute 'code varchar(20)'

SAP DBTech JDBC: [257]: sql syntax error: incorrect syntax near "code": line 1 col 1 (at pos 1)

* Could not execute 'code := 'C20000''

SAP DBTech JDBC: [257]: sql syntax error: incorrect syntax near "code": line 1 col 1 (at pos 1)

* Could not execute 'SELECT * FROM "OINV" WHERE "CardCode" = :code'

SAP DBTech JDBC: [467]: cannot use parameter variable: CODE: line 1 col 42 (at pos 41)