on 05-27-2015 8:26 AM
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.
Hi Nikhil,
I wasn't able to reproduce this.
create column table abc (aaa nvarchar (40), bbb nvarchar(40));
create procedure abc_p(
IN aaa int,
in bbb int)
LANGUAGE SQLSCRIPT
AS
BEGIN
DECLARE cnt INT := 0;
SELECT COUNT(*) INTO cnt
FROM abc
WHERE
aaa = :aaa
AND bbb = :bbb;
SELECT :cnt, :aaa, :bbb
FROM dummy;
END;
insert into abc values (1, 2);
call abc_p (1, 2);
:CNT | :AAA | :BBB |
1 | 1 | 2 |
This was on Rev. 94, so maybe you're looking at a bug in an older rev.
- Lars
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
89 | |
10 | |
9 | |
9 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.