parabiz
January 2nd, 2004, 02:46 PM
Hello friends,
What i need is create a rule where i can check the supplied email address has valid email format or not.
Though i have made the user defined function for that i am not able to implement in a RULE
Please help me
User defined Function is as follows
------------------------------------------------------------------------------------------
CREATE FUNCTION EmailValidate (@email varChar(100))
RETURNS int
AS
BEGIN
DECLARE @invalChars varchar(5),@valid int,@badChar varchar(1),@atPos
int,@periodPos int
SET @valid = 1
SET @invalChars = ' /:,;'
--Check to see if it's blank
IF len(ltrim(rtrim(@email))) = 0
SET @valid = 0
ELSE
--Loop invalid characters to see if it exists in email
WHILE len(@invalChars) > 0
BEGIN
SET @badChar = substring(@invalChars,1,1)
IF(charindex(@badChar,@email) > 0)
--If invalid character was found, return 0 to invalidate
SET @valid = 0
SET @invalChars = replace(@invalChars,@badChar,'')
END
--Check to see if "@" exists.
SET @atPos = charindex('@',@email,1)
IF @atPos = 0
SET @valid = 0
--Check to see if extra "@" exists after 1st "@".
IF charindex('@',@email,@atPos+1) > 0
SET @valid = 0
SET @periodPos = charindex('.',@email,@atPos)
IF @periodPos = 0
SET @valid = 0
IF (@periodPos+3) > len(@email)
SET @valid = 0
RETURN (@valid)
END
------------------------------------------------------------------------------------------
Now i want this function to call in Rule or whatever way i need only the valid email addresses in database
Thank you in advance for your help
What i need is create a rule where i can check the supplied email address has valid email format or not.
Though i have made the user defined function for that i am not able to implement in a RULE
Please help me
User defined Function is as follows
------------------------------------------------------------------------------------------
CREATE FUNCTION EmailValidate (@email varChar(100))
RETURNS int
AS
BEGIN
DECLARE @invalChars varchar(5),@valid int,@badChar varchar(1),@atPos
int,@periodPos int
SET @valid = 1
SET @invalChars = ' /:,;'
--Check to see if it's blank
IF len(ltrim(rtrim(@email))) = 0
SET @valid = 0
ELSE
--Loop invalid characters to see if it exists in email
WHILE len(@invalChars) > 0
BEGIN
SET @badChar = substring(@invalChars,1,1)
IF(charindex(@badChar,@email) > 0)
--If invalid character was found, return 0 to invalidate
SET @valid = 0
SET @invalChars = replace(@invalChars,@badChar,'')
END
--Check to see if "@" exists.
SET @atPos = charindex('@',@email,1)
IF @atPos = 0
SET @valid = 0
--Check to see if extra "@" exists after 1st "@".
IF charindex('@',@email,@atPos+1) > 0
SET @valid = 0
SET @periodPos = charindex('.',@email,@atPos)
IF @periodPos = 0
SET @valid = 0
IF (@periodPos+3) > len(@email)
SET @valid = 0
RETURN (@valid)
END
------------------------------------------------------------------------------------------
Now i want this function to call in Rule or whatever way i need only the valid email addresses in database
Thank you in advance for your help