You can use this option with the Transform Data task, the DataDriven Query task, and the Parallel Data Pump task.If you haven’t enabled the multiphase data pump, you can write code for o
Trang 1.ExceptionFileOptions = 1 ‘DTSExcepFile_SingleFile70 ExceptionFileRowDelimiter = “{CR}{LF}”
.ExceptionFileTextQualifier = “”
.FetchBufferSize = 1 FirstRow = 0
.InputGlobalVariableNames = “”
.LastRow = 0 MaximumErrorCount = 0 ProgressRowCount = 1000 SourceSQLStatement = “”
End With pkg.Tasks.Add tsk
‘Create step for task Set stp = pkg.Steps.New With stp
.Name = “stp” & sBaseName Description = sBaseName TaskName = tsk.Name End With
pkg.Steps.Add stp fctCreateDataDrivenQueryTask = stp.Name Set conSource = Nothing
Set conDest = Nothing Set tsk = Nothing Set cus = Nothing Set stp = Nothing ProcExit:
Exit Function ProcErr:
MsgBox Err.Number & “ - “ & Err.Description GoTo ProcExit
End Function
Conclusion
The Data Driven Query task is a useful tool when you need to specify multiple results for adata transformation The next chapter explains how to use multiple phases with the transforma-tion tasks
L ISTING 8.2 Continued
Trang 2CHAPTER 9
The Multiphase Data Pump
IN THIS CHAPTER
• Enabling the Multiphase Data Pump 228
• Programmatic Flow with Multiple Phases 230
• Using the Phases 233
• Creating a COM Object with Visual C++ to Program the Phases 243
• Creating a Multiphase Data Pump in Code 243
Trang 3The multiphase data pump option allows you to write code at several different points in thedata transformation process You can use this option with the Transform Data task, the DataDriven Query task, and the Parallel Data Pump task.
If you haven’t enabled the multiphase data pump, you can write code for only one point of thedata transformation process—the point at which each row is being transformed After enablingthis option, you can write code for all these phases and subphases:
• Pre Source Phase—Before the source query is executed
• Row Transform Phase—Each row of data is processed
• On Transform Failure—Subphase of the Post Row Transform phase Occurs when there
is an error in the transformation
• On Insert Failure—Subphase of the Post Row Transform phase Occurs when a recordfails to be inserted
• On Insert Success—Subphase of the Post Row Transform phase Occurs when a record issuccessfully inserted
• Batch Complete Phase—A batch of records is successfully inserted
• Post Source Data Phase—The rows have all been processed
• Pump Complete Phase—The transformation task has completed its work
Enabling the Multiphase Data Pump
The last section of this chapter explains how to create a multiphase data pump in code In theDTS Designer, you can enable the multiphase data pump by doing the following:
1 Right-click on the Data Transformation Services node in the Enterprise Manager
2 Select Properties from the pop-up menu
3 Select Show multi-phase pump in DTS Designer on the Package Properties dialog, asshown in Figure 9.1
After selecting the multiphase option, you will see a Phases filter on the Transformation tab ofthe Transform Data Task Properties dialog, as shown in Figure 9.2 Each transformation canimplement one or more of the phases By selecting one of the phases, you can see which trans-formations have implemented a particular phase
The Phases tab of the ActiveX Script Transformation Properties dialog shows the eight phasesand subphases where you can write code, as shown in Figure 9.3 You enable a phase by select-ing the check box beside it You can set the default entrance function and create the defaultcode for all the phases you have selected by clicking the Auto Gen button
Trang 4You can use the Phases filter to show the transformations that are using a particular phase.
Even if you remove the multiphase option from the Package Designer, multiple phases in a transformation will remain However, you will not be able to view all the
NOTE
Trang 5F IGURE 9.3
You can choose which phases you want to use in the ActiveX Script Transformation Properties dialog.
You can enable the multiphase data pump option in code by using the Application object.Here’s the VBScript code to do so:
Function Main Dim app Set app = CreateObject(“DTS.Application”) app.DesignerSettings = DTSDesigner_ShowMultiPhaseTransforms Main = DTSTaskExecResult_Success
End Function
Programmatic Flow with Multiple Phases
Figure 9.4 shows the programmatic flow of the phases and subphases as the Transform Datatask is executed You can choose to implement one, all, or any combination of these phases andsubphases When you implement a phase, the specified entry function is called and the code inthat function is executed
The Pre Source phase is usually executed just once You can execute it more than once by tingDTSTransformStat_SkipFetchas the return value from the entry function
set-The Row Transform phase is executed once for each record in the data source
Trang 6F IGURE 9.4
The programmatic flow in the multiphase data pump.
The Post Row Transform phase is often executed once for each record in the data source It isnot executed if the Row Transform phase is completed successfully, and it does not attempt toinsert a record into the destination
The Transform Failure subphase is executed whenever there is an error in the Row Transformphase
Either the Insert Success subphase or the Insert Failure subphase is executed after an attempt
to insert a record into the destination These subphases are mutually exclusive
The On Batch Complete phase is executed once each time a batch of records is committed
This phase is only used when Fast Load is being used
The Post Source Data and Pump Complete phases are each executed once after all the recordshave been processed
On Insert Failure On Insert Success
OK/SkipFetch Skip Row/Skip Insert
Error/Exception No Error
On Transform Failure
All Rows Processed Follow Next Row in Batch/Skip Fetch
Follow Next Row after Batch
Post Row
Trang 7All six properties of the DTSTransformPhaseInfoobject are read-only They are as follows:
• CurrentPhase—The phase whose code is currently being executed This property usesthe values of the DTSTransformPhaseEnum, which are listed in the last section of thischapter
• CurrentSourceRow—The number of the source row currently being processed Thesource rows are numbered consecutively, beginning with 1
• DestinationRowsComplete—The number of rows that have been successfully insertedinto the data destination For a Data Driven Query task, the value in this property is thenumber of data-driven queries that have been executed
• ErrorRows—The number of rows that have generated an error
• ErrorCode—The error code returned by the phase immediately preceding the currentphase
• TransformStatus—The transformation status returned by the transformation ately preceding the current transformation, when that transformation was executed on thesame row of source data
immedi-Three of these properties (CurrentSourceRow, DestinationRowsComplete, and ErrorRows) usethevt_decimaldata type When you reference these properties in VBScript, you have to con-vert them to long integers:
If bDisplayErrMsg Then msg = “Error in “ & sPhase & vbCrLf msg = msg & Err.Number & “ “ & Err.Description msgbox msg
End If
If bRecordErr Then DTSLookups(“InserttblOrderErrors”).Execute _
Trang 8DTSSource(“OrderID”), _ DTSSource(“TranType”), _ DTSSource(“TranDate”), _ DTSDestination(“OrderID”), _ DTSDestination(“OrderDate”), _ DTSDestination(“RequiredDate”), _ DTSDestination(“ShippedDate”), _ DTSTransformPhaseInfo.CurrentPhase, _ CLng(DTSTransformPhaseInfo.CurrentSourceRow) , _ DTSTransformPhaseInfo.ErrorCode, _
CLng(DTSTransformPhaseInfo.DestinationRowsComplete) , _ DTSTransformPhaseInfo.TransformStatus, _
Now, _ Err.Number, _ Err.Description End If
End Function
Using the Phases
The phases and subphases differ in their access to the source and destination columns Theyalso have different return values that are valid for the entry function Table 9.1 has an overview
of these differences (Where my testing varies from Books Online, the information from BooksOnline appears in parentheses.)
T ABLE 9.1 The Columns and the Return Values Available for Each of the Phases
Phase/Subphase Source Columns Destination Columns Return Values
Trang 9Books Online states that the Pre Source phase, the Transform Failure subphase, and the PostSource Data phase can use all the transformation values that can be returned from a RowTransform phase
The transformation statuses have some different behavior when used for the various phases:
DTSTransformStat_SkipFetch can be used as the return value for the Pre Source phase, the Transform Failure subphase, and the Post Source Data phase, as well as for the Row Transform phase For all of these phases, this transformation status causes the phase’s entry function to be called again immediately.
DTSTransformStat_SkipInsert has the same effect as DTSTransformStat_OK when used for the Pre Source phase, the Transform Failure subphase, and the Post Source Data phase.
DTSTransformStat_SkipRow can be used only for the Row Transform phase It ates an error when used for any other phase.
gener-NOTE
Chapter 7, “Writing ActiveX Scripts for a Transform Data Task,” has a transformation scriptexample that uses two of the transformation phases I have extended that example here to useall eight of the phases and subphases You can find it on the CD in a file called
UseAllPhases.dts
The transformation script has a function called fctPhasethat displays a message box tellingwhich phase is currently active The message is only displayed if the user sets the value of thevariable bDisplayPhasetoTRUEin the Pre Source phase This function calls another function,
fctPhaseName, which finds the current phase number and converts it into a phase name Thesefunctions are shown in Listing 9.2
L ISTING 9.2 Functions That Display the Current Phase Function fctPhase
Dim msg
If bDisplayPhase = True Then msg = fctPhaseName msgbox msg
End If End Function
Trang 10Function fctPhaseName dim sName
Select Case DTSTransformPhaseInfo.CurrentPhase Case 1
sName = “Pre-Source Data Phase”
Case 2 sName = “Post-Source Data Phase”
Case 4 sName = “Row Transform Phase”
Case 8 sName = “On Transform Failure Phase”
Case 16 sName = “On Insert Success Phase”
Case 32 sName = “On Insert Failure Phase”
Case 64 sName = “Batch Complete Phase”
Case 128 sName = “Pump Complete Phase”
End Select fctPhaseName = sName End Function
Pre Source Phase
You can use the Pre Source phase to initialize variables that are used throughout the script Youcan use either global variables or script variables declared outside a function for this purpose
If you use script variables, they will be visible only to functions in this particular script Theywill not be visible outside the task or to other transformations in the same task
If you are using a text file as the destination for your transformation, you could use the PreSource phase to write a header to the file
If you want to execute the code in this phase more than once, you can return theDTSTransformStat_SkipFetchtransformation value from the entry function of the Pre Source
Trang 11Listing 9.3 shows the script variable declarations and the code for the Pre Source phase of theUseAllPhases example In the Pre Source phase, you have the option of setting the display andrecording options for the task You can display message boxes that show the current phase, thetransformation progress, or the transformation errors You can record the progress in
tblOrderProgress and the errors in tblOrderErrors By default, the message boxes are disabledand the recording is enabled
L ISTING 9.3 The Pre Source Phase from the UseAllPhases Task Option Explicit
Dim bDisplayProgressMsg, bRecordProgress Dim bDisplayErrMsg, bRecordErr
Dim bDisplayPhase Dim lLastInsertSuccessKey Function PreSourceMain()
‘Set Display and Recording Options bDisplayProgressMsg = CBool(False) bRecordProgress = CBool(True) bDisplayErrMsg = CBool(False)
You can change the source for the Transform Data task in the Pre Source phase, but that change does not go into effect until the next time the task is executed Even though the Pre Source phase occurs before the first data is processed, the source query has already been executed when this phase occurs, so changing the query has
no effect on the current execution of the task.
If you want to dynamically modify the source query for a Transform Data task, you can do so in a Dynamic Properties task or an ActiveX Script task before the execution
of the Transform Data task You could also modify the source query in a Workflow ActiveX Script for the step associated with the Transform Data task.
NOTE
You cannot access any of the transformation’s source columns in this phase You do haveaccess to the destination columns, however Any values that you assign to the destinationcolumns will remain until they are overwritten or until the first record is inserted into thedestination
Trang 12bRecordErr = CBool(True) bDisplayPhase = CBool(False)
‘Initialize lLastInsertSuccessKey = 0 Call fctPhase
Call fctProgress PreSourceMain = DTSTransformstat_OK End Function
Row Transform Phase
The Row Transform phase is the default transformation phase Writing scripts for this phase isthe topic of Chapter 7, “Writing ActiveX Scripts for a Transform Data Task.”
You are required to have a Row Transform phase in at least one of the transformations definedfor a transformation task All the other phases are optional
You can modify the values in the transformation’s destination columns in most of the phases
This is the only phase where you can actually insert rows into the data destination
Post Row Transform Phase
You cannot write code for the Post Row Transform phase Instead, you write code for one ormore of the subphases associated with this phase:
• On Transform Failure
• On Insert Failure
• On Insert SuccessZero, one, or two of these subphases will be called for each record being transformed None ofthe subphases will be called if the Row Transform phase is successful but returns a transforma-tion status of DTSTranformStat_SkipInsertorDTSTransformStat_SkipRow On Insert Failureand On Insert Success are mutually exclusive—one and only one will be called for eachattempted insert into the data destination
Trang 13On Transform Failure Subphase
If the Row Transform phase returns an error (DTSTransformStat_Erroror
DTSTransformStat_ExceptionRow), the On Transform Failure subphase will be called
You have read access to the source columns and write access to the destination columns in thisphase The UseAllPhases task uses this subphase to call fctError, which creates a record tostore the values of all the source and destination columns (see Listing 9.4)
L ISTING 9.4 The On Transform Failure Subphase from the UseAllPhases Task Function TransFailureMain()
Call fctPhase Call fctError TransFailureMain = DTSTransformstat_OK End Function
On Insert Failure Subphase
The Row Transform phase may be completed successfully, but the insertion of a record into thedata destination may fail The insert failure could be a result of one of the following:
• Violation of a Primary Key constraint
• Violation of a Foreign Key constraint
• Violation of a Unique constraint
• Violation of a Check constraint
An insert failure is not usually caused by a data type conversion error Those errors usually cause a transform failure.
NOTE
You have read access to the transformation’s source columns and write access to the tion columns during this phase It doesn’t do much good to write to these destination columns,though, because they will be set to Null before the next execution of the Row Transformphase
Trang 14destina-The UseAllPhases task also uses this subphase to call fctError, as shown in Listing 9.5.
L ISTING 9.5 The On Insert Failure Subphase from the UseAllPhases Task
Function InsertFailureMain() Call fctPhase
Call fctError InsertFailureMain = DTSTransformstat_OK End Function
On Insert Success Subphase
Whenever a record is successfully inserted into the data destination, the On Insert Success phase is executed As with the On Insert Failure subphase, you have read access to the trans-formation’s source columns and write access to the destination columns during this subphase
sub-This subphase can be used to keep track of the progress of a data transformation when you arenot using Fast Load You would normally use the On Batch Complete phase to do this, but OnBatch Complete is not executed when Fast Load is not being used
This subphase can also be used for maintaining aggregations As each new record is insertedinto the destination, the aggregated value can be updated It is usually possible (and muchmore efficient) to calculate aggregations after all the records have been processed
The UseAllPhases task uses this subphase to store the value of the most recent OrderID thathas been inserted (see Listing 9.6) This value is used in the On Batch Complete phase as addi-tional information on the progress of the transformation for the report
This problem only occurs with this subphase—On Transform Failure and On Insert Success are executed whether or not Fast Load is being used
CAUTION
Trang 15L ISTING 9.6 The On Insert Success Subphase from the UseAllPhases Task Function InsertSuccessMain()2
Call fctPhase
‘Save the Value for use in fctProgress.
lLastInsertSuccessKey = DTSDestination(“OrderID”) InsertSuccessMain = DTSTransformstat_OK
End Function
On Batch Complete Phase
The On Batch Complete phase occurs when a batch is committed to the destination This phase
is not executed when Fast Load is not being used
Books Online states that neither the source nor the destination columns are available in thisphase My testing indicates that they are both available for reading but not writing
The On Batch Complete phase is useful for keeping track of the progress of a data tion The UseAllPhases task uses the phase for that purpose, as shown in Listing 9.7
transforma-L ISTING 9.7 The On Batch Complete Phase and the fctProgress Function from the UseAllPhases Task
Function BatchCompleteMain() Call fctPhase
Call fctProgress BatchCompleteMain = DTSTransformstat_OK End Function
Function fctProgress Dim msg, sProgress, sPhase, lCurrentSourceRow, lDestRowsComplete lCurrentSourceRow = CLng(DTSTransformPhaseInfo.CurrentSourceRow) lDestRowsComplete = CLng(DTSTransformPhaseInfo.DestinationRowsComplete) Select Case DTSTransformPhaseInfo.CurrentPhase
Case DTSTransformPhase_PreSourceData sProgress = “Start”
Case DTSTransformPhase_OnBatchComplete
Trang 16sProgress = “Batch Completed”
Case DTSTransformPhase_OnPumpComplete sProgress = “Finished”
End Select
If bDisplayProgressMsg Then sPhase = fctPhaseName msg = “Currently in “ & sPhase & vbCRLF msg = msg & “Progress: “ & sProgress & vbCRLF msg = msg & “Current Source Row: “ & lCurrentSourceRow & vbCRLF msg = msg & “Destination Rows Complete: “ & _
lDestRowsComplete & vbCRLF msgbox msg
End If
If bRecordProgress Then DTSLookups(“InserttblOrderProgress”).Execute _ lLastInsertSuccessKey, _
sProgress, _ lCurrentSourceRow, _ lDestRowsComplete, _ CLng(DTSTransformPhaseInfo.ErrorRows), _ Now
End If
End Function
Post Source Data Phase
The Post Source Data phase occurs after all the records have been processed This phase isexecuted only once, unless you use the DTSTranformStat_SkipFetchtransformation value toexecute it repeatedly
You can access the data in the transformation’s destination columns, but not in the sourcecolumns
You can use this phase for any final processing that needs to be accomplished on the final row
of data The UseAllPhases task uses this phase for this purpose The last record is inserted intothe destination, using a data modification lookup query (see Listing 9.8)
Trang 17L ISTING 9.8 The Post Source Data Phase from the UseAllPhases Task Function PostSourceMain()
On Error Resume Next Call fctPhase
‘Insert last record DTSLookups(“InserttblOrderDates”).Execute _
DTSDestination(“OrderID”), _ DTSDestination(“OrderDate”), _ DTSDestination(“ShippedDate”), _ DTSDestination(“RequiredDate”)
If Err.Number <> 0 Then Call fctError
End If PostSourceMain = DTSTransformstat_OK End Function
If you specify a value for MaxRows that is less than the number of rows in the data source, the Post Source Data phase code will not be executed.
CAUTION
It appears that the final On Batch Insert phase usually occurs before the Post Source Data phase.
NOTE
Pump Complete Phase
The Pump Complete phase is the last phase of the data transformation It executes only onceand cannot be called to execute again
Books Online states that there is no access to either the source or destination columns fromthis phase, but my testing indicates that there is access to both of them
You would use the Pump Complete phase in much the same way as the Post Source Dataphase The UseAllPhases task uses this phase to write one final record to report on theprogress of the task (see Listing 9.9)
Trang 18L ISTING 9.9 The Pump Complete Phase from the UseAllPhases Task
Function PumpCompleteMain() Call fctPhase
Call fctProgress PumpCompleteMain = DTSTransformstat_OK End Function
Creating a COM Object with Visual C++ to Program the Phases
If you want the best possible performance from your multiphase data pump, you should sider creating a COM object with Visual C++ When you have registered your COM object,you will be able to choose it from the list of available transformations in the Create NewTransformation dialog
See Chapter 32, “Creating a Custom Transformation with VC++,” for more information
Creating a Multiphase Data Pump in Code
Most of the work in creating a multiphase data pump is writing the ActiveX script code for thevarious phases There are two additional things you have to do when you are creating a taskwith phases using Visual Basic code—setting the TransformPhasesproperty and setting theproperties that determine the entrance functions
TheTransformPhasesproperty is the only extended property for the Transformation2object
in SQL Server 2000 This property contains a bitmap that indicates which phases are enabled
Trang 19Setting the Entrance Functions
You have to specify the name of the entrance function for each of the phases that you areusing This is the function that is called when the programmatic flow reaches the point for theparticular phase The entrance function also returns a value that determines the result of thephase
The entrance functions can be referenced through the TransformServerPropertiesof the
Transformationobject, as shown in Listing 9.10
L ISTING 9.10 VBScript Code to Reference the Names of the Entrance Functions Option Explicit
Function Main Dim pkg, tsk, cus, trn, trnprp Set pkg = DTSGlobalVariables.Parent Set tsk = pkg.Tasks(“tskAllPhases”) Set cus = tsk.CustomTask
Set trn = cus.Transformations(“trnAllPhases”) Set trnprp = trn.TransformServerProperties Msgbox trnprp(“PreSourceDataFunctionEntry”) Msgbox trnprp(“FunctionEntry”) ‘The Row Transform Phase
Trang 20Msgbox trnprp(“TransformFailureFunctionEntry”) Msgbox trnprp(“InsertFailureFunctionEntry”) Msgbox trnprp(“InsertSuccessFunctionEntry”) Msgbox trnprp(“BatchCompleteFunctionEntry”) Msgbox trnprp(“PostSourceDataFunctionEntry”) Msgbox trnprp(“PumpCompleteFunctionEntry”) Main = DTSTaskExecResult_Success End Function
Trang 22CHAPTER 10
The Parallel Data Pump Task
• The Transformation Modes 252
• Creating a Parallel Data Pump Task in Visual Basic 254
• A User Interface for the Parallel Data Pump Task 257
Trang 23The Parallel Data Pump task allows you to transform hierarchical rowsets, OLE DB objects inwhich individual columns can themselves be rowsets This task is very similar to the TransformData task or the Data Driven Query task But instead of having one collection of
Transformationobjects for a task, the Parallel Data Pump task has multiple collections—onefor each separate rowset embedded in the hierarchical rowset Each of these collections oftransformations is called a TransformationSetobject
The Parallel Data Pump task is a new feature in SQL Server 2000 It’s so new, in fact, that it doesn’t have a user interface yet You have to create your Parallel Data Pump tasks completely in code That’s unfortunate, especially for a task that is more com- plex than any of the other tasks included with DTS.
I have developed a strategy for using portions of the existing Package Designer face for building a Parallel Data Pump task This strategy is described in the last sec- tion of this chapter, “A User Interface for the Parallel Data Pump Task.”
inter-NOTE
When you double-click on a Parallel Data Pump task icon, the default Custom Task Properties dialog opens with the task’s properties You can modify the task’s proper- ties as long as your source and destination queries are under 269 characters If they are longer than that, the queries will be truncated when you click the OK button You can edit all the properties of a Parallel Data Pump task using Disconnected Edit However, you can’t view or edit any of the properties of the task’s transformation sets or transformations.
CAUTION
The Parallel Data Pump task is not correctly saved to VB The Save operation does not generate an error and the task’s properties are correctly saved, but none of the task’s transformation sets or transformations are saved.
CAUTION
Trang 24Hierarchical Rowsets
A rowset is a data object that has rows and named columns A hierarchical rowset contains
columns that are themselves rowsets Instead of joining child tables to parent tables with tionships between foreign and primary keys, the child tables become a part of the parent table
rela-The Microsoft Data Shaping Service for OLE DB can be used to create a hierarchical rowset
Here is some of the terminology for hierarchical rowsets:
• Shape language—The language used to construct hierarchical rowsets
• Column rowset—A rowset that is contained in a column
• Subsets or chapters—The individual values of a column rowset
• Parent rowset—A rowset that contains a column rowset
• Child rowset—A rowset that is used as the source for a column rowset
• Shape Append Command—The syntax used in creating a hierarchical rowset This mand uses the keywords SHAPE,APPEND,AS,RELATE, and TO
com-• SHAPE—Keyword used at the beginning of a parent rowset
• APPEND—Keyword used at the beginning of the definition of a column rowset
• AS—Keyword used before the name that is being assigned to the column rowset
• RELATE—Keyword used before the field in the column rowset that is being used to jointhe column rowset to the parent rowset
• TO—Keyword used before the field in the parent rowset that is being used to join the umn rowset to the parent rowset
col-Listing 10.1 shows a simple query for a hierarchical rowset The rowset contains a parentrowset with one column rowset If this query were used as the source query in a Parallel DataPump task, you would create two TransformationSet objects, one for each of the two rowsets
You can find all the queries referenced in this chapter in the file HierarchicalQueries.txt
L ISTING 10.1 A Query for a Simple Hierarchical Rowset, Based on the Pubs Sample Database
SHAPE {SELECT stor_id, stor_name, city, state FROM stores}
APPEND ( {SELECT stor_id, ord_num, ord_date, qty, title_id FROM sales}
Trang 25Listing 10.2 shows a more complex hierarchical rowset query that includes four levels ofembedded rowsets Note how all the APPENDphrases come before the first ASphrase when youhave column rowsets embedded inside of column rowsets.
L ISTING 10.2 A Query for a Hierarchical Rowset Containing Five Column Rowsets Embedded to Four Levels
SHAPE {SELECT stor_id, stor_name, city, state FROM stores}
APPEND ( ( SHAPE {SELECT stor_id, ord_num, ord_date, title_id FROM sales}
APPEND ( ( SHAPE {SELECT title_id, title, type, pub_id FROM titles}
APPEND ( {SELECT pub_id, pub_name FROM publishers}
AS publisher_chapters RELATE pub_id TO pub_id )
)
AS title_chapters RELATE title_id TO title_id )
, ( {SELECT ta.title_id, a.au_id, a.au_lname FROM authors a INNER JOIN titleauthor ta
ON a.au_id = ta.au_id}
AS author_chapters RELATE title_id TO title_id )
)
AS sales_chapters RELATE stor_id TO stor_id )