Quantcast
Channel: SCN : Discussion List - SAP HANA Developer Center
Viewing all articles
Browse latest Browse all 6412

Using 'Pass by reference' as input parameters to calculation view in a SELECT statement

$
0
0

Hi,

 

I am migrating MS SQL functions to HANA calculation views .

 

Our application generates a SELECT query  depending on the fields/columns and filters the user selects, the query is formed in run-time as follows :

 

For e.g. User chooses fields 'person_name', 'city', 'country' for output and 'country' is filter

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


SELECT

 

(select person_name from get_name_from_country (x1.country) ) as person_name,     -- this is col1 destination and can be modified

(select city from get_city(x2.country) ) as city ,                                                                  -- this is col2 defination and can be modified

x1. country as country                                                                                                       --- this is col3

FROM

 

person_table x1                                                                                                                -- FROM clause is generated by the application

INNER JOIN active_person_view x3

ON x1.person_name = x3.active_person_name

INNER JOIN  city_table x2

ON x2.person_name = x3.active_person_name

 

WHERE

 

(x1.country = 'US' and x3.active = '1')                                                                              --  the filter values are piked from user selection

 

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


I am converting get_name_from_country and get_city functions into calculation view and  the new SELECT looks like below:  But it gives an error for the below code at x1.country and x2.country in the sub-selects

 

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

 

SELECT

 

(select person_name from "_SYS_BIC"."FG_TEST/GET_NAME_FROM_COUNTRY" ( 'PLACEHOLDER' = ('$$country$$',x1.country)) as person_name,    

(select city from "_SYS_BIC"."FG_TEST/GET_CITY"( 'PLACEHOLDER' = ('$$country$$',x2.country) ) as city                                                                

 

FROM

 

person_table x1                                                                                                               

INNER JOIN active_person_view x3

ON x1.person_name = x3.active_person_name

INNER JOIN  city_table x2

ON x2.person_name = x3.active_person_name

 

WHERE

 

(x1.country = 'US' and x3.active = '1')                                                                           


--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


 

Please let me know for any alternate way i can pass the values by reference to the calculation view.


Viewing all articles
Browse latest Browse all 6412

Trending Articles



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