Quantcast
Channel: SCN : Discussion List - SAP HANA and In-Memory Computing
Viewing all articles
Browse latest Browse all 5653

Comparing NVARCHAR with INT in hana

$
0
0

Hi,

 

A strange observation. Can anyone pls explain. I am trying to create a procedure in hana something like this:

create procedure abc(

IN UserID int,

in EventID int)

LANGUAGE SQLSCRIPT  

AS       

BEGIN

DECLARE cnt INT := 0;

 

SELECT COUNT(*) INTO cnt FROM SCHEMA."ABCD" 

  WHERE "EventID" = :EventID AND "UserID" = :UserID AND "RoleID"=(SELECT "RoleID" FROM SCHEMA."aa" WHERE "ggg"= 'XYZ'); 

 

  select :cnt,:EventID, :UserID from dummy;

END;

 

In Table ABCD the EventID column is NVARCHAR(100) and UserID is INT type. When i execute this procedure using

call abc(1,2)

it does not give me correct result. It returns cnt as 0 whereas actually output should be 1. I tried playing with the query somewhat and found that if i replace the part "EventID" = :EventID with "EventID" = 2 then it gives correct output. I finally tried replacing this clause with "EventID" = TO_INT(:EventID) and it gives correct output. The question is why is it behaving in such a manner ?  Why do i need to use TO_INT function for my EventID input ?

 

TIA.


Viewing all articles
Browse latest Browse all 5653

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>