Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 27th, 2004, 01:36 PM
noiture777 noiture777 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 2 noiture777 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question code to generate random No & Fill them in a table

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

Reply With Quote
  #2  
Old May 30th, 2004, 04:39 AM
galith_haham galith_haham is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 64 galith_haham User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 25 m 17 sec
Reputation Power: 5
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.

Reply With Quote
  #3  
Old May 31st, 2004, 01:47 AM
Tomasz Morus Tomasz Morus is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 20 Tomasz Morus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 m 28 sec
Reputation Power: 0
Send a message via ICQ to Tomasz Morus
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

Reply With Quote
  #4  
Old June 1st, 2004, 04:06 PM
noiture777 noiture777 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 2 noiture777 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thumbs up Thank you a lot

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)

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > code to generate random No & Fill them in a table


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT