DELETE FROM lgdat.stka WHERE v6stat = 'C';
DELETE FROM lgdat.stkmm where avtype = 'C';
DELETE FROM lgdat.stkmp where awtype = 'C';
DELETE FROM lgdat.icstm where cgtype = 'C';
DELETE FROM lgdat.icstp where chtype = 'C';
DELETE FROM lgdat.icstr where y0type = 'C';
WITH
repl AS (
    SELECT 
        *
    FROM 
        (   
            VALUES
                ('GAB12000DE2','Garden Bowl - Slate Blue','GAB12000A34C012LRTOQ',0.93886),
                ('GAB14000DE2','Garden Bowl - Slate Blue','GAB14000A34C012LRTOT',1.30893),
                ('GAB18000DE2','Garden Bowl - Slate Blue','GAB18000A34C006LRTOW',2.04076),
                ('GAB22000DE2','Garden Bowl - Slate Blue','GAB22000A34C006LRTOZ',3.54985),
                ('GAB12000BG3','Garden Bowl - Teal','GAB12000A34C012LRTOQ',0.93886),
                ('GAB14000BG3','Garden Bowl - Teal','GAB14000A34C012LRTOT',1.30893),
                ('GAB18000BG3','Garden Bowl - Teal','GAB18000A34C006LRTOW',2.04076),
                ('GAB22000BG3','Garden Bowl - Teal','GAB22000A34C006LRTOZ',3.54985),
                ('CNA06000A42','Caribbean Planter - Warm Gray','CNA06000A50C024LRCGA',0.36037),
                ('CNA08000A42','Caribbean Planter - Warm Gray','CNA08000A50C024LRCGC',0.44575),
                ('CNA06000F89','Caribbean Planter - Raspberry','CNA06000A50C024LRCGA',0.36222),
                ('CNA08000F89','Caribbean Planter - Raspberry','CNA08000A50C024LRCGC',0.45024),
                ('CNA10000F89','Caribbean Planter - Raspberry','CNA10000A42C012LRBXI',0.65195),
                ('CNA12000F89','Caribbean Planter - Raspberry','CNA12000A42C012LRBXJ',1.63119),
                ('CNA06000BG3','Caribbean Planter - Teal','CNA06000A50C024LRCGA',0.36222),
                ('CNA08000BG3','Caribbean Planter - Teal','CNA08000A50C024LRCGC',0.45024),
                ('CNA10000BG3','Caribbean Planter - Teal','CNA10000A42C012LRBXI',0.65195),
                ('CNA12000BG3','Caribbean Planter - Teal','CNA12000A42C012LRBXJ',1.63119),
                ('CNA06000A10','Caribbean Planter - White','CNA06000A50C024LRCGA',0.35215),
                ('CNA08000A10','Caribbean Planter - White','CNA08000A50C024LRCGC',0.44641),
                ('CNA10000A10','Caribbean Planter - White','CNA10000A42C012LRBXI',0.64485),
                ('CNA12000A10','Caribbean Planter - White','CNA12000A42C012LRBXJ',1.61797),
                ('CNA30000A10','Caribbean Planter - White','CNA30000G18C002LRCDG',28.85),
                ('LIA06000DE2','Classic Planter - Slate Blue','LIA06000A34C024LRTIV',0.35842),
                ('LIA08000DE2','Classic Planter - Slate Blue','LIA08000A34C024LRTIZ',0.56212),
                ('LIA10000DE2','Classic Planter - Slate Blue','LIA10000A34C012LRTJD',1.8113),
                ('LIA12000DE2','Classic Planter - Slate Blue','LIA12000A34C012LRTJH',2.42383),
                ('LIA14000DE2','Classic Planter - Slate Blue','LIA14000A34C012LRTJL',2.73708),
                ('LIA16000DE2','Classic Planter - Slate Blue','LIA16000A34C006LRTJP',3.05778),
                ('LIA20000DE2','Classic Planter - Slate Blue','LIA20000A34C006LRTJT',5.63275),
                ('LIA24000DE2','Classic Planter - Slate Blue','LIA24000A34C006LRTJY',6.35725),
                ('LIA06000B78','Classic Planter - Seafoam','LIA06000A34C024LRTIV',0.35842),
                ('LIA08000B78','Classic Planter - Seafoam','LIA08000A34C024LRTIZ',0.56212),
                ('LIA10000B78','Classic Planter - Seafoam','LIA10000A34C012LRTJD',1.8113),
                ('LIA12000B78','Classic Planter - Seafoam','LIA12000A34C012LRTJH',2.42383),
                ('LIA14000B78','Classic Planter - Seafoam','LIA14000A34C012LRTJL',2.73708),
                ('LIA16000B78','Classic Planter - Seafoam','LIA16000A34C006LRTJP',3.05778),
                ('LIA20000B78','Classic Planter - Seafoam','LIA20000A34C006LRTJT',5.63275),
                ('LIA24000B78','Classic Planter - Seafoam','LIA24000A34C006LRTJY',6.35725),
                ('SLI06000DE2','Classic Saucer - Slate Blue','SLI06000A34C024LRTKB',0.18237),
                ('SLI08000DE2','Classic Saucer - Slate Blue','SLI08000A34C024LRTKF',0.29674),
                ('SLI10000DE2','Classic Saucer - Slate Blue','SLI10000A34C012LRTKJ',0.54887),
                ('SLI12000DE2','Classic Saucer - Slate Blue','SLI12000A34C012LAH13',0.72483),
                ('SLI14000DE2','Classic Saucer - Slate Blue','SLI14000A34C012LAH16',0.99295),
                ('SLI17000DE2','Classic Saucer - Slate Blue','SLI17000A34C012LAH19',1.10433),
                ('SLI20000DE2','Classic Saucer - Slate Blue','SLI20000A34C006LAH24',1.0319),
                ('SLI24000DE2','Classic Saucer - Slate Blue','SLI24000A34C006LRTLD',1.95471),
                ('SLI06000B78','Classic Saucer - Seafoam','SLI06000A34C024LRTKB',0.18237),
                ('SLI08000B78','Classic Saucer - Seafoam','SLI08000A34C024LRTKF',0.29674),
                ('SLI10000B78','Classic Saucer - Seafoam','SLI10000A34C012LRTKJ',0.54887),
                ('SLI12000B78','Classic Saucer - Seafoam','SLI12000A34C012LAH13',0.72483),
                ('SLI14000B78','Classic Saucer - Seafoam','SLI14000A34C012LAH16',0.99295),
                ('SLI16000B78','Classic Saucer - Seafoam','SAA14001A10C006LRCDJ',1.10433),
                ('SLI20000B78','Classic Saucer - Seafoam','SLI20000A34C006LAH24',1.0319),
                ('SLI24000B78','Classic Saucer - Seafoam','SLI24000A34C006LRTLD',1.95471),
                ('ECA06000DE2','Eclipse Planter - Slate Blue','ECA06000A101009LRCIG',0.42036),
                ('ECA08000DE2','Eclipse Planter - Slate Blue','ECA08000A101006LRCID',0.63429),
                ('ECA10000DE2','Eclipse Planter - Slate Blue','ECA10000A341020LRCEL',0.92453),
                ('ECA12000DE2','Eclipse Planter - Slate Blue','ECA12000A101006LRCIA',1.25858),
                ('ECA16000DE2','Eclipse Planter - Slate Blue','ECA16000A34C010LRCEX',2.57535),
                ('ECA20000DE2','Eclipse Planter - Slate Blue','ECA20000A341006LRCEU',4.17568),
                ('ECA06000B78','Eclipse Planter - Seafoam','ECA06000A101009LRCIG',0.42036),
                ('ECA08000B78','Eclipse Planter - Seafoam','ECA08000A101006LRCID',0.63429),
                ('ECA10000B78','Eclipse Planter - Seafoam','ECA10000A341020LRCEL',0.92453),
                ('ECA12000B78','Eclipse Planter - Seafoam','ECA12000A101006LRCIA',1.25858),
                ('ECA16000B78','Eclipse Planter - Seafoam','ECA16000A34C010LRCEX',2.57535),
                ('ECA20000B78','Eclipse Planter - Seafoam','ECA20000A341006LRCEU',4.17568),
                ('GDP08000DE2','Hanging Garden Planter - Slate Blue','SAA14001A10C006LRCDJ',1.5),
                ('GDP08000BG3','Hanging Garden Planter - Teal','SAA14001A10C006LRCDJ',1.5),
                ('MSA12001DE2','Marina Planter - Slate Blue','MSA12001A341008LRCFQ',1.85199),
                ('MSA16001DE2','Marina Planter - Slate Blue','MSA16001A34C004LRAYN',2.80127),
                ('MSA20001DE2','Marina Planter - Slate Blue','MSA20001A34C004LRCFW',4.88869),
                ('MSA12001A42','Marina Planter - Warm Gray','MSA12001A341008LRCFQ',1.85199),
                ('MSA16001A42','Marina Planter - Warm Gray','MSA16001A34C004LRAYN',2.80127),
                ('MSA20001A42','Marina Planter - Warm Gray','MSA20001A34C004LRCFW',4.88869),
                ('MSA12001B78','Marina Planter - Seafoam','MSA12001A341008LRCFQ',1.85199),
                ('MSA16001B78','Marina Planter - Seafoam','MSA16001A34C004LRAYN',2.80127),
                ('MSA20001B78','Marina Planter - Seafoam','MSA20001A34C004LRCFW',4.88869),
                ('SEA07001DE2','Sedona Planter - Slate Blue','SEA07001B15C008LRAZR',0.60131),
                ('SEA09001DE2','Sedona Planter - Slate Blue','SEA09001B15C008LRAZS',0.91061),
                ('SEA12001DE2','Sedona Planter - Slate Blue','SEA12001B15C006LRAZU',1.55347),
                ('SEA14001DE2','Sedona Planter - Slate Blue','SEA14001B15C006LRAZT',2.14701),
                ('SEA16000DE2','Sedona Planter - Slate Blue','SAA14001A10C006LRCDJ',2.51344),
                ('SEA07001B78','Sedona Planter - Seafoam','SEA07001B15C008LRAZR',0.60131),
                ('SEA09001B78','Sedona Planter - Seafoam','SEA09001B15C008LRAZS',0.91061),
                ('SEA12001B78','Sedona Planter - Seafoam','SEA12001B15C006LRAZU',1.55347),
                ('SEA14001B78','Sedona Planter - Seafoam','SEA14001B15C006LRAZT',2.14701),
                ('SEA16000B78','Sedona Planter - Seafoam','SAA14001A10C006LRCDJ',2.51344),
                ('SEA07001A42','Sedona Planter - Warm Gray','SEA07001B15C008LRAZR',0.60131),
                ('SEA09001A42','Sedona Planter - Warm Gray','SEA09001B15C008LRAZS',0.91061),
                ('SEA12001A42','Sedona Planter - Warm Gray','SEA12001B15C006LRAZU',1.55347),
                ('SEA14001A42','Sedona Planter - Warm Gray','SEA14001B15C006LRAZT',2.14701),
                ('SEA16000A42','Sedona Planter - Warm Gray','SAA14001A10C006LRCDJ',2.51344),
                ('VNP18000A42','Venetian Flower Box - Warm Gray','VNP18000A34C006LRTPN',1.44406),
                ('VNP24000A42','Venetian Flower Box - Warm Gray','VNP24000A34C006LRTPR',1.63875),
                ('VNP30000A42','Venetian Flower Box - Warm Gray','VNP30000A34C006LRTPV',2.31994),
                ('VNP18000A10','Venetian Flower Box - White','VNP18000A34C006LRTPN',1.44406),
                ('VNP24000A10','Venetian Flower Box - White','VNP24000A34C006LRTPR',1.63875),
                ('VNP30000A10','Venetian Flower Box - White','VNP30000A34C006LRTPV',2.31994),
                ('SVN18000A42','Venetian Flower Box Tray - Warm Gray','SVN18000A34C006LRTPZ',0.94787),
                ('SVN24000A42','Venetian Flower Box Tray - Warm Gray','SVN24000A34C006LRTQD',1.04921),
                ('SVN30000A42','Venetian Flower Box Tray - Warm Gray','SVN30000A34C006LRTQH',1.25193),
                ('SVN18000A10','Venetian Flower Box Tray - White','SVN18000A34C006LRTPZ',0.94787),
                ('SVN24000A10','Venetian Flower Box Tray - White','SVN24000A34C006LRTQD',1.04921),
                ('SVN30000A10','Venetian Flower Box Tray - White','SVN30000A34C006LRTQH',1.25193),
                ('ASP06000P81','Aria Square Planter - Fresh Avocado','SAA14001A10C006LRCDJ',0.852601662887377),
                ('ASP08000P81','Aria Square Planter - Fresh Avocado','SAA14001A10C006LRCDJ',1.4348492660222),
                ('ASP10000P81','Aria Square Planter - Fresh Avocado','SAA14001A10C006LRCDJ',2.69581191222571),
                ('ASP12000P81','Aria Square Planter - Fresh Avocado','SAA14001A10C006LRCDJ',4.1862917611489),
                ('ASP16000P81','Aria Square Planter - Fresh Avocado','SAA14001A10C006LRCDJ',9.09797526283241),
                ('ASP06000P80','Aria Square Planter - Glossy White','SAA14001A10C006LRCDJ',0.852601662887377),
                ('ASP08000P80','Aria Square Planter - Glossy White','SAA14001A10C006LRCDJ',1.4348492660222),
                ('ASP10000P80','Aria Square Planter - Glossy White','SAA14001A10C006LRCDJ',2.69581191222571),
                ('ASP12000P80','Aria Square Planter - Glossy White','SAA14001A10C006LRCDJ',4.1862917611489),
                ('ASP16000P80','Aria Square Planter - Glossy White','SAA14001A10C006LRCDJ',9.09797526283241),
                ('ASP06000P26','Aria Square Planter - Black Onyx','SAA14001A10C006LRCDJ',0.852601662887377),
                ('ASP08000P26','Aria Square Planter - Black Onyx','SAA14001A10C006LRCDJ',1.4348492660222),
                ('ASP10000P26','Aria Square Planter - Black Onyx','SAA14001A10C006LRCDJ',2.69581191222571),
                ('ASP12000P26','Aria Square Planter - Black Onyx','SAA14001A10C006LRCDJ',4.1862917611489),
                ('ASP16000P26','Aria Square Planter - Black Onyx','SAA14001A10C006LRCDJ',9.09797526283241),
                ('ASP06000DE3','Aria Square Planter - Sapphire Blue','SAA14001A10C006LRCDJ',0.852601662887377),
                ('ASP08000DE3','Aria Square Planter - Sapphire Blue','SAA14001A10C006LRCDJ',1.4348492660222),
                ('ASP10000DE3','Aria Square Planter - Sapphire Blue','SAA14001A10C006LRCDJ',2.69581191222571),
                ('ASP12000DE3','Aria Square Planter - Sapphire Blue','SAA14001A10C006LRCDJ',4.1862917611489),
                ('ASP16000DE3','Aria Square Planter - Sapphire Blue','SAA14001A10C006LRCDJ',9.09797526283241),
                ('ARP06000P81','Aria Round Planter - Fresh Avocado','SAA14001A10C006LRCDJ',0.70132159315339),
                ('ARP08000P81','Aria Round Planter - Fresh Avocado','SAA14001A10C006LRCDJ',1.16639446371434),
                ('ARP10000P81','Aria Round Planter - Fresh Avocado','SAA14001A10C006LRCDJ',2.06032580911152),
                ('ARP12000P81','Aria Round Planter - Fresh Avocado','SAA14001A10C006LRCDJ',3.3063246409675),
                ('ARP16000P81','Aria Round Planter - Fresh Avocado','SAA14001A10C006LRCDJ',7.29303859560353),
                ('ARP06000P80','Aria Round Planter - Glossy White','SAA14001A10C006LRCDJ',0.70132159315339),
                ('ARP08000P80','Aria Round Planter - Glossy White','SAA14001A10C006LRCDJ',1.16639446371434),
                ('ARP10000P80','Aria Round Planter - Glossy White','SAA14001A10C006LRCDJ',2.06032580911152),
                ('ARP12000P80','Aria Round Planter - Glossy White','SAA14001A10C006LRCDJ',3.3063246409675),
                ('ARP16000P80','Aria Round Planter - Glossy White','SAA14001A10C006LRCDJ',7.29303859560353),
                ('ARP06000P26','Aria Round Planter - Black Onyx','SAA14001A10C006LRCDJ',0.70132159315339),
                ('ARP08000P26','Aria Round Planter - Black Onyx','SAA14001A10C006LRCDJ',1.16639446371434),
                ('ARP10000P26','Aria Round Planter - Black Onyx','SAA14001A10C006LRCDJ',2.06032580911152),
                ('ARP12000P26','Aria Round Planter - Black Onyx','SAA14001A10C006LRCDJ',3.3063246409675),
                ('ARP16000P26','Aria Round Planter - Black Onyx','SAA14001A10C006LRCDJ',7.29303859560353),
                ('ARP06000DE3','Aria Round Planter - Sapphire Blue','SAA14001A10C006LRCDJ',0.70132159315339),
                ('ARP08000DE3','Aria Round Planter - Sapphire Blue','SAA14001A10C006LRCDJ',1.16639446371434),
                ('ARP10000DE3','Aria Round Planter - Sapphire Blue','SAA14001A10C006LRCDJ',2.06032580911152),
                ('ARP12000DE3','Aria Round Planter - Sapphire Blue','SAA14001A10C006LRCDJ',3.3063246409675),
                ('ARP16000DE3','Aria Round Planter - Sapphire Blue','SAA14001A10C006LRCDJ',7.29303859560353),
                ('ANP12000A39','Aspen Planter - Charcoal','SAA14001A10C006LRCDJ',7.09567010761259),
                ('ANP15000A39','Aspen Planter - Charcoal','SAA14001A10C006LRCDJ',10.3452077597572),
                ('ANP17500A39','Aspen Planter - Charcoal','SAA14001A10C006LRCDJ',14.4071298249379),
                ('CAS12000P26','Cascade Tall Square Planter - Black Onyx','SAA14001A10C006LRCDJ',6.29314316635745),
                ('CAS15000P26','Cascade Tall Square Planter - Black Onyx','SAA14001A10C006LRCDJ',15.3787074829932),
                ('CAS12000P80','Cascade Tall Square Planter - Glossy White','SAA14001A10C006LRCDJ',6.29314316635745),
                ('CAS15000P80','Cascade Tall Square Planter - Glossy White','SAA14001A10C006LRCDJ',15.3787074829932),
                ('CAR12000P26','Cascade Tall Round Planter - Black Onyx','SAA14001A10C006LRCDJ',8.71982072275551),
                ('CAR15000P26','Cascade Tall Round Planter - Black Onyx','SAA14001A10C006LRCDJ',15.8462292221236),
                ('CAR12000P80','Cascade Tall Round Planter - Glossy White','SAA14001A10C006LRCDJ',8.71982072275551),
                ('CAR15000P80','Cascade Tall Round Planter - Glossy White','SAA14001A10C006LRCDJ',15.8462292221236),
                ('SKR12000G27','Santa Fe Round Planter - Black Sand','SAA14001A10C006LRCDJ',4.42057974300831),
                ('SKR16000G27','Santa Fe Round Planter - Black Sand','SAA14001A10C006LRCDJ',9.79167124866476),
                ('SKR12000E66','Santa Fe Round Planter - Cavern Clay','SAA14001A10C006LRCDJ',4.42057974300831),
                ('SKR16000E66','Santa Fe Round Planter - Cavern Clay','SAA14001A10C006LRCDJ',9.79167124866476),
                ('SKR12000A56','Santa Fe Round Planter - Pebble Gray','SAA14001A10C006LRCDJ',4.42057974300831),
                ('SKR16000A56','Santa Fe Round Planter - Pebble Gray','SAA14001A10C006LRCDJ',9.79167124866476),
                ('SKS12000G27','Santa Fe Square Planter - Black Sand','SAA14001A10C006LRCDJ',5.54815910808768),
                ('SKS16000G27','Santa Fe Square Planter - Black Sand','SAA14001A10C006LRCDJ',10.8425160791589),
                ('SKS12000E66','Santa Fe Square Planter - Cavern Clay','SAA14001A10C006LRCDJ',5.54815910808768),
                ('SKS16000E66','Santa Fe Square Planter - Cavern Clay','SAA14001A10C006LRCDJ',10.8425160791589),
                ('SKS12000A56','Santa Fe Square Planter - Pebble Gray','SAA14001A10C006LRCDJ',5.54815910808768),
                ('SKS16000A56','Santa Fe Square Planter - Pebble Gray','SAA14001A10C006LRCDJ',10.8425160791589),
                ('WBP16000P82','Whiskey Barrel Planter - Aged Oak','SAA14001A10C006LRCDJ',4.5)
            ) x("target","descr","clone","cost")
)
,istka AS (
    INSERT INTO lgdat.stka
    SELECT
        repl.target v6part
        ,v6plnt
        ,v6unti
        ,v6rpln
        ,v6tpln
        ,v6tdys
        ,v6mrps
        ,v6abcc
        ,v6ccpy
        ,v6lcdt
        ,v6dbcc
        ,v6ordq
        ,v6opcy
        ,v6mult
        ,v6fut1
        ,v6fut2
        ,v6scdt
        ,v6plan
        ,v6cntr
        ,v6untp
        ,v6lvl
        ,v6pack
        ,v6pacu
        ,v6prpt
        ,v6kitc
        ,v6proc
        ,v6lrsp
        ,v6lrsc
        ,v6lrsf
        ,v6lrmp
        ,v6lrmc
        ,v6lrmf
        ,v6lwsp
        ,v6lwsc
        ,v6lwsf
        ,v6lcsp
        ,v6lcsc
        ,v6lcsf
        ,v6lcmp
        ,v6lcmc
        ,v6lcmf
        ,v6lssc
        ,v6lssf
        ,v6lsmp
        ,v6lsmc
        ,v6lsmf
        ,v6mpck
        ,v6mpku
        ,v6altf
        ,v6dbuy
        ,v6scdp
        ,v6selp
        ,v6rcps
        ,v6recu
        ,v6recc
        ,v6ftmf
        ,v6csmu
        ,v6ntky
        ,v6minq
        ,v6maxq
        ,v6moqt
        ,v6estv
        ,v6corg
        ,v6psor
        ,'C' v6stat
        ,v6reas
        ,v6auty
        ,v6unto
        ,v6reqc
        ,v6buyr
        ,v6lead
        ,v6optr
        ,v6multp
        ,v6minr
        ,v6perc
        ,v6ola
        ,v6mpqt
        ,v6dpst
        ,v6spdt
        ,v6bbdt
        ,v6orlt
        ,v6autr
        ,v6repp
        ,v6rept
        ,v6shrk
        ,v6fcfn
        ,v6auto
        ,v6olok
        ,v6oepy
        ,v6prfr
        ,v6cmtl
        ,v6drws
        ,v6drwl
        ,v6denc
        ,v6drel
        ,v6ddat
        ,v6drwn
        ,v6drws2
        ,v6drwl2
        ,v6denc2
        ,v6drel2
        ,v6ddat2
        ,v6drwn2
        ,v6lotf
        ,v6serf
        ,v6lotb
        ,v6lota
        ,v6lotv
        ,v6stcl
        ,v6vlcd
        ,v6sppp
        ,v6sppc
        ,v6mppp
        ,v6mppc
        ,v6frml
        ,v6istr
        ,v6engc
        ,v6revl
        ,v6rdat
        ,v6rcvlc
        ,v6sflc
        ,v6cusr
        ,v6cdat
        ,v6ctme
        ,v6uusr
        ,v6udat
        ,v6utme
        ,v6fut3
        ,v6fut4
        ,v6fut5
        ,v6flg1
        ,v6flg2
        ,v6flg3
        ,v6flg4
        ,v6flg5
        ,v6flg6
        ,v6flg7
        ,v6flg8
        ,v6flg9
        ,v6flg10
        ,v6fut6
        ,v6fut7
        ,v6fut8
        ,v6fut9
        ,v6fut10
        ,v6fut11
        ,v6fut12
        ,v6fut13
        ,v6fut14
        ,v6fut15
        ,v6fut16
        ,v6fut17
        ,v6fut18
        ,v6fut19
        ,v6fut20
        ,v6fut21
        ,v6fut22
        ,v6fut23
        ,v6fut24
        ,v6fut25
        ,v6fut26
        ,v6fut27
        ,v6fut28
        ,v6fut29
        ,v6fut30
        ,v6fut31
        ,v6fut32
        ,v6fut33
        ,v6fut34
        ,v6fut35
        ,v6fut36
        ,v6fut37
        ,v6fut38
        ,v6fut39
        ,v6fut40
        ,v6fut41
        ,v6fut42
        ,v6fut43
        ,v6fut44
        ,v6fut45
        ,v6prcl
        ,v6dbac
        ,v6scdpt
        ,v6apsup
        ,v6matp
        ,v6matm
        ,v6mesc
        ,v6crtm
        ,v6lled
        ,v6pctr
        ,v6inqu
        ,v6clexp
    FROM
        repl
        INNER JOIN lgdat.stka ON
            v6part = repl.clone
    RETURNING *
)
, istkmm AS (
    INSERT INTO lgdat.stkmm
    SELECT
        repl.target avparta
        ,repl.descr avdes1
        ,avdes2
        ,avdes3
        ,avunti
        ,avmajg
        ,avming
        ,avmajs
        ,avmins
        ,avglcd
        ,avgled
        ,avharm
        ,avclss
        ,avfut3
        ,avfut4
        ,avfut5
        ,avfutc
        ,avfutd
        ,avupcc
        ,avgtin
        ,avnwht
        ,avnwun
        ,avsvol
        ,avsvun
        ,avengc
        ,avrevl
        ,avrdat
        ,avcoil
        ,avfut9
        ,avmspc
        ,avslif
        ,avdplt
        ,avuver
        ,avcata
        ,avfedc
        ,avtaxr
        ,avcust
        ,"avcpt#"
        ,"avrev#"
        ,avfut7
        ,avfut8
        ,avfutb
        ,avldat
        ,'C' avtype
        ,avfutk
        ,avfutn
        ,avppap
        ,avcusr
        ,avcdat
        ,avctme
        ,avuusr
        ,avudat
        ,avutme
        ,avsizc
        ,avstlc
        ,avcolc
        ,avassc
        ,avsasc
        ,avlcoil
        ,avgdfl
        ,avvdfl
        ,avwoqf
        ,avnmfc
        ,avfuth
        ,avfuti
        ,avfutl
        ,avfutm
        ,avfutp
        ,avfutq
        ,avfutr
        ,avprun
        ,avtotp
        ,avdisc
        ,avinvt
        ,avbk01
        ,avbill
        ,avbk04
        ,avbk06
        ,avoldd
        ,avoldd2
        ,avlotf
        ,avserf
        ,avorig
        ,avplan
        ,avminq
        ,avmaxq
        ,avlead
        ,avscdt
        ,avestv
        ,avcntr
        ,avuntp
        ,avlvl
        ,avmoqt
        ,avpack
        ,avpacu
        ,avprpt
        ,avkitc
        ,avproc
        ,avlrsp
        ,avlrsc
        ,avlrsf
        ,avlrmp
        ,avlrmc
        ,avlrmf
        ,avlwsp
        ,avlwsc
        ,avlwsf
        ,avlcsp
        ,avlcsc
        ,avlcsf
        ,avlcmp
        ,avlcmc
        ,avlcmf
        ,avlssc
        ,avlssf
        ,avlsmp
        ,avlsmc
        ,avlsmf
        ,avmpck
        ,avmpku
        ,avaltf
        ,avdbuy
        ,avfut1
        ,avfut2
        ,avfut6
        ,avfuta
        ,avfutg
        ,avrecu
        ,avftmf
        ,avrecc
        ,avfutj
        ,avabcc
        ,avcorg
        ,avperc
        ,avoptr
        ,avmult
        ,avminr
        ,avshrk
        ,avstat
        ,avreas
        ,avspdt
        ,avbbdt
        ,avpsor
        ,avfuto
        ,avdrws
        ,avdrwl
        ,avdenc
        ,avdrel
        ,avddat
        ,avfute
        ,avdrws2
        ,avdrwl2
        ,avdenc2
        ,avdrel2
        ,avddat2
        ,avfutf
        ,avstcl
        ,avvlcd
        ,avsppp
        ,avsppc
        ,avmppp
        ,avmppc
        ,avflg01
        ,avflg02
        ,avflg03
        ,avflg04
        ,avflg05
        ,avflg06
        ,avflg07
        ,avflg08
        ,avflg09
        ,avflg10
        ,avfut01
        ,avfut02
        ,avfut03
        ,avfut04
        ,avfut05
        ,avfut06
        ,avfut07
        ,avfut08
        ,avfut09
        ,avfut10
        ,avfut11
        ,avfut12
        ,avfut13
        ,avfut14
        ,avfut15
        ,avfut16
        ,avfut17
        ,avfut18
        ,avfut19
        ,avfut20
        ,avfut21
        ,avfut22
        ,avfut23
        ,avfut24
        ,avfut25
        ,avfut26
        ,avfut27
        ,avfut28
        ,avfut29
        ,avfut30
        ,avfut31
        ,avfut32
        ,avfut33
        ,avfut34
        ,avfut35
        ,avfut36
        ,avfut37
        ,avfut38
        ,avfut39
        ,avfut40
        ,avfut41
        ,avfut42
        ,avfut43
        ,avfut44
        ,avfut45
        ,avudft
        ,avfrml
        ,avhaza
        ,avlled
        ,avdbac
        ,avscdpt
        ,avfifo
        ,avantid
        ,avsubt
        ,avprcl
        ,avotp
        ,avcbyl
        ,avsrvc
        ,avspal
        ,avpgrp
    FROM
        repl
        INNER JOIN lgdat.stkmm m ON
            m.avpart = repl.clone
    RETURNING *
)
, istkmp AS (
    INSERT INTO lgdat.stkmp
    SELECT
        repl.target awpart
        ,repl.descr awdes1
        ,awdes2
        ,awdes3
        ,awunti
        ,awmajg
        ,awming
        ,awmajs
        ,awmins
        ,awgldc
        ,awgled
        ,awharm
        ,awclss
        ,awfut3
        ,awfut4
        ,awfut5
        ,awfutc
        ,awfutd
        ,awupcc
        ,awgtin
        ,awnwht
        ,awnwun
        ,awsvol
        ,awsvun
        ,'C' awtype
        ,awvend
        ,"awvpt#"
        ,"awrev#"
        ,awengc
        ,awrevl
        ,awrdat
        ,awfut7
        ,awfut8
        ,awfutb
        ,awcoil
        ,awfut9
        ,awmspc
        ,awuver
        ,awcata
        ,awslif
        ,awfutk
        ,awfutn
        ,awppap
        ,awdplt
        ,awgdfl
        ,awvdfl
        ,awwoqf
        ,awlcoil
        ,awnmfc
        ,awsizc
        ,awstlc
        ,awcolc
        ,awassc
        ,awsasc
        ,awcusr
        ,awcdat
        ,awctme
        ,awuusr
        ,awudat
        ,awutme
        ,awfuth
        ,awfuti
        ,awfut6
        ,awfutl
        ,awfutm
        ,awfuto
        ,awfutp
        ,awfutq
        ,awfutr
        ,awldat
        ,awlotf
        ,awserf
        ,awoldd
        ,awbk02
        ,awoldd2
        ,awdisc
        ,aworig
        ,awfedc
        ,awtaxr
        ,awbk01
        ,awbk03
        ,awbk04
        ,awbk05
        ,awinvt
        ,awconv
        ,awunto
        ,awreqc
        ,awoptr
        ,awlead
        ,awcorg
        ,awcntr
        ,awola
        ,awuntp
        ,awshrk
        ,awlvl
        ,awmoqt
        ,awpack
        ,awpacu
        ,awprpt
        ,awbuyr
        ,awauty
        ,awmpqt
        ,awabcc
        ,awstat
        ,awproc
        ,awlrsp
        ,awlrsc
        ,awlrsf
        ,awlrmp
        ,awlrmc
        ,awlrmf
        ,awlwsp
        ,awlwsc
        ,awlwsf
        ,awlcsp
        ,awlcsc
        ,awlcsf
        ,awlcmp
        ,awlcmc
        ,awlcmf
        ,awlssc
        ,awlssf
        ,awlsmp
        ,awlsmc
        ,awlsmf
        ,awmpck
        ,awmpku
        ,awfutj
        ,awfutg
        ,awdbuy
        ,awperc
        ,awreas
        ,awfut1
        ,awfut2
        ,awaltf
        ,awftmf
        ,awrecu
        ,awrecc
        ,awpsor
        ,awfuta
        ,awscdt
        ,awdrws
        ,awdrwl
        ,awdenc
        ,awdrel
        ,awddat
        ,awdrws2
        ,awdrwl2
        ,awdenc2
        ,awdrel2
        ,awddat2
        ,awfute
        ,awfutf
        ,awstcl
        ,awvlcd
        ,awsppp
        ,awsppc
        ,awmppp
        ,awmppc
        ,awflg01
        ,awflg02
        ,awflg03
        ,awflg04
        ,awflg05
        ,awflg06
        ,awflg07
        ,awflg08
        ,awflg09
        ,awflg10
        ,awfut01
        ,awfut02
        ,awfut03
        ,awfut04
        ,awfut05
        ,awfut06
        ,awfut07
        ,awfut08
        ,awfut09
        ,awfut10
        ,awfut11
        ,awfut12
        ,awfut13
        ,awfut14
        ,awfut15
        ,awfut16
        ,awfut17
        ,awfut18
        ,awfut19
        ,awfut20
        ,awfut21
        ,awfut22
        ,awfut23
        ,awfut24
        ,awfut25
        ,awfut26
        ,awfut27
        ,awfut28
        ,awfut29
        ,awfut30
        ,awfut31
        ,awfut32
        ,awfut33
        ,awfut34
        ,awfut35
        ,awfut36
        ,awfut37
        ,awfut38
        ,awfut39
        ,awfut40
        ,awfut41
        ,awfut42
        ,awfut43
        ,awfut44
        ,awfut45
        ,awudft
        ,awfrml
        ,awhaza
        ,awlled
        ,awdbac
        ,awscdpt
        ,awfifo
        ,awantid
        ,awsubt
        ,awprcl
        ,awotp
        ,awcbyl
        ,awsrvc
        ,awspal
        ,awpgrp
    FROM
        repl
        INNER JOIN lgdat.stkmp ON
            awpart = repl.clone
    RETURNING *
)
, iicstm AS (
    INSERT INTO lgdat.icstm
    SELECT
        target cgpart
        ,cglabs
        ,cgmats
        ,cgburs
        ,cglaba
        ,cgmata
        ,cgbura
        ,cglabv
        ,cgmatv
        ,cgburv
        ,cgtptd
        ,cgsdat
        ,cost cgstcs
        ,cgaccs
        ,cgavcs
        ,cgstoc
        ,cgacoc
        ,cgavoc
        ,cgsqty
        ,cgaqty
        ,'C' cgtype
        ,cgbrfs
        ,cgbrvs
        ,cgbrfa
        ,cgbrva
        ,cgbrfv
        ,cgbrvv
        ,cgfuts
        ,cgfuta
        ,cgfutv
        ,cgplnt
        ,cgfut1
        ,cgfut2
        ,cgfut3
        ,cgfut4
        ,cgfut5
        ,cgflg1
        ,cgflg2
        ,cgflg3
    FROM
        repl
        INNER JOIN lgdat.icstm ON
            cgpart = clone
    RETURNING *
)
,iicstp AS (
    INSERT INTO lgdat.icstp
    SELECT
        target chpart
        ,chluc
        ,chlcc
        ,chlfc
        ,chldc
        ,chl1c
        ,chl2c
        ,chsuc
        ,chscc
        ,chsfc
        ,chsdc
        ,chs1c
        ,chs2c
        ,chscr
        ,chlcr
        ,chsdat
        ,cost chstcs
        ,chaccs
        ,chavcs
        ,chsdr
        ,chs1r
        ,chs2r
        ,chldr
        ,chl1r
        ,chl2r
        ,chsqty
        ,chaqty
        ,'C' chtype
        ,chcurr
        ,chsdwc
        ,chacwc
        ,chplnt
        ,chavuc
        ,chavxc
        ,chavdc
        ,chav1c
        ,chav2c
        ,chavfc
        ,chfut1
        ,chfut2
        ,chfut3
        ,chfut4
        ,chfut5
        ,chflg1
        ,chflg2
        ,chflg3
        ,chflg4
        ,chflg5
        ,chflg6
        ,chflg7
        ,chcrcd
    FROM
        repl
        INNER JOIN lgdat.icstp ON
            chpart = clone
    RETURNING *
)
,iicstr AS (
    INSERT INTO lgdat.icstr
    SELECT
        target y0part
        ,y0plnt
        ,cost y0stcs
        ,y0accs
        ,y0avcs
        ,y0suc
        ,y0sshr
        ,y0sshc
        ,y0soc
        ,y0sdat
        ,y0sqty
        ,y0luc
        ,y0lshc
        ,y0loc
        ,y0aqty
        ,'C' y0type
        ,y0smat
        ,y0slab
        ,y0svbr
        ,y0sfbr
        ,y0sotc
        ,y0lmat
        ,y0llab
        ,y0lvbr
        ,y0lfbr
        ,y0lotc
        ,y0amat
        ,y0alab
        ,y0avbr
        ,y0afbr
        ,y0aotc
        ,y0aunc
        ,y0ashc
        ,y0acrc
        ,y0fut1
        ,y0fut2
        ,y0fut3
        ,y0fut4
        ,y0fut5
        ,y0flg1
        ,y0flg2
        ,y0flg3
        ,y0crcd
        ,y0stcr
        ,y0lscr
    FROM
        repl
        INNER JOIN lgdat.icstr ON
            clone = y0part
    RETURNING *
)
SELECT 'stka', count(*) FROM istka
UNION ALL
SELECT 'stkmm', count(*) FROM istkmm
UNION ALL
SELECT 'stkmp', count(*) FROM istkmp
UNION ALL
SELECT 'icstm', count(*) FROM iicstm
UNION ALL
SELECT 'icstp', count(*) FROM iicstp
UNION ALL
SELECT 'icstr', count(*) FROM iicstr;