Groups | Blog | Home
all groups > sql server dts > october 2003 >

sql server dts : Multi-phase data pump question


Richard R
10/31/2003 2:24:25 PM
Hi guys,

I've been trying to load in fixed-width text data into my data warehouse,
but the data occasionally has errors in one field.
( It's supposed to be an integer and the OS/400 system that generates the
file randomly puts in alphabetic characters. This causes the load to fail as
the string can't conver to an integer.)

Is it possible to use the multi-phase data pump to put these rows into
another file, or better still another SQL table?
It should be, but I'm struggling a bit.
I can't have two destination connections on my data pump, which presumably
means I have to define the destination in the ActiveX. Which means, I think,
that I have to send the data to a file system object. Can I just write the
row to a text file withour worrying about the formatting?

Any help appreciated.
Especially as I've lent my DTS books to a colleague and can't get them back
for a week :-<

Richard R

Allan Mitchell
10/31/2003 2:39:35 PM
Why not do this in 2 phases.

1. Use the DB2 equivalent of ISNUMERIC() to load the good stuff
2. Load the other stuff into wherever you want using a seperate datapump



--


Allan Mitchell (Microsoft SQL Server MVP)
MCSE,MCDBA
www.SQLDTS.com
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org




[quoted text, click to view]

Richard R
10/31/2003 4:45:16 PM
Hi,

Unfortunately I don't own the OS/400 system, all I get is the text file to
deal with as best as I can.

I've tried the vb script below on the Transform fail phase of the pump.
What seems to happen though is that the Create Object line works, but non of
the rest do, and the job fails with the same error anyway.

'-------Start------------------
dim objFSO
dim objStream

const OUTPUT_FILE = "c:\logfile.txt"
const fsoForWriting = 2

set objFSO = CreateObject("Scripting.FileSystemObject")
MsgBox("Createobject" )

set objStream = objFSO.OpenTextFile(OUTPUT_FILE,
fsoForWriting, true)
MsgBox("OpenTextfile" )

strRecord = "This is just a test string"
MsgBox(strRecord )

objStream.WriteLine(strRecord)
objStream.WriteBlankLines(1)

Main = DTSTaskExecResult_Success

'------------End-------------

[quoted text, click to view]

Allan Mitchell
10/31/2003 5:08:36 PM
You do not have to own the AS400 system. The SQL Query is in your DTS
DataPump task


Anyway

This works for me


--Source Table
CREATE TABLE IHoldMixedStuff(col1 varchar(10))
--Destination Table
CREATE TABLE IHoldOnlyIntegerValues(col1 INT)
--Data In Source that will blow up for Destination
INSERT IHoldMixedStuff(col1) VALUES('ABC')
INSERT IHoldMixedStuff(col1) VALUES('123')



Function TransFailureMain()


dim objFSO
dim objStream

const OUTPUT_FILE = "c:\logfile.txt"
const fsoForWriting = 2

set objFSO = CreateObject("Scripting.FileSystemObject")

set objStream = objFSO.OpenTextFile(OUTPUT_FILE, fsoForWriting, true)

strRecord = DTSSource("col1")

objStream.WriteLine(strRecord)
objStream.WriteBlankLines(1)

objStream.close



TransFailureMain = DTSTransformstat_OK
End Function


--


Allan Mitchell (Microsoft SQL Server MVP)
MCSE,MCDBA
www.SQLDTS.com
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org




[quoted text, click to view]

Richard R
10/31/2003 5:44:33 PM
Sorry Allan, it's been a long week and I'm being really thick

Can you explain where in the process I run your inserts?
My c:\duffdata.txt file is something like:

1234
5678
9012
abc
4523
.. and so on.

Are you suggesting I bring this into a single file that can handle any
format, and then transform those rows with a SQL query?

Thanks for your help (and patience)

Rich





[quoted text, click to view]

Allan Mitchell
10/31/2003 5:55:04 PM
What I have done here is identify those records (PK) that failed.

What you can then do is up to you but.

1. Look at those values the following morning
2. Mail them to the admin
3. You are not going to be able to rework them as they came from the Source
and for the sake of the source they are correct
4. Why is the destination a different datatype to the destination if they
need to represent the same thing.



--


Allan Mitchell (Microsoft SQL Server MVP)
MCSE,MCDBA
www.SQLDTS.com
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org




[quoted text, click to view]

Richard R
10/31/2003 6:40:41 PM
Hi Allan,

I've just properly compared your code to mine, and realised there are a
couple of lines different:

You finish:
objStream.close
TransFailureMain = DTSTransformstat_OK

Whereas I finish
Main = DTSTaskExecResult_Success

I don't have time to try it right now, but I'm prepared to bet that this
makes all the difference.

Have a good weekend,

Rich



[quoted text, click to view]



Richard R
11/20/2003 10:24:47 AM
Hi Allan

Sorry I didn't post back earlier. I've ben off sick for a fortnight.

Your solution worked fine, and I've now got it running in the live system,
including posting headers & footers onto the file.

Thanks for your help


Richard

[quoted text, click to view]

AddThis Social Bookmark Button