Tải bản đầy đủ (.pdf) (31 trang)

Microsoft SQL Server 2000 Data Transformation Services- P15

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (198.18 KB, 31 trang )

//Destination column type is 8-byte real.
*pdAverage = (double) cint;
for (j = 0; j < m_iDecimals; j++) {
*pdAverage = *pdAverage / 10;
}
memcpy(pDestData, pdAverage, *pulLength);
break;
default:
*pdAverage = (double) cint;
for (j = 0; j < m_iDecimals; j++) {
*pdAverage = *pdAverage / 10;
}
memcpy(pDestData, pdAverage, *pulLength);
break;
}
*pulStatus = DBSTATUS_S_OK;
//END ADDED CODE----------------------------------------------
return NOERROR;
}
Adding the Project’s Error Definitions
If you want to return specific error codes for conditions that occur in your custom transforma-
tion, add them in the *.idl file following this line:
import “ocidl.idl”;
The code that defines the errors for the AvgXform task is shown in Listing 32.5.
L
ISTING
32.5
The Error Definitions for the Custom Task
//-----------Error codes for the Average Transform---------------------
typedef [helpstring(
“Error codes generated by the average transform”)]


enum DTSAvgTransformError {
DTSAvgXform_Error_WRONG_NUM_DEST_COLS = 0x80041001,
DTSAvgXform_Error_NOT_CORRECT_TYPE = 0x80041002
} DTSAvgXformError, *LPDTSAvgXformError;
//---------------------------------------------------------------------
Extending the Power of DTS
P
ART
VI
676
L
ISTING
32.4
Continued
39 0672320118 CH32 11/13/00 5:04 PM Page 676
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Registering the Custom Transformation
The ATL COM wizard creates the code to register the custom transformation during the build
process. You can register the transformation on other computers by using the
regsvr32
command-line utility:
regsvr32 <Path>\Average.dll
Unlike the registration of custom tasks, there are no special registry entries that need to be
created for a custom transformation.
Conclusion
DTS provides many excellent built-in tools. One of the best characteristics of DTS, though, is
its extensibility. You can build new tools within the DTS environment to handle new data trans-
formation situations more effectively.
Build a custom transformation when you need the best possible performance, or when you are
using a particular ActiveX transformation script repeatedly.

Creating a Custom Transformation with VC++
C
HAPTER
32
32
C
REATING A
C
USTOM
T
RANSFORMATION
677
39 0672320118 CH32 11/13/00 5:04 PM Page 677
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
39 0672320118 CH32 11/13/00 5:04 PM Page 678
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
INDEX
A
aborting Transform Data task, 191
accessing
COM objects, 27
files, 360
package log files, 456-458
AcquireConnection method, 122
activating debugging, 55
Active Template Library, see ATL
ActiveX Script task, 40, 50
constants, 42
creating, 346-348, 362-363
Data Driven Query task, 214, 221-222

debugging, 558-561
destination columns, 202
empty strings, 203-204
errors, 555
executing, 182-183
failure precedence constraints, 476
full outer joins, 206
global variables, 196-197
lookups, 199-200
null values, 203-204
objects, 42
Package Object Browser, 47, 49
programmatic identifier, 622
properties, 172, 347, 496
strings, 202-203
Transform Data task, 260-263
transformations, 152, 172, 183-187
Workflow, 494, 495
writing, 52
40 0672320118 index 11/13/00 4:55 PM Page 679
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
adding
680
adding, 624
assignments, 370
data, 89-90, 220
fields, 277-278, 280
global variables, 347,
496
joins, 91

lookups, 200
objects, 29, 317-320
properties to custom
transformations,
665-667
records, 201
ADO recordset, 355-356
AllowIdentityInsert
property, 158, 217
Analysis Services
Processing task, 40,
44, 93, 413-417,
420-421
analyzing
errors, 554-555
Internet clickstream
data, 39-40
API calls, 361
appending
files, 152
hierarchical rowsets,
249
Application object, 28
creating, 446
hierarchy, 625-628
log files, 21
properties, 626
referencing, 350
architecture, DTS pack-
ages, 8, 10

