DRAFT ETL+ Load Replace - Suggested Logic
Step by step technical description of the ETL+ Load Replace process. Proposed logic for ETL+ Load Replace procedure
Load Replace Panel UI
<source field
> >= <target T-SQL
>
Variables used below.
<source-table> – source table named in the ETL SQL Statement panel.
The
source field
/left hand entry is a name of a field/column in the <source-table>.
<target-table> – corresponding target table. The table currently selected in the Target Objects panel.
See also ETL+ Load Replace
Process
TargetRowCount
= Obtain the number of rows in the <target-table>.
Zero means the table has zero rows or the table has yet to be created in the DW.IF
TargetRowCount
= 0 AND Target T-SQL string begins with “MAX(“ THENRun Load All
End Load Replace process now.
Evaluate Target T-SQL into
SQLResults
T-SQL syntax: SELECT Target T-SQL FROM <target-table>
Save the results of the T-SQL SELECT statement into a variable named
SQLResults
low-value
variable. Determine the low-value for the date type of <source-table>.source field
.
Pseudo code
low-value
= Low_Value(Data_Type(<source-table>.source field
))Data_Type – a function that returns the name of the datatype of the source field/row named in the parm.
The datatype for all source fields is shown on the Design page.
Low_Value – a function that returns the lowest value for the datatype named in the parm.
For instance Low_Value(T-SQL_smallint) = -32,768
IF
SQLResults
=NULL
AND Target T-SQL NOT = “NULL”
THEN
compare-value
= low value for the data type of <source-table>.source field
(left hand box)
ELSE
compare-value
=SQLResults
Filter and Extract Source Table into temp/staging table (pseudo query language)
Extract INTO staging-table ! pseudo query language
FROM <source-table>
WHERE <source-table>.source field
>=compare-value
Delete all rows in
target T-SQL
that meet the filter criteriaT-SQL: DELETE FROM target-table WHERE target-table.
target T-SQL
>=SQLResults
Add/Insert records from staging-table into target-table.
T-SQL: INSERT FROM staging-table INTO target-table.
<source-table> – source table named in the ETL SQL Statement panel.
<target-table> – corresponding target table. The table currently selected in the Target Objects panel.
Related Pages
ETL+ Load Replace – update & eventual replacement for Load Replace content in ETL+ Table Load Types
LOADMAX Option
Concept: Create a new, ETL+ only function called LOADMAX
that can be used in place of the MAX
function in Target T-SQL.
Replace step # 2 above with
2. IF TargetRowCount
= 0 AND Target T-SQL string begins with “LOADMAX(“ THEN
Run Load All
End Load Replace process now.
ELSE
Change “LOADMAX(
" to "MAX(
" in Target T-SQL string.