How to force a varchar number into a string?
Hello,
I'm doing a program in which you can reset a users password. This password needs to contain enlist one number in order to be "TRUE" among others (which are already done).
I have been looking for information about how to accomplish this task but my efforts haven't get me a solution.
I have found things about "rtrim" (which I think have nothing to do with what I'm trying), REGEXP_LIKE (could it be that the "like" is only for Oracle?).
Before I post the function know that this one serves no purpose but my own learning. Basically, I'm quite new at this.
Here goes the function:
delimiter //
drop function if exists login;
Create Function login (nombreusuario varchar(20), password varchar (10), repite varchar (10), vieja varchar (10))
Returns boolean no SQL
begin
/* Comparar los valores nombre y password con los reales */
declare comparacion varchar(30);
declare compa varchar(30);
set comparacion = (SELECT nombre
FROM usuarios
WHERE (nombre = nombreusuario)) ;
set compa = (SELECT contrasena
FROM usuarios
WHERE (nombre = nombreusuario));
if (comparacion = nombreusuario) and (compa = vieja) and length(password)>=6 and (password = repite) then
/* Hacer el UPDATE */
UPDATE usuarios
SET contrasena = password
WHERE nombre = nombreusuario;
/*Como es verdadero devuelve verdadero */
Return TRUE;
else
Return FALSE ;
end if;
end
//
delimiter ;
...........
I have try the next modification on the "if" line:
if (comparacion = nombreusuario) and (compa = vieja) and length(password)>=6 and REGEXP_LIKE (password, '[0-9]') and (password = repite) then
But it comes up with this error when I try to use the function:
ERROR 1305 (42000): FUNCTION incidencias.REGEXP_LIKE does not exist
What should I add into the if line to force a number on the password?
Thank you very much for your time.
Subject
Written By
Posted
How to force a varchar number into a string?
February 13, 2015 08:47AM
February 14, 2015 09:19AM
February 14, 2015 10:22AM
February 14, 2015 10:29AM
February 14, 2015 11:52PM
February 15, 2015 12:00AM
February 15, 2015 08:10AM
February 15, 2015 08:53AM
February 15, 2015 12:22PM
February 15, 2015 01:33PM
February 16, 2015 05:25AM
February 18, 2015 03:46PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.