Re: username/password generation with a trigger

From: Mike Ault <mikerault_at_earthlink.net>
Date: 17 Sep 2002 05:50:59 -0700
Message-ID: <37fab3ab.0209170450.16438ce2_at_posting.google.com>


You mean something like:

FUNCTION gen_pword
RETURN VARCHAR2 AS

   pi        		NUMBER := 3.141592653589793238462643 ;
   seed      	NUMBER ;
   pwd       	VARCHAR2(6);
   pwd_len   	NUMBER := 6;          /* length of password */
BEGIN
--dbms_output.enable(1000000);

   SELECT TO_NUMBER(TO_CHAR(hsecs)) / 8640000 INTO seed FROM v$timer ;  /* 0<= seed < 1 */
   pwd := NULL ;

       FOR  j  IN 1..pwd_len LOOP
          seed := POWER(pi + seed,5)  - TRUNC (POWER(pi + seed,5) );
          pwd := pwd || CHR( 64 + 1 + TRUNC (seed * 26)) ;
       END LOOP;

-- dbms_output.put_line (pwd);
RETURN pwd;
END; This is from my DBA_UTILITES package which is available at www.robonerd.com, the site for ROBO Books International, in the Download discussion area under the Free Stuff group.

Mike Ault
TUSC - www.tusc.com
ROBO Books - www.robonerd.com
rens_at_joxx.nl (|Rens| 0) wrote in message news:<617e9c3f.0209160437.a286a10_at_posting.google.com>...
> Hello,
>
> I'm a total newbie when it comes to (Oracle) databases, so I was
> wondering if someone could help me out with a problem.
>
> I have developed a web-based JSP application. This website uses a
> login-system based on a username/password pair in the database. In
> short, I have one table called 'customer' which is linked to another
> one 'site_customer'. In the latter one, there are two fields,
> username/password.
>
> customer.firstname
> customer.lastname
> customer.customer_num -> site_customer.customer_num
> site_customer.username
> site_customer.password
>
> The customer table also contains a first,- and last name as you can
> see. Now, here comes the problem: I want to generate a username based
> on these names (e.g. 'john smith' would result in 'jsmithxxxx', where
> xxxx is an incremeting number (if there is a 'jonathan smith' or
> something))
>
> How on earth can I do this? I tried to read something about triggers
> that would generate a new record for the site_customer table. I'm
> kinda stuck with this. Also: how do I generate a random
> password/string .. ?
>
> Any help would be greatly appreciated,
>
> Rens van Leeuwen
Received on Tue Sep 17 2002 - 14:50:59 CEST

Original text of this message