archiving data, 38, 60
arguments, DTSRun
utility, 20-21
AS keyword rowsets,
249
assignments
constants, 374
data files, 373
Dynamic Properties
task, 367-368,
370-371
environment variables,
374
global variables, 372
INI files, 373-374
SQL queries, 372
asynchronous
processing, 392
ATL transformation,
662-663, 677
Attributes field
(dimension tables),
85-87
AutoCommit
Transaction property,
465, 482
automating
filters, 415-416
global variables, 55
avoiding dimension

tables, 94-98
B
batch files, 228, 427
bcp command line
utility, 268, 427, 585
binary files, 427
bindings table, 214
browsing meta data,
591, 593
bulk copy, 426
Bulk Insert task, 50,
268
bcp command line
utility, 268
connections, 102
creating, 270, 287-290
data, 89
delimited text files, 271
destination files, 270
executing, 26
fixed-length text files,
271
format files, 52,
271-276
programmatic identifier,
622
properties
Check Constraints,
281-282
Code Page, 284-285

Data File Type, 285
Enable Identity
Insert, 283-284
Keep Nulls, 282-283
Maximum Errors,
286
Rows, 286
Sorted Data, 284
selecting, 269-270
Transform Data task,
268
business analysis data,
64-69, 589
40 0672320118 index 11/13/00 4:55 PM Page 680
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Commit On option
681
C
cache, DTS packages,
56
calculating values, 37
Called Package, 385,
386
calling
functions, 535
wizards, 504-507
capturing rowsets,
299-300
case sensitivity,
197-198

Catalog property, 108
categories, objects, 612
CCLine property, 407
cdw command-line
utility, 505
changing Server
property, 368
chaos, 483
Check Constraints
property, 281-282
CheckingDurationIn
Secs property, 656
CheckingIntervalInSecs
property, 656
child packages, 378-383
child rowsets, 249
cleansing data, 89, 91
clearing objects,
317-320
clickstream data, 39-40,
60
CloseConnection
property, 496
closing connections,
122-123, 480
clustering data, 67
code
events, 42
libraries, 530
pages, 284-285

wizards, 506-507
writing phases, 228
Batch Complete, 228
On Batch Complete,
240-241
On Insert
Failure/Success,
228, 239-240
On Transform
Failure, 228
Post Source Data,
228, 241-242
Pre Source, 228
Pump Complete,
228, 242
Row Transform, 228
collation, 314
collections
Add method, 624
Count property, 624
CustomTask interface,
639-640
Insert method, 624
Item method, 624
methods, 625
New method, 624
Package2 object, 445
Parallel Data Pump
task, 252
Parent property, 466,

624
Properties, 625
referencing, 350
transformations,
146-147
columns, 159
creating, 167-169
destination, 139-141,
143
identity, 283
lineage, 600-601
mappings, 519-520
names, 575-577
ordinal numbers,
575-577
prediction queries, 419
properties, 159-160
referencing, 183
rowsets, 249
scripts, 187
source, 139-141, 143
Transform Data task,
138
COM objects
accessing, 27
creating, 243
references, 546
command-line utilities
cdw, 505
DTSQiz, 505

DTSRun, 53, 427
osql, 427
wizards, 505-506
CommandProperties
property, 294
commands, 21-22
CommandTimeout
property, 294
Commit On option, 482
40 0672320118 index 11/13/00 4:55 PM Page 681
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Commit Transaction option
682
Commit Transaction
option, 485
CommitSuccess
property, 496
comparing transfor-
mations, 573-574
Component Object
Model, see COM
components, 370
configuration
Connection object,
113-115
packages, 479-481
transactions, 484
Connected property,
112
ConnectImmediate

property, 112
Connection object, 27
Bulk Insert task, 102
Called Package, 385
closing, 122-123, 480
collections, 109, 624
creating, 512-513, 633
data, 37, 102, 109-110
DTS Designer, 10,
103-104
Execute SQL task, 102
methods, 122
modifying, 121-122
OLAP data source, 119
OLE DB providers, 102,
114-115, 119, 121
opening, 123
Oracle DB Provider,
121
packages, 628-631
Parallel Data Pump task,
102
properties, 104-114, 294
referencing, 348-349
Server property, 368
text files, 115-119
transactions, 486-487
Transform Data task,
102
troubleshooting, 490

