oracle plsql

in my application need to send a generic password through mail.
till now we are sending only one generic password but now there is a password restriction that a user cannot use
his/her last 6 previous password.

function to write with multiple generic passwords and it should send randomly the generic password.
Sarma VadlamaniprogrammeranalystAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

slightwv (䄆 Netminder) Commented:
I don't understand the question.

Are you wanting to generate a random password?  If so, that can be done with DBMS_RANDOM.STRING.

If you have a list and need to randomly pick one, still pretty easy with DBMS_RANDOM.VALUE.

For the previous 6 passwords, I don't see where generic is involved.  You would need to store them somewhere to make sure the new password wasn't reused.
hopefully you aren't storing the previous 6 passwords, but rather some kind of irreversible hash of them.

Your function could then simply loop generating new passwords,  hash them and then check the hash against the previous 6 saved hashes.  If it's new, then write the new hash, delete the 7th and then send out the new password.

If by chance you randomly generate a password that was already reused, then loop and try again
In most cases I would assume the loop would execute exactly once because the random password wouldn't repeat very often.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.