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

SQLScript procedure execution

$
0
0

Hi,

 

I'm on HANA version 1.00.53.375657.

 

I need to populate 2 tables(ins1, ins2) based on the results of some calculations on 2 other tables(tab1, tab2). I have created a procedure for this and roughly it looks like this:

 

 

create procedure proc1(IN var1 INTEGER)

LANGUAGE SQLSCRIPT as

BEGIN

 

     tabvar1 = select col1, col2 from tab1 where id = :var1;

 

     tabvar2 = select c1, c2, c3, c4 rom tab2 where <conditions>

 

     tabvar3 = (select P2.c1, P2.c2, P3.c3

                    from

                    (

                        select c1, c2, c3, sum(c4) from tab1 as P1, :tabvar2 as P2

                         where <conditions>

                         group by P2.c1, P2.c2, P2.c3)

                    where <conditions>);

 

     insert into ins1 (select :var1 as id, c1 as name from :tabvar3);

     insert into ins2 (select c1 || '_' || c2 as customers from :tabvar3);

 

END;

 

When this procedure is invoked with an input value for the first time, ins1 and ins2 have no rows in them.

When invoked with the same input value subsequently, ins1 and ins2 have the expected number of rows.

 

For instance,

 

 

call proc1(5)  ----> No rows in ins1 and ins2 corresponding to input 5

call proc1(5)  -> expected number of rows in ins1 and ins2.

 

call proc1(5000)   -> no rows in ins1 and ins2 corresponding to input 5000

call proc1(5000)  -> expected no of rows in ins1 and ins2

 

I had inserted the following statement into the procedure

tabvar3 = TRACE(:tabvar3)

and checked that tabvar3 indeed has no rows after the first execution (with a new input value).

 

Is this expected behavior?

 

Many thanks in advance for your suggestions/pointers.

 

 

 

 

 


Viewing all articles
Browse latest Browse all 5653

Trending Articles



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