trusted, 20
Visual Basic, 104,
114-115
consolidation, data,
36-37
constants
ActiveX scripts, 42
Data Driven Query task,
219-220
Dynamic Properties
task, 374
constraints
copying, 316
disabling, 281
enabling, 281
failure precedence, 476
monitoring, 281-282
precedence, 471-476
conversion
binary files to text, 427
Visual Basic to
VBScript, 360-361
Copy Column transfor-
mation, 149, 168-169,
573
Copy Database Wizard,
33-34, 45, 52
calling, 504-507
databases, 502-503,
508-509

DTS packages, 511-512
location, 508-509
objects, 510-511
packages, 17
Copy SQL Server
Objects task
collation, 314
CopySchema, 313
data, 313-314
databases, 310-311
DropDestinationObjects
First, 313
executing, 26
IncludeDependencies,
313
objects, 312-315
performance, 310
programmatic identifier,
622
properties, 317
script file directories,
316-317
user default options,
315-316
Visual Basic, 320-323
copying
collation, 314
commands, 21
constraints, 316
data, 313-314

databases, 52, 310-311,
316
FOREIGN keys, 316
indexes, 316
logins, 316
objects, 314-315, 502
permissions, 316
PRIMARY keys, 316
tables, 516
triggers, 316
40 0672320118 index 11/13/00 4:55 PM Page 682
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
custom tasks
683
Copying in ActiveX
Script transformation,
573
CopySchema property,
313
Count property, 624
covering indexes, 585
Create Process task, 50
CreateCustomToolTip
method, 645
CreateProcess object,
428
creating
ActiveX Script task,
346-348, 362-363
Analysis Services

Processing task,
420-421
Application object, 446
Bulk Insert task, 270,
287-290
columns, 167-169
COM object, 243
connections, 512-513,
553
constants, 374
Copy Column transfor-
mation, 168-169
cubes, 656-657
custom transformations,
664
Data Driven Query task,
216-219, 223-226
data files, 7-8, 111, 373
Data Mining Prediction
Query task, 421-423
destination columns,
159-160
DTS Designer, 103-104,
534
Dynamic Properties
task, 375-376
environment variables,
374
Execute Process task,
407-408, 428-429

Execute SQL task,
292-294, 306-308
files, 151-152
FTP task, 327-331
global variables, 55,
194-197, 372
INI files, 373-374
local variables, 192
LocalCubeTask, 657
lookups, 199-200
loops, 352-355, 542
Message Queue task,
400-403
multiphase data pump,
243
objects, 31, 312-313,
360
packages, 31-32,
497-499, 613
Parallel Data Pump
task, 254-257
parameter queries, 217
precedence constraints,
473-474
Read File transforma-
tion, 170-171
source columns,
159-160
SQL queries, 372-373
steps, 470

subordinate dimensions,
98
tasks, 11-12, 335, 536,
620-621, 634-635
templates, 32-33
Transfer Databases task,
341-342
Transform Data task,
128-129, 160-165, 201
transformation scripts,
185
transformations,
167-169
UDL files, 111
utility packages,
384-386
variables, 360
Write File transforma-
tion, 170-171
CreationDate property,
466
CreatorComputerName
property, 466
CRM (Customer
Relationship
Management), 60
cubes
creating, 656-657
fact tables, 84
processing, 413-414

updating, 414
CurrentPhase property,
232
CurrentSource
property, 232
custom tasks
creating, 634-635
Description property,
639
40 0672320118 index 11/13/00 4:55 PM Page 683
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
custom tasks
684
errors, 650-652
events, 650-652
Execute method,
640-645
interface, 636-637
log files, 650-652
Name property, 637-638
Properties collection,
639-640
referencing, 635,
653-654
registering, 652-653
threads, 653
VBScript, 654-655
Visual Basic, 653-655
custom transforma-
tions, 152

