aws
aws

Reputation: 83

dbms_random.value works fine with code below except need to change date by assigned field

Dear I have this code which is work fine it generate random time which is generated till the last record found I have 2 fields where is :C field have date with different I can generate random time but in the same date how to assign :C field dates in that it take date from :C field and put into with this generated time

    
    START_DATE DATE := TO_DATE('01.01.2021 07:45', 'dd.mm.yyyy hh24:mi');
Begin

    FIRST_RECORD;
    LOOP
:a :=   START_DATE + round(dbms_random.value (1, 15))/ (24 * 60);
IF :system.last_record = 'FALSE'   
    THEN
       NEXT_RECORD;
    ELSE
       EXIT;
       END IF;
END LOOP;
End;
--it gives me data like this 
01.01.2021 07:59
01.01.2021 07:59
01.01.2021 07:57
01.01.2021 07:53
01.01.2021 07:47
01.01.2021 07:59
01.01.2021 07:54
01.01.2021 07:47
01.01.2021 07:57
01.01.2021 07:46
01.01.2021 07:47

I have :c field of date on forms which is tabular I want that it just pic date from :c and take time from this code like this

01.01.2021 07:59
02.01.2021 07:57
03.01.2021 07:53
04.01.2021 07:47
05.01.2021 07:59

Upvotes: 0

Views: 156

Answers (1)

Littlefoot
Littlefoot

Reputation: 142798

Well, why don't you put that value into the C field in the same procedure, at once?

...

:a := START_DATE + round(dbms_random.value (1, 15))/ (24 * 60);

:c := trunc(:c)  + round(dbms_random.value (1, 15))/ (24 * 60);     --> this

...

Upvotes: 1

Related Questions