ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » General Discussion » 12 Digit Random and Unique Number Generation

Post new topic  Reply to topic Goto page 1, 2  Next
 12 Digit Random and Unique Number Generation « View previous topic :: View next topic » 
Author Message
edasnarik
PostPosted: Mon Dec 07, 2009 3:43 am    Post subject: 12 Digit Random and Unique Number Generation Reply with quote

Acolyte

Joined: 10 Mar 2009
Posts: 61

Hi Everyone,

I need to generate 12 Digit Random numbers starting from 1 to all 9's and store all of them in Database.

Please let me know on how to proceed.
Back to top
View user's profile Send private message
exerk
PostPosted: Mon Dec 07, 2009 3:59 am    Post subject: Reply with quote

Jedi Council

Joined: 02 Nov 2006
Posts: 6339

I suppose you could proceed to a bookshop and purchase a treatise on random number generation, and one on databases and how to use them, synergise the content, and apply.

Please let us know how this question has anything to do with WebSphere MQ
_________________
It's puzzling, I don't think I've ever seen anything quite like this before...and it's hard to soar like an eagle when you're surrounded by turkeys.
Back to top
View user's profile Send private message
manicminer
PostPosted: Mon Dec 07, 2009 4:59 am    Post subject: Reply with quote

Disciple

Joined: 11 Jul 2007
Posts: 177

If you want to store all possible random numbers from 1 to 999999999999
you could simply write a for loop inserting them . Of course it will look like they are in sequence but sometimes that happens - it's random after all

Edit - also see:

http://www.random.org/

Which Mr Google helpfully suggested.
_________________
Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime.
Back to top
View user's profile Send private message
zpat
PostPosted: Mon Dec 07, 2009 5:08 am    Post subject: Reply with quote

Jedi Council

Joined: 19 May 2001
Posts: 5866
Location: UK

Assuming we are talking message broker - why not use the RAND function in ESQL?
Back to top
View user's profile Send private message
edasnarik
PostPosted: Mon Dec 07, 2009 7:26 am    Post subject: Reply with quote

Acolyte

Joined: 10 Mar 2009
Posts: 61

exerk wrote:

Please let us know how this question has anything to do with WebSphere MQ


This is not related to MQ so I have posted this question in General Discussion Section

manicminer wrote:
If you want to store all possible random numbers from 1 to 999999999999
you could simply write a for loop inserting them .


But how to shuffle numbers .. which is the criterion here as I don't want it sequential.

zpat wrote:
Assuming we are talking message broker - why not use the RAND function in ESQL?


Does it hold good for uniqueness as well ? We are talking about 999999999999 numbers in all.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Mon Dec 07, 2009 8:03 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

This is at least the second time you have asked this same question.

I'm not terribly motivated to go search for the previous answers, that are assuredly all the same.

You are expecting too much help from this forum in general. What you are asking for is someone to provide you with a direct and complete solution to what is a fairly basic application of product knowledge.

Also, more specifically, you are not asking for random numbers between 1 and 999999999999.

You are asking for a single random PERMUTATION of the set of numbers 1...999999999999

It's entirely unclear what value you will achieve by storing that permutation into a database.

It's entirely unclear what value you will achieve by storing that set of numbers in an unordered permutation, rather than storing them in a natural sequence and selecting a random value from the set of unchosen numbers.

It's entirely unclear what value you are achieving by generating any permutation of this set before hand, rather than on an as-needed basis.
Back to top
View user's profile Send private message
zpat
PostPosted: Mon Dec 07, 2009 8:04 am    Post subject: Reply with quote

Jedi Council

Joined: 19 May 2001
Posts: 5866
Location: UK

UUIDASCHAR is another ESQL function.

The question is really what is the requirement behind this - not how can a particular solution be coded?
Back to top
View user's profile Send private message
gbaddeley
PostPosted: Mon Dec 07, 2009 2:51 pm    Post subject: Re: 12 Digit Random and Unique Number Generation Reply with quote

Jedi Knight

Joined: 25 Mar 2003
Posts: 2538
Location: Melbourne, Australia

edasnarik wrote:
Hi Everyone,
I need to generate 12 Digit Random numbers starting from 1 to all 9's and store all of them in Database.
Please let me know on how to proceed.


Research random numbers. eg. http://random.mat.sbg.ac.at/
Find a generator algorithm that cycles through all the required numbers without repeats.

Look at postings on newsgroup sci.crypt.random-numbers.

Random numbers is a very interesting field of mathematics and computing.
_________________
Glenn
Back to top
View user's profile Send private message
bruce2359
PostPosted: Mon Dec 07, 2009 3:42 pm    Post subject: Reply with quote

Poobah

Joined: 05 Jan 2008
Posts: 9469
Location: US: west coast, almost. Otherwise, enroute.

Pseudo-random numbers are interesting, too.
_________________
I like deadlines. I like to wave as they pass by.
ב''ה
Lex Orandi, Lex Credendi, Lex Vivendi. As we Worship, So we Believe, So we Live.
Back to top
View user's profile Send private message
edasnarik
PostPosted: Tue Dec 08, 2009 9:55 pm    Post subject: Reply with quote