creating, 664
error definitions, 676
PreValidateSchema
method, 667-669
ProcessPhase method,
672-676
properties, 665-667
registering, 677
starting, 664-665
ValidateSchema
method, 669-671
Customer Relationship
Management (CRM),
60
CustomTask property,
615-616, 619
CustomTaskUI inter-
face, 645-649
D
data
adding, 89-90, 220
Analysis Services
Processing task, 93
archiving, 38, 60
business analysis, 64-69
cleansing, 89, 91
clustering, 67
connections, 37
consolidation, 36-37
copying, 313-314

Data Mining Prediction
Query task, 93
decision trees, 67
destination tables,
277-278
duplication, 37
Dynamic Properties
task, 370-371, 373
enterprise data flow, 61
errors, 554-555
exporting, 427, 596
history, 68
homogenization, 37
Import/Export Wizard,
519-520
Information Model, 598
Internet, 60
loading, 569-572
marts, 37-38
merging, 206
messages, 396-399
mining, 45, 67-68, 93,
419, 421-423
missing, 205
modifying, 201, 503
moving, 60
OLTP systems, 68
processing, 502
queries, 253, 514-515
reading, 483

returning, 464-465
sources, 102, 191, 419,
460
storage, 60, 72, 74, 76
summarization, 37
transactions, 63-64
transformations, 7-8, 49,
61-63, 228
types, 311
warehousing, 37-38
Web clickstream, 69
see also Meta Data
Services
Data Driven Query task
ActiveX scripts, 214
bindings table, 214
connections, 102
creating, 216-219,
223-226
executing, 26
hierarchy, 617
parameter queries,
214-216
performance, 215, 582
programmatic identifier,
622
source queriesevents,
214
tables, 220-222
transformation status,

219-220
Data File Type prop-
erty, 285
Data Lineage Fields
field, 82, 85
Data Link files, 109-111
40 0672320118 index 11/13/00 4:55 PM Page 684
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
destination files
685
Data Pump task,
661-662
Data Transform task,
47
Data Transformation
Services, see DTS
Data Transformation
task, see Transform
Data task
databases
copying, 52, 310-311,
316
creating, 341-342
destination, 311, 508
information models,
598-599
location, 508-509
moving, 502-503
objects, 310
properties, 419

queries, 294
replication, 585
repository, 598
source, 311, 508
tables, 310
transferring, 336-337
transformations, 599
upgrading, 36, 502, 504
users, 311
databases servers
Bulk Insert task
executing, 26
Copy SQL Server
Objects task, 26
Execute SQL task, 26
Transfer Databases task,
26
DataDrivenQueryTask
object, 218
DataPumpOptions
property, 158
DataPumpTask object,
136, 612
DataSource property,
108, 415
DataType property,
159, 197
DateTime in ActiveX
Script transformation,
573

DateTime String trans-
formation, 148-149,
171, 573
DB providers, 102
debugging, 55
ActiveX scripts,
558-561
Enterprise Manager,
561-563
Package Manager,
561-563
Decimals property,
666-667
decision trees, 67
declaring variables,
192-193, 446, 450, 531
decompression, text
files, 427
default settings
configuration, 311
Transformation Flags
dialog, 145
deleting
DTS packages, 21
messages, 399
packages, 443
queries, 218
records, 221
rows, 518
tasks, 645

delimited text files, 271
Description property
ActiveX Script task, 347
Connection object, 112
CustomTask interface,
637, 639
Data Mining Prediction
Query, 419
Dynamic Properties
task, 367
Execute Package task,
380
Execute Process task,
428
Package object, 368,
436-438, 465
PackageInfo object, 445
Send Mail task, 407
Step object, 497
Task object, 619
Transform Data task,
129-130
DesignerSettings prop-
erty, 626
destination files, 116
Bulk Insert task, 270
collections, 252
columns, 139-141, 143
creating, 159-160
databases, 311, 508

error rows, 49
Import/Export Wizard,
516-518
objects, 312-313
referencing, 183
40 0672320118 index 11/13/00 4:55 PM Page 685
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
destination files
686
rows, 517-518
source files, 276-281
strings, 370
Transfer Databases task,
335
Transform Data task,
137-139
values, 202
DestTranslateChar
property, 317
DestUseTransaction
property, 317
development errors,
554
Dimension Keys field
(fact tables), 82
dimension tables, 79
fields, 85
loading, 90-92
records, 84-85
size, 84

