|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
HI all dears
![]() could anyone help me searching this code : what i want is to write a code to randomly extract an item_id from item table and use it to fill INVOICE table and assign random value for the item chosen as it is the quantity of the itme in the invocie thank you all |
|
#2
|
|||
|
|||
|
Hi,
first for the access issue - you can use the sample clause (it will enable you to select a sample randomly). the second part is the insert forwhich you can use the random funciton (if i am not mistaken dbms_random). good luck. |
|
#3
|
|||
|
|||
|
sample code:
declare i integer; k NUMBER := 11; begin dbms_random.initialize(10293); -- petla FOR i IN 0 .. 10 LOOP -- -- generete random number from 0 to k - 1 -- k can be sequence number minus 1 -- dbms_output.put_line(trunc(dbms_random.value(0,k))); dbms_random.terminate(); END LOOP; end; ---- You retrive any number from 0 to k It's simple. I use it to test DB. cheers |
|
#4
|
|||
|
|||
|
dear Tomasz Morus , galith_haham
Thank you alot for your valuable answer ...you really helped me deeply Thank you again by the way another one forwarded to me tht link URL which explain in details dbms.random urs , Mohannad (sorry for the late replay) |
![]() |
| Viewing: Dev Shed Forums > Databases > Oracle Development > code to generate random No & Fill them in a table |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|