Acolyte

Joined: 10 Mar 2009
Posts: 61

mqjeff wrote:
This is at least the second time you have asked this same question.

The previous one was for 7 digits and this one is for 12 digits.

mqjeff wrote:

It's entirely unclear what value you will achieve by storing that permutation into a database.

It's entirely unclear what value you will achieve by storing that set of numbers in an unordered permutation, rather than storing them in a natural sequence and selecting a random value from the set of unchosen numbers.

It's entirely unclear what value you are achieving by generating any permutation of this set before hand, rather than on an as-needed basis.


Storing the Random numbers and rendering them sequentially is far simpler than storing sequentially in the database and selecting a random value from the set of unchosen numbers and checking for the uniqueness.

As smdavies99 was saying in the link http://www.mqseries.net/phpBB2/viewtopic.php?t=51533&sid=8bc8e8f2f05988d6361d083f05e59234

Remember that for every number you generate in your random sequence you have to then check to see it if has already been used. As you can guess this will take an ever increading time as the numbers get used up.
Back to top
View user's profile Send private message
manicminer
PostPosted: Wed Dec 09, 2009 2:08 am    Post subject: Reply with quote

Disciple

Joined: 11 Jul 2007
Posts: 177

edasnarik wrote:

Storing the Random numbers and rendering them sequentially is far simpler than storing sequentially in the database and selecting a random value from the set of unchosen numbers and checking for the uniqueness.

As smdavies99 was saying in the link http://www.mqseries.net/phpBB2/viewtopic.php?t=51533&sid=8bc8e8f2f05988d6361d083f05e59234

Remember that for every number you generate in your random sequence you have to then check to see it if has already been used. As you can guess this will take an ever increading time as the numbers get used up.


My problem with finding a solution to this is that you haven't specified your real requirement.

Generate random numbers isn't a requirement you are ever going to get a good solution to, other than - use a random number generator.

Why don't you try posting the problem you are actually trying to solve, then you might find people more willing to come up with creating solutions that match your requirements.

If you don't feel you can disclose the actual problem due to business sensitivity (I'd be mildly surprised if that is the case) then re-phrase the problem in a way you are happy to state but still captures the fundamental requirement at a high level, rather than focusing on low level things like random number generation and databases.
_________________
Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime.
Back to top
View user's profile Send private message
edasnarik
PostPosted: Wed Dec 09, 2009 7:06 am    Post subject: Reply with quote

Acolyte

Joined: 10 Mar 2009
Posts: 61

manicminer wrote:
re-phrase the problem in a way you are happy to state but still captures the fundamental requirement at a high level


Which is precisely what I have done and that is all I have got in requirements.
Back to top
View user's profile Send private message
bruce2359
PostPosted: Wed Dec 09, 2009 7:19 am    Post subject: Reply with quote

Poobah

Joined: 05 Jan 2008
Posts: 9469
Location: US: west coast, almost. Otherwise, enroute.

...sounds like a computer science class lab assignment.

As a side-issue: a random number generator may be a technical requirement, but not a business requirement.

What we're pondering is what will the random numbers be used for, and how this relates to MQ or DB2 or whatever. While mqseries.net is an excellent technical post site, nearly all of us work for business to satisfy business needs.

If all you need is a random number generator, there are lots of options - easily found by searching Mr. Google. Some programming languages offer this as a built-in function.
_________________
I like deadlines. I like to wave as they pass by.
ב''ה
Lex Orandi, Lex Credendi, Lex Vivendi. As we Worship, So we Believe, So we Live.
Back to top
View user's profile Send private message
edasnarik
PostPosted: Thu Dec 10, 2009 11:28 am    Post subject: Reply with quote

Acolyte

Joined: 10 Mar 2009
Posts: 61

bruce2359 wrote:

If all you need is a random number generator, there are lots of options - easily found by searching Mr. Google. Some programming languages offer this as a built-in function.


Not a but 999,999,999,999 unique random numbers.
So in a cycle .. all numbers from 0 to 12 9's would be used up.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Wed Dec 16, 2009 2:42 pm    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Just for fun,
Code:

      DECLARE I INTEGER;
      DECLARE J INTEGER;
      DECLARE size INTEGER 99; --999999999999;
      set I = 0;
      while I <= size DO
         CREATE LASTCHILD OF OutputLocalEnvironment.DATA NAME CAST(I as character) VALUE I;
         SET I = I+1;
      end while;
      DECLARE temp REFERENCE to OutputLocalEnvironment.DATA;
      While I > 0 DO
         SET J = FLOOR((RAND() * I) +1);
         MOVE temp to OutputLocalEnvironment.DATA.[J];
         DETACH temp;
         ATTACH temp to OutputLocalEnvironment.LIST AS LASTCHILD;
         SET I = I-1;
      END WHILE;


Best of luck with it.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Goto page 1, 2  Next Page 1 of 2

MQSeries.net Forum Index » General Discussion » 12 Digit Random and Unique Number Generation
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.