subordinate, 92, 95-98
updates, 94-98
directories
manipulating, 357
moving, 326
script files, 316-317
dirty read, 483
disabling
constraints, 281
steps, 480, 496
Disconnected Edit tool,
29-30, 54
displaying
commands, 21
objects, 318-320
packages, 457-458
dividing, see splitting
documentation, pack-
age connections,
628-631
DropDestination
ObjectsFirst, 313
DTS packages (Data
Transformation
Services), 16, 40, 42,
460
Application hierarchy,
613, 625-628
architecture, 8, 10
Browser, 591

bulk copy, 426
caches, 56
connections, 10,
103-104
data transformations,
7-8
deleting, 21
Execute Package task,
42, 44
Execute Process task,
407-408, 426-429
executing, 23-24, 367,
511-512, 521
FTP task, 42
Import/Export Wizard,
34-36, 504
Information Model, 599
logs, 56
Message Queue task,
42, 44
multiphase data pump,
228-230
passwords, 21
performance, 122-123
precedence constraints,
473-474
Query Designer,
132-133
replication, 521
reports, 406

retrieving, 14
saving, 14, 521, 523
scheduling, 24-25,
511-512, 521-522
Send Mail task, 406
steps, 534
storing, 14-15
structured storage file,
15
templates, 54
Transact-SQL code,
549-552
Transformation Status
value, 188
versions, 16, 467
Visual Basic, 15, 53
see also packages
DTSIsoLevel transac-
tions, 483-484
DTSLineage variables,
602
DTSMQMessage object,
395
DTSMQType properties,
394
DTSPackageDSO, 460
DTSRun utility, 427
arguments, 20-21
Dynamic Properties
task, 366

Execute Process task,
378
packages, 22-23
Windows, 53
40 0672320118 index 11/13/00 4:55 PM Page 686
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
errors
687
DTSStepScriptResult
scripts, 495
DTSTransformPhaseInfo
object, 232-233
DTSTransformStat val-
ues, 188-191, 219-220
DTSWiz command-line
utility, 505
duplication, data, 37
DWGuide tool, 599-600
Dynamic Properties
task, 40, 42-43, 326
assignment, 367-368,
370-371
constants, 374
creating, 375-376
data files, 373
DTSRun utility, 366
environment variables,
374
files, 366
global variables, 372

INI files, 373-374
object models, 28-29
packages, 366
programmatic identifier,
623
properties, 367-370
queries, 372-373
statements, 366
dynamic values, 383
E
E-commerce, 60
Edit method, 645, 647
editing
objects, 29-30
overwriting, 31
properties, 29-30
email 406
empty strings, 203-204
enabling
constraints, 281
lineage variables,
602-604
multiphase data pump,
228-230
properties, 283
triggers, 282
encryption
commands, 22
packages, 443-445
parameters, 20

enterprise data flow,
61
Enterprise Manager
packages, 17
debugging, 561-563
wizards, 505
entrance functions,
244-245
entry function, 361
EnumPackageInfos
method, 447
EnumPackageLineages
method, 608
EnumPackageLogRecor
ds method, 458
EnumStepLogRecords
method, 458
EnumTaskLogRecords
method, 458
environment variables,
374
ErrorIfFileNotFound
property, 170
ErrorIfReceiveMessage
TimeOut property,
400
errors
ActiveX, debugging,
558-561
administration notifica-

tion, 558
custom tasks, 650-652
definitions, 676
development, 554
Enterprise Manager,
561-563
format files, 275
generating, 49-50
global variables, 195
handling, 154-156, 361,
540-541, 548-549, 554
Import/Export Wizard,
523
incorrect data, 554-555
local variables, 193
lookups, 557
maximum, 286
On Transform Failure
subphase, 238-239
Package Manager,
561-563
packages, 481
raising, 555-557
records, 557-558
rows, 49, 556
storing, 340
transactions, 558
troubleshooting, 557
40 0672320118 index 11/13/00 4:55 PM Page 687
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.

×