on 07-23-2013 2:57 PM
Hi there,
Basically, I'm trying to generate a random number for use in a CE_CALC function in my calculation view script.
This is my code:
mc_proj = CE_PROJECTION(:mc_prac, ["LEADS_MIN", "LEADS_MAX",
CE_CALC('"LEADS_MIN" + :rnd * ("LEADS_MAX" - "LEADS_MIN")', double)
as "R_LEADS", "COST_MIN", "COST_MAX", "RATE_MIN", "RATE_MAX",
"PROFIT_MIN", "PROFIT_MAX", "OVERHEAD"]);
rnd is supposed to be the variable that will hold my random number.
What's the best way to go about this?
Thanks
Hi Aakash,
I think that you can use RAND() function to generate random number, the RAND() will generate 0 to 1.0 number, but you only can use SQL statement to output, for example
create procedure RANDOM_NUMBER(out rand_num double) language sqlscript as
BEGIN
select rand() into rand_num from dummy;
END
So you can update your procedure SQL without CE engine.
Hope this can help you.
Regards
Jerry
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jerry, thanks for the reply.
I see what you mean. But I then need to use that generated number in my calculation view script. How do I call the procedure in my CV script and place the result into a variable that I can then use in my projection code above?
Sorry I've only just started using HANA so I may be asking stupid questions.
Hi Aakash,
I am not sure why you need to do this, however you can do it base on below script definition.
var_out = select
"CUSTOMERID",
"CUSTOMERNAME",
"REGIONNAME",
"CITYNAME",rand()*10000 as "SALESPRICE",
rand()*1000 as "RANDOMNUMONE",
rand()*1000 as "RANDOMNUMTWO"
from "your schema"."table name";
Regarding as table structure and CV, please refer to below figure.
You can define yourself formula for random number.
Hope this can help you.
Regards,
Jerry
User | Count |
---|---|
84 | |
25 | |
12 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.