dbTalk Databases Forums  

Help Using Regular Expressions in a column Transformation

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Help Using Regular Expressions in a column Transformation in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
getanothername
 
Posts: n/a

Default Help Using Regular Expressions in a column Transformation - 04-14-2005 , 11:57 AM






I'm still in learning mode with regular expressions and am attempting a
few things during a Trasformation task from one table to another.
Basically what I'm trying to to is this: during the copy/import from one
table to another, I'm trying to somewhat validate an email field. When
it returns valid I want it mapped directly to the corresponding column
in the destination, but when it doesn't match to the expression, I want
it moved to a different column. What I've got so far is this:

Function Main()

Dim objRE
Dim strExample
set objRE = new RegExp
objRE.Pattern = "^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,})+$"
strExample = TRIM( DTSSource("CAP_EMAIL") )
' Test if a match is found
If objRE.Test(strExample) = True Then
DTSDestination("CAP_EMAIL") = DTSSource("CAP_EMAIL")
Else
DTSDestination("invalidCapEmail") = DTSSource("CAP_EMAIL")
End If
Set objRE = Nothing

Main = DTSTransformStat_OK
End Function

It keep returning the following error: ActiveX Scripting Transform '':
Function 'reg' was not found in the script.

Any help would be appreciated.

Reply With Quote
  #2  
Old   
Darren Green
 
Posts: n/a

Default Re: Help Using Regular Expressions in a column Transformation - 04-15-2005 , 07:38 AM






Are you sure the error is for the code you have posted? Code looks fine, and
significantly does not appear to call any function called "reg".


--
Darren Green
http://www.sqldts.com
http://www.sqlis.com

"getanothername" <g (AT) gmail (DOT) com> wrote

Quote:
I'm still in learning mode with regular expressions and am attempting a
few things during a Trasformation task from one table to another.
Basically what I'm trying to to is this: during the copy/import from one
table to another, I'm trying to somewhat validate an email field. When
it returns valid I want it mapped directly to the corresponding column
in the destination, but when it doesn't match to the expression, I want
it moved to a different column. What I've got so far is this:

Function Main()

Dim objRE
Dim strExample
set objRE = new RegExp
objRE.Pattern = "^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,})+$"
strExample = TRIM( DTSSource("CAP_EMAIL") )
' Test if a match is found
If objRE.Test(strExample) = True Then
DTSDestination("CAP_EMAIL") = DTSSource("CAP_EMAIL")
Else
DTSDestination("invalidCapEmail") = DTSSource("CAP_EMAIL")
End If
Set objRE = Nothing

Main = DTSTransformStat_OK
End Function

It keep returning the following error: ActiveX Scripting Transform '':
Function 'reg' was not found in the script.

Any help would be appreciated.



Reply With Quote
  #3  
Old   
getanothername
 
Posts: n/a

Default Re: Help Using Regular Expressions in a column Transformation - 04-15-2005 , 10:25 AM



Darren Green wrote:
Quote:
Are you sure the error is for the code you have posted? Code looks fine, and
significantly does not appear to call any function called "reg".


That's what is completely baffling to me. That's a copy and paste from
the activeX transformation.

-Dan


Reply With Quote
  #4  
Old   
Darren Green
 
Posts: n/a

Default Re: Help Using Regular Expressions in a column Transformation - 04-20-2005 , 08:53 AM



I had another look and used your code in a simple transforn, and it works
fine. You must be getting confused somewhere.


Darren Green
http://www.sqldts.com
http://www.sqlis.com

"getanothername" <g (AT) gmail (DOT) com> wrote

Quote:
Darren Green wrote:
Are you sure the error is for the code you have posted? Code looks fine,
and
significantly does not appear to call any function called "reg".


That's what is completely baffling to me. That's a copy and paste from
the activeX transformation.

-Dan



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.