Tuesday 12 June 2012

Random Number Report

While browsing, found a good SQL query for having the random numbers generated.

Acutally this can be useful in the case where we can show a result depending on the value generated.

And YES, even the developer wont be sure of the value generated. Can be well used in GAME type of reports in OBIEE or to tell a fortune message to the user when he/ she logs into the application.

The code can we used in the RPD and can be used in the Answers.
I am using a session variable with the below code in the init block
select to_number(substr(to_char(dbms_random.value), 2, 1)) from dual

I will call this session variable into the column formula of a report and mention the conditions as

case VALUEOF(NQ_SESSION.Random_Ses)
when 2 then 'Bad fortune'
when  3 then 'You would have a Great Day'
when 4 then 'You will meet your luck today'
when 5 then 'You will have a bad day'
when 6 then 'Dont expect'
when 7 then 'Bad Day'
when 8 then 'You will work hard'
when 9 then 'You will go outside'
else 'Nothing Special'
end

Whenever the user logs into the application then the random number is generated and gets a values assigned. And in return he/ she will see the message of their fortune. :)


After the user log in.


Maybe this is also a good example for session variable.

No comments:

Post a Comment

Thanks to Comment
--Add--