Creating a new package is something we avoid in a customer environment due to licensing, version handling and permission setup issues. I was wondering if this can be solve using already existing things
A) You can use a custom logical unit (rnd.zip in rnd.docx).
1. Create a logical unit: MyRnd 2. Create a persistent field (numeric): p 3. Create a read only field (numeric): Rng a) argument: t.cf$_p b) select statment: select dbms_random.value +:cf$_p -:cf$_p from dual 4) Then Approve & Publish LU
In report select ifsapp.my_rnd_clp.Get_Cf$_Rnd(0) from dual
Is there an alternate to get a random value in a quick report?
Cheers!
Page 1 / 1
Put it in a package?
Header:
1 FUNCTION getRandom(val_ IN NUMBER, val2_ IN NUMBER) RETURN NUMBER;
Body:
1FUNCTION getRandom(val_ IN NUMBER, val2_ IN NUMBER) RETURN NUMBER IS random_ NUMBER; BEGIN random_ := DBMS_RANDOM.value(val_, val2_); RETURN random_;END getRandom;
Creating a new package is something we avoid in a customer environment due to licensing, version handling and permission setup issues. I was wondering if this can be solve using already existing things
/DSJ
I can’t see any other way around it, other than by having a customisation to get RnD to take out the code which is blocking it.
DSJ,
Is the following ‘allowed’ in your situation:
select regexp_substr(sys_guid(), '\d') from dual;
It is pseudo random, but it is quite simple to implement, I think.
Regards, Steve
This is an alternative, but it’s limited to the set ranges
1SELECT substr(to_char(systimestamp, 'FF6'), 6, 6) FROM dual; -- Random from 0 to 9SELECT substr(to_char(systimestamp, 'FF6'), 5, 6) FROM dual; -- Random from 0 to 99SELECT substr(to_char(systimestamp, 'FF6'), 4, 6) FROM dual; -- Random from 0 to 999SELECT substr(to_char(systimestamp, 'FF6'), 3, 6) FROM dual; -- Random from 0 to 9999SELECT substr(to_char(systimestamp, 'FF6'), 2, 6) FROM dual; -- Random from 0 to 99999SELECT to_char(systimestamp, 'FF6') FROM dual; -- Random from 0 to 999999
Thanks both for the answers.
I put both answers to test and here’s the result
Quick report SQL
1SELECT to_char(systimestamp, 'FF6'),regexp_substr(sys_guid(), '\d') FROM dual unionallSELECT to_char(systimestamp, 'FF6'),regexp_substr(sys_guid(), '\d') FROM dual unionallSELECT to_char(systimestamp, 'FF6'),regexp_substr(sys_guid(), '\d') FROM dual unionallSELECT to_char(systimestamp, 'FF6'),regexp_substr(sys_guid(), '\d') FROM dual unionallSELECT to_char(systimestamp, 'FF6'),regexp_substr(sys_guid(), '\d') FROM dual
result
I read somewhere that systimestamp precision varies with DB settings and it could be the reason I’m getting same value with the systimestamp?
Makes sense. When I run regexp_substr(sys_guid(), '\d') I only get 9 returned every time
A) You can use a custom logical unit (rnd.zip in rnd.docx).
1. Create a logical unit: MyRnd 2. Create a persistent field (numeric): p 3. Create a read only field (numeric): Rng a) argument: t.cf$_p b) select statment: select dbms_random.value +:cf$_p -:cf$_p from dual 4) Then Approve & Publish LU
In report select ifsapp.my_rnd_clp.Get_Cf$_Rnd(0) from dual
B) You can use a IAL (my_rnd.ial.txt)
SELECT x.rnd FROM ifsinfo.my_rnd x
This will return a pseudo-random number between 0 and 1.
SELECT TO_NUMBER(sys_guid(), 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') / POWER(2, 128) FROM DUAL
We use 3 different kinds of cookies. You can choose which cookies you want to accept. We need basic cookies to make this site work, therefore these are the minimum you can select. Learn more about our cookies.