mardi 28 mars 2017

How do I create string of random length using different calls to random in PL/SQL Oracle Developer?

I am writing a chunk of PL/Code to test a database for a homework assignment. The criteria for what I am working on: b. Email must be less than 20 characters long, and must be a valid format, e.g. having a ‘@’ sign and a ‘.’ sign at the right position.

So I will have a string/varchar that is less than 20. I know that with the Top Level Domain as 3 spaces, the dot, and the at symbol taking up 5 spaces of that length, which leaves 14 spaces. So I thought I could randomly generate a string in the range of 1-14 to fill in the remaining spaces, and make the whole thing less than 20. How would I do this?

Email := dmbs_random.string('U', trunc(dbms_random.value(1,14))||'@'||dmbs_random.string('U', trunc(dbms_random.value(1,14))||'.'||dbms_random.string('U',3)<20;

I know the above is incorrect, but it is just psuedo code of what I am attempting.




Aucun commentaire:

Enregistrer un commentaire