How to optimise an SELECT
Hi guys,
I have to develop a procedure which will update a column ( im_column_to_be_updt ) into a big_table
The structure of the table:
big_table (462611506 records)
CREATE TABLE big_table
im_cod_banca VARCHAR2(05),
im_dta_rif DATE,
im_cod_identifier1 VARCHAR2(08),
im_cod_identifier2 VARCHAR2(03),
im_cod_identifier3 VARCHAR2(01),
im_cod_identifier4 VARCHAR2(02),
im_imp_statis NUMBER(21, 03),
im_cod_tipo_cliente VARCHAR2(03),
im_cod_prod VARCHAR2(06),
im_parlatore_private VARCHAR2(50),
im_promotore VARCHAR2(50),
im_linea_orig VARCHAR2(08),
im_column_to_be_updt VARCHAR2(08),
im_f_soc_gruppo CHAR(01),
im_source_table NUMBER(03, 0),
im_sett_attivita VARCHAR2(03) DEFAULT 'NGE',
im_ramo_attivita VARCHAR2(03) DEFAULT 'NGE',
im_naz_resid VARCHAR2(03) DEFAULT 'NGE',
im_cap_resid VARCHAR2(10) DEFAULT 'NGE',
im_agrario VARCHAR2(06) DEFAULT 'NGE',
im_gest_corp VARCHAR2(50) DEFAULT 'NGE',
im_affluent VARCHAR2(50) DEFAULT 'NGE',
im_gdr VARCHAR2(50) DEFAULT 'NGE'
COMPRESS FOR OLTP
NOLOGGING
TABLESPACE tablespace_data1
PARTITION BY RANGE(im_dta_rif)
SUBPARTITION BY LIST(im_source_table)
SUBPARTITION TEMPLATE
SUBPARTITION sp_def VALUES (DEFAULT)
PARTITION p_2008y VALUES LESS THAN (TO_DATE('20090101', 'YYYYMMDD')),
PARTITION p_2009y VALUES LESS THAN (TO_DATE('20100101', 'YYYYMMDD')),
PARTITION p_2010s1 VALUES LESS THAN (TO_DATE('20100701', 'YYYYMMDD')),
PARTITION p_20100701 VALUES LESS THAN (TO_DATE('20100702', 'YYYYMMDD')),
PARTITION p_20100702 VALUES LESS THAN (TO_DATE('20100703', 'YYYYMMDD')),
PARTITION p_20100705 VALUES LESS THAN (TO_DATE('20100706', 'YYYYMMDD')),
PARTITION p_20100706 VALUES LESS THAN (TO_DATE('20100707', 'YYYYMMDD')),
PARTITION p_20100707 VALUES LESS THAN (TO_DATE('20100708', 'YYYYMMDD')),
PARTITION p_20100708 VALUES LESS THAN (TO_DATE('20100709', 'YYYYMMDD')),
PARTITION p_20100709 VALUES LESS THAN (TO_DATE('20100710', 'YYYYMMDD')),
PARTITION p_20100712 VALUES LESS THAN (TO_DATE('20100713', 'YYYYMMDD')),
PARTITION p_20100713 VALUES LESS THAN (TO_DATE('20100714', 'YYYYMMDD')),
PARTITION p_20100714 VALUES LESS THAN (TO_DATE('20100715', 'YYYYMMDD')),
PARTITION p_20100715 VALUES LESS THAN (TO_DATE('20100716', 'YYYYMMDD')),
PARTITION p_20100716 VALUES LESS THAN (TO_DATE('20100717', 'YYYYMMDD')),
PARTITION p_20100719 VALUES LESS THAN (TO_DATE('20100720', 'YYYYMMDD')),
PARTITION p_20100720 VALUES LESS THAN (TO_DATE('20100721', 'YYYYMMDD')),
PARTITION p_20100721 VALUES LESS THAN (TO_DATE('20100722', 'YYYYMMDD')),
PARTITION p_20100722 VALUES LESS THAN (TO_DATE('20100723', 'YYYYMMDD')),
PARTITION p_20100723 VALUES LESS THAN (TO_DATE('20100724', 'YYYYMMDD')),
PARTITION p_20100726 VALUES LESS THAN (TO_DATE('20100727', 'YYYYMMDD')),
PARTITION p_20100727 VALUES LESS THAN (TO_DATE('20100728', 'YYYYMMDD')),
PARTITION p_20100728 VALUES LESS THAN (TO_DATE('20100729', 'YYYYMMDD')),
PARTITION p_20100729 VALUES LESS THAN (TO_DATE('20100730', 'YYYYMMDD')),
PARTITION p_20100730 VALUES LESS THAN (TO_DATE('20100731', 'YYYYMMDD')),
PARTITION p_20100802 VALUES LESS THAN (TO_DATE('20100803', 'YYYYMMDD')),
PARTITION p_20100803 VALUES LESS THAN (TO_DATE('20100804', 'YYYYMMDD')),
PARTITION p_20100804 VALUES LESS THAN (TO_DATE('20100805', 'YYYYMMDD')),
PARTITION p_20100805 VALUES LESS THAN (TO_DATE('20100806', 'YYYYMMDD')),
PARTITION p_20100806 VALUES LESS THAN (TO_DATE('20100807', 'YYYYMMDD')),
PARTITION p_20100809 VALUES LESS THAN (TO_DATE('20100810', 'YYYYMMDD')),
PARTITION p_20100810 VALUES LESS THAN (TO_DATE('20100811', 'YYYYMMDD')),
PARTITION p_20100811 VALUES LESS THAN (TO_DATE('20100812', 'YYYYMMDD')),
PARTITION p_20100812 VALUES LESS THAN (TO_DATE('20100813', 'YYYYMMDD')),
PARTITION p_20100813 VALUES LESS THAN (TO_DATE('20100814', 'YYYYMMDD')),
PARTITION p_20100816 VALUES LESS THAN (TO_DATE('20100817', 'YYYYMMDD')),
PARTITION p_20100817 VALUES LESS THAN (TO_DATE('20100818', 'YYYYMMDD')),
PARTITION p_20100818 VALUES LESS THAN (TO_DATE('20100819', 'YYYYMMDD')),
PARTITION p_20100819 VALUES LESS THAN (TO_DATE('20100820', 'YYYYMMDD')),
PARTITION p_20100820 VALUES LESS THAN (TO_DATE('20100821', 'YYYYMMDD')),
PARTITION p_20100823 VALUES LESS THAN (TO_DATE('20100824', 'YYYYMMDD')),
PARTITION p_20100824 VALUES LESS THAN (TO_DATE('20100825', 'YYYYMMDD')),
PARTITION p_20100825 VALUES LESS THAN (TO_DATE('20100826', 'YYYYMMDD')),
PARTITION p_20100826 VALUES LESS THAN (TO_DATE('20100827', 'YYYYMMDD')),
PARTITION p_20100827 VALUES LESS THAN (TO_DATE('20100828', 'YYYYMMDD')),
PARTITION p_20100830 VALUES LESS THAN (TO_DATE('20100831', 'YYYYMMDD')),
PARTITION p_20100831 VALUES LESS THAN (TO_DATE('20100901', 'YYYYMMDD')),
PARTITION p_20100901 VALUES LESS THAN (TO_DATE('20100902', 'YYYYMMDD')),
PARTITION p_20100902 VALUES LESS THAN (TO_DATE('20100903', 'YYYYMMDD')),
PARTITION p_20100903 VALUES LESS THAN (TO_DATE('20100904', 'YYYYMMDD')),
PARTITION p_20100906 VALUES LESS THAN (TO_DATE('20100907', 'YYYYMMDD')),
PARTITION p_20100907 VALUES LESS THAN (TO_DATE('20100908', 'YYYYMMDD')),
PARTITION p_20100908 VALUES LESS THAN (TO_DATE('20100909', 'YYYYMMDD')),
PARTITION p_20100909 VALUES LESS THAN (TO_DATE('20100910', 'YYYYMMDD')),
PARTITION p_20100910 VALUES LESS THAN (TO_DATE('20100911', 'YYYYMMDD')),
PARTITION p_20100913 VALUES LESS THAN (TO_DATE('20100914', 'YYYYMMDD')),
PARTITION p_20100914 VALUES LESS THAN (TO_DATE('20100915', 'YYYYMMDD')),
PARTITION p_20100915 VALUES LESS THAN (TO_DATE('20100916', 'YYYYMMDD')),
PARTITION p_20100916 VALUES LESS THAN (TO_DATE('20100917', 'YYYYMMDD')),
PARTITION p_20100917 VALUES LESS THAN (TO_DATE('20100918', 'YYYYMMDD')),
PARTITION p_20100920 VALUES LESS THAN (TO_DATE('20100921', 'YYYYMMDD')),
PARTITION p_20100921 VALUES LESS THAN (TO_DATE('20100922', 'YYYYMMDD')),
PARTITION p_20100922 VALUES LESS THAN (TO_DATE('20100923', 'YYYYMMDD')),
PARTITION p_20100923 VALUES LESS THAN (TO_DATE('20100924', 'YYYYMMDD')),
PARTITION p_20100924 VALUES LESS THAN (TO_DATE('20100925', 'YYYYMMDD')),
PARTITION p_20100927 VALUES LESS THAN (TO_DATE('20100928', 'YYYYMMDD')),
PARTITION p_20100928 VALUES LESS THAN (TO_DATE('20100929', 'YYYYMMDD')),
PARTITION p_20100929 VALUES LESS THAN (TO_DATE('20100930', 'YYYYMMDD')),
PARTITION p_20100930 VALUES LESS THAN (TO_DATE('20101001', 'YYYYMMDD')),
PARTITION p_20101004 VALUES LESS THAN (TO_DATE('20101005', 'YYYYMMDD')),
PARTITION p_20101005 VALUES LESS THAN (TO_DATE('20101006', 'YYYYMMDD')),
PARTITION p_20101006 VALUES LESS THAN (TO_DATE('20101007', 'YYYYMMDD')),
PARTITION p_20101007 VALUES LESS THAN (TO_DATE('20101008', 'YYYYMMDD')),
PARTITION p_20101008 VALUES LESS THAN (TO_DATE('20101009', 'YYYYMMDD')),
PARTITION p_20101011 VALUES LESS THAN (TO_DATE('20101012', 'YYYYMMDD')),
PARTITION p_20101012 VALUES LESS THAN (TO_DATE('20101013', 'YYYYMMDD')),
PARTITION p_20101013 VALUES LESS THAN (TO_DATE('20101014', 'YYYYMMDD')),
PARTITION p_20101014 VALUES LESS THAN (TO_DATE('20101015', 'YYYYMMDD')),
PARTITION p_20101015 VALUES LESS THAN (TO_DATE('20101016', 'YYYYMMDD')),
PARTITION p_20101018 VALUES LESS THAN (TO_DATE('20101019', 'YYYYMMDD')),
PARTITION p_20101019 VALUES LESS THAN (TO_DATE('20101020', 'YYYYMMDD')),
PARTITION p_20101020 VALUES LESS THAN (TO_DATE('20101021', 'YYYYMMDD')),
PARTITION p_20101021 VALUES LESS THAN (TO_DATE('20101022', 'YYYYMMDD')),
PARTITION p_20101022 VALUES LESS THAN (TO_DATE('20101023', 'YYYYMMDD')),
PARTITION p_20101025 VALUES LESS THAN (TO_DATE('20101026', 'YYYYMMDD')),
PARTITION p_20101026 VALUES LESS THAN (TO_DATE('20101027', 'YYYYMMDD')),
PARTITION p_20101027 VALUES LESS THAN (TO_DATE('20101028', 'YYYYMMDD')),
PARTITION p_20101028 VALUES LESS THAN (TO_DATE('20101029', 'YYYYMMDD')),
PARTITION p_20101029 VALUES LESS THAN (TO_DATE('20101030', 'YYYYMMDD')),
PARTITION p_20101102 VALUES LESS THAN (TO_DATE('20101103', 'YYYYMMDD')),
PARTITION p_20101103 VALUES LESS THAN (TO_DATE('20101104', 'YYYYMMDD')),
PARTITION p_20101104 VALUES LESS THAN (TO_DATE('20101105', 'YYYYMMDD')),
PARTITION p_20101105 VALUES LESS THAN (TO_DATE('20101106', 'YYYYMMDD')),
PARTITION p_20101108 VALUES LESS THAN (TO_DATE('20101109', 'YYYYMMDD')),
PARTITION p_20101109 VALUES LESS THAN (TO_DATE('20101110', 'YYYYMMDD')),
PARTITION p_20101110 VALUES LESS THAN (TO_DATE('20101111', 'YYYYMMDD')),
PARTITION p_20101111 VALUES LESS THAN (TO_DATE('20101112', 'YYYYMMDD')),
PARTITION p_20101112 VALUES LESS THAN (TO_DATE('20101113', 'YYYYMMDD')),
PARTITION p_20101115 VALUES LESS THAN (TO_DATE('20101116', 'YYYYMMDD')),
PARTITION p_20101116 VALUES LESS THAN (TO_DATE('20101117', 'YYYYMMDD')),
PARTITION p_20101117 VALUES LESS THAN (TO_DATE('20101118', 'YYYYMMDD')),
PARTITION p_20101118 VALUES LESS THAN (TO_DATE('20101119', 'YYYYMMDD')),
PARTITION p_20101119 VALUES LESS THAN (TO_DATE('20101120', 'YYYYMMDD')),
PARTITION p_20101122 VALUES LESS THAN (TO_DATE('20101123', 'YYYYMMDD')),
PARTITION p_20101123 VALUES LESS THAN (TO_DATE('20101124', 'YYYYMMDD')),
PARTITION p_20101124 VALUES LESS THAN (TO_DATE('20101125', 'YYYYMMDD')),
PARTITION p_20101125 VALUES LESS THAN (TO_DATE('20101126', 'YYYYMMDD')),
PARTITION p_20101126 VALUES LESS THAN (TO_DATE('20101127', 'YYYYMMDD')),
PARTITION p_20101129 VALUES LESS THAN (TO_DATE('20101130', 'YYYYMMDD')),
PARTITION p_20101130 VALUES LESS THAN (TO_DATE('20101201', 'YYYYMMDD')),
PARTITION p_20101201 VALUES LESS THAN (TO_DATE('20101202', 'YYYYMMDD')),
PARTITION p_20101202 VALUES LESS THAN (TO_DATE('20101203', 'YYYYMMDD')),
PARTITION p_20101203 VALUES LESS THAN (TO_DATE('20101204', 'YYYYMMDD')),
PARTITION p_20101206 VALUES LESS THAN (TO_DATE('20101207', 'YYYYMMDD')),
PARTITION p_20101207 VALUES LESS THAN (TO_DATE('20101208', 'YYYYMMDD')),
PARTITION p_20101209 VALUES LESS THAN (TO_DATE('20101210', 'YYYYMMDD')),
PARTITION p_20101210 VALUES LESS THAN (TO_DATE('20101211', 'YYYYMMDD')),
PARTITION p_20101213 VALUES LESS THAN (TO_DATE('20101214', 'YYYYMMDD')),
PARTITION p_20101214 VALUES LESS THAN (TO_DATE('20101215', 'YYYYMMDD')),
PARTITION p_20101215 VALUES LESS THAN (TO_DATE('20101216', 'YYYYMMDD')),
PARTITION p_20101216 VALUES LESS THAN (TO_DATE('20101217', 'YYYYMMDD')),
PARTITION p_20101217 VALUES LESS THAN (TO_DATE('20101218', 'YYYYMMDD')),
PARTITION p_20101220 VALUES LESS THAN (TO_DATE('20101221', 'YYYYMMDD')),
PARTITION p_20101221 VALUES LESS THAN (TO_DATE('20101222', 'YYYYMMDD')),
PARTITION p_20101222 VALUES LESS THAN (TO_DATE('20101223', 'YYYYMMDD')),
PARTITION p_20101223 VALUES LESS THAN (TO_DATE('20101224', 'YYYYMMDD')),
PARTITION p_20101224 VALUES LESS THAN (TO_DATE('20101225', 'YYYYMMDD')),
PARTITION p_20101227 VALUES LESS THAN (TO_DATE('20101228', 'YYYYMMDD')),
PARTITION p_20101228 VALUES LESS THAN (TO_DATE('20101229', 'YYYYMMDD')),
PARTITION p_20101229 VALUES LESS THAN (TO_DATE('20101230', 'YYYYMMDD')),
PARTITION p_20101230 VALUES LESS THAN (TO_DATE('20101231', 'YYYYMMDD')),
PARTITION p_20101231 VALUES LESS THAN (TO_DATE('20110101', 'YYYYMMDD')),
PARTITION p_20110103 VALUES LESS THAN (TO_DATE('20110104', 'YYYYMMDD')),
PARTITION p_20110104 VALUES LESS THAN (TO_DATE('20110105', 'YYYYMMDD')),
PARTITION p_20110105 VALUES LESS THAN (TO_DATE('20110106', 'YYYYMMDD')),
PARTITION p_20110107 VALUES LESS THAN (TO_DATE('20110108', 'YYYYMMDD')),
PARTITION p_20110110 VALUES LESS THAN (TO_DATE('20110111', 'YYYYMMDD')),
PARTITION p_20110111 VALUES LESS THAN (TO_DATE('20110112', 'YYYYMMDD')),
PARTITION p_20110112 VALUES LESS THAN (TO_DATE('20110113', 'YYYYMMDD')),
PARTITION p_20110113 VALUES LESS THAN (TO_DATE('20110114', 'YYYYMMDD')),
PARTITION p_20110114 VALUES LESS THAN (TO_DATE('20110115', 'YYYYMMDD')),
PARTITION p_default VALUES LESS THAN (MAXVALUE)
PARALLEL
CREATE BITMAP INDEX dmc_bi_im_dip
ON big_table(im_cod_identifier4)
TABLESPACE tablespace_idx1
NOLOGGING
LOCAL
CREATE BITMAP INDEX dmc_bi_im_gdr
ON big_table(im_gdr)
TABLESPACE tablespace_idx1
NOLOGGING
LOCAL
CREATE BITMAP INDEX dmc_bi_im_gest_corp
ON big_table(im_gest_corp)
TABLESPACE tablespace_idx1
NOLOGGING
LOCAL
CREATE BITMAP INDEX dmc_bi_im_parl
ON big_table(im_parlatore_private)
TABLESPACE tablespace_idx1
NOLOGGING
LOCAL
CREATE BITMAP INDEX dmc_bi_im_prod
ON big_table(im_cod_prod)
TABLESPACE tablespace_idx1
NOLOGGING
LOCAL
CREATE BITMAP INDEX dmc_bi_im_promo
ON big_table(im_promotore)
TABLESPACE tablespace_idx1
NOLOGGING
LOCAL
CREATE BITMAP INDEX dmc_bi_im_utilcoge
ON big_table(im_column_to_be_updt)
TABLESPACE tablespace_idx1
NOLOGGING
LOCAL
DECLARE
v_ownname all_tables.owner%TYPE := 'schema1';
v_tabname all_tables.table_name%TYPE := 'big_table';
BEGIN
dbms_stats.set_table_prefs(v_ownname, v_tabname, 'GRANULARITY', 'AUTO');
dbms_stats.set_table_prefs(v_ownname, v_tabname, 'PUBLISH', 'TRUE');
dbms_stats.set_table_prefs(v_ownname, v_tabname, 'ESTIMATE_PERCENT', 'dbms_stats.auto_sample_size');
dbms_stats.set_table_prefs(v_ownname, v_tabname, 'INCREMENTAL', 'TRUE');
dbms_stats.set_table_prefs(v_ownname, v_tabname, 'NO_INVALIDATE', 'dbms_stats.auto_invalidate');
dbms_stats.set_table_prefs(v_ownname, v_tabname, 'CASCADE', 'TRUE');
dbms_stats.set_table_prefs(v_ownname, v_tabname, 'METHOD_OPT', 'FOR ALL COLUMNS SIZE AUTO');
END;
table_conto (8982009 records)
CREATE TABLE table_conto
(AC_DATA_RIF DATE,
AC_COD_BANCA VARCHAR2(5),
AC_COD_DIP VARCHAR2(10),
AC_CDR_CONTO VARCHAR2(10),
AC_DIP_RESP_CONTO VARCHAR2(10),
AC_ID_CONTO NUMBER(20,0),
AC_NUMERO_CONTO VARCHAR2(100),
AC_NUMERO_CARTA VARCHAR2(16),
ac_cod_identifier1 VARCHAR2(2),
ac_cod_identifier2 VARCHAR2(3),
ac_cod_identifier3 VARCHAR2(8),
ac_cod_identifier4 VARCHAR2(1),
AC_TIPO_CONTO_ID NUMBER,
AC_TIPO_CONTO_COD VARCHAR2(10),
AC_TIPO_CONTO_DSC VARCHAR2(250),
AC_CATEGORY_ID NUMBER,
AC_CATEGORY_COD VARCHAR2(50),
AC_CATEGORY_DSC VARCHAR2(250),
AC_NAT_CONTO_HOST VARCHAR2(10),
AC_CONTRAD_HOST VARCHAR2(50),
AC_GRUPPO_PATRIMONIALE VARCHAR2(50),
AC_PDC_DENOMINAZIONE VARCHAR2(250),
AC_DATA_APERTURA DATE,
AC_DIP_APERTURA VARCHAR2(100),
AC_DATA_CHIUSURA DATE,
AC_DIP_CHIUSURA VARCHAR2(100),
AC_STATO_CONTO_ID NUMBER,
AC_STATO_CONTO_COD VARCHAR2(10),
AC_STATO_CONTO_DSC VARCHAR2(250),
AC_MOTIVO_CHIUSURA_ID NUMBER,
AC_MOTIVO_CHIUSURA_COD VARCHAR2(10),
AC_MOTIVO_CHIUSURA_DSC VARCHAR2(250),
AC_CODICE_BLOCCO_ID NUMBER,
AC_CODICE_BLOCCO_COD VARCHAR2(10),
AC_COD_BLOCCO_DSC VARCHAR2(250),
AC_DATA_BLOCCO DATE,
CONSTRAINT DW_CONTO_IDCDT_PK_1001 PRIMARY KEY (AC_ID_CONTO, AC_DATA_RIF)
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS NOLOGGING
STORAGE(INITIAL 8388608 NEXT 8388608 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE table_space2_idx ENABLE )
SEGMENT CREATION IMMEDIATE
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
NOCOMPRESS NOLOGGING
STORAGE(INITIAL 8388608 NEXT 8388608 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE table_space2_data
PARALLELand table_services (6474561 records):
CREATE TABLE table_services
(CP_ID_SOTTOSCRIZIONE NUMBER(10,0),
CP_ID_CONTO NUMBER(10,0),
CP_ID_SERVIZIO NUMBER(10,0),
CP_NOME_SERVIZIO VARCHAR2(100),
CP_DATA_INIZIO_SOTTOSCR DATE,
CP_DATA_FINE_SOTTOSCR DATE,
CP_DATA_CREAZIONE_SOTTOSCR DATE,
CP_FLAG_CANCELLATA NUMBER(1,0),
CP_COD_BANCA VARCHAR2(5),
CP_DATA_RIF DATE,
CONSTRAINT DW_SERVIZIO_PK_1001 UNIQUE (CP_ID_SOTTOSCRIZIONE)
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS NOLOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE table_space1_idx ENABLE)
SEGMENT CREATION IMMEDIATE
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
NOCOMPRESS NOLOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE table_space1_data
PARALLELNow let me explain a little more in detail:
This procedure is for a bank (a Italian group of banks to be more accurate -> the name of the columns). I have the big_table where I have data about accounts clients: each client it's unique identified by the columns:
- im_cod_banca = the id of the bank inside the group
- im_cod_identifier1
- im_cod_identifier2
- im_cod_identifier3
- im_cod_identifier4
For all clients from the big_table whic respect the following 2 conditions:
1. im_column_to_be_updt = 'AAAA'
2. NVL(t.cp_flag_cancellata, 0) = 0
I have to update the column im_column_to_be_updt.
Using this unique identification I have to take from the table_conto the account_id (column ac_id_conto ) and, using this account_id I have to go into the table_services to take the service_cod and service_description (the columns CP_ID_SERVIZIO, respectively CP_NOME_SERVIZIO ).
Based on the value of CP_NOME_SERVIZIO I have to update that column into the big_table table.
Now, I use this statement to retrieve the values:
SELECT statement:
SELECT DISTINCT d.im_cod_banca,
d.im_cod_identifier1,
d.im_cod_identifier2,
d.im_cod_identifier3,
d.im_cod_identifier4,
c.ac_id_conto,
t.cp_id_servizio,
t.cp_nome_servizio,
t.cp_data_fine_sottoscr
FROM schema1.BIG_TABLE d,
schema2.TABLE_CONTO c,
schema2.TABLE_SERVICE t
WHERE d.im_cod_banca = c.ac_cod_banca
AND d.im_cod_identifier1 = c.ac_cod_identifier1
AND d.im_cod_identifier2 = c.ac_cod_identifier2
AND d.im_cod_identifier3 = c.ac_cod_identifier3
AND d.im_cod_identifier4 = c.ac_cod_identifier4
AND t.im_cod_banca = c.ac_cod_banca
AND t.cp_id_conto = c.ac_id_conto
AND ((t.cp_data_fine_sottoscr = (SELECT MAX(cp_data_fine_sottoscr)
FROM schema2.TABLE_SERVICE
WHERE cp_id_conto = c.ac_id_conto)) OR
(t.cp_data_fine_sottoscr IS NULL))
AND d. im_column_to_be_updt = 'AAAA'
AND NVL(t.cp_flag_cancellata, 0) = 0 An account may have more than one services attached in the table_services, therefore I have to take only the service with the column cp_data_fine_sottoscr null or cp_data_fine_sottoscr higher ( cp_data_fine_sottoscr is the date when the service was created).
The big_table is in the schema where I have some rights, but the other 2 table ( table_conto and table_services ) are in a different schema, where i have only SELECT. No DML, no privileges to modify the structure of the tables (index, partitions, ...).
My problem is: that SELECT takes a lot of time to be executed.
Any suggestions for improving that SELECT?
Edited by: Mihai_72 on Oct 17, 2012 9:42 PM
Edited by: Mihai_72 on Oct 18, 2012 9:39 AM
Edited by: Mihai_72 on Oct 18, 2012 2:16 PM
Finally I've managed to do something:
MERGE INTO (SELECT * FROM schema1.BIG_TABLE WHERE im_dta_rif >= to_date('20120101','yyyymmdd')) d
USING (SELECT data_rif, cod_banca, id1, id2, id3, id4, id_conto, id_servizio, nome_servizio, column_to_be_updt
FROM (SELECT DISTINCT d.im_dta_rif AS data_rif,
d.im_cod_banca AS cod_banca,
d.im_identifier1 AS id1,
d.im_identifier2 AS id2,
d.im_identifier3 AS id3,
d.im_identifier4 AS id4,
c.ac_id_conto AS id_conto,
t.cp_id_servizio AS id_servizio,
t.cp_nome_servizio AS nome_servizio,
DECODE(t.cp_nome_servizio, 'VAL1', 'XXXX1',
'VAL2', 'XXXX2',
'VAL3', 'XXXX3',
'YYYY') AS column_to_be_updt,
t.cp_data_fine_sottoscr AS data_fine,
RANK() OVER (PARTITION BY t.cp_id_conto ORDER BY t.cp_data_fine_sottoscr DESC NULLS FIRST) rn
FROM schema1.BIG_TABLE d,
schema2.TABLE_CONTO c,
schema2.TABLE_SERVICES t
WHERE d.im_cod_banca = c.ac_cod_banca
AND d.im_identifier1 = c.ac_identifier1
AND d.im_identifier2 = c.ac_identifier2
AND d.im_identifier3 = c.ac_identifier3
AND d.im_identifier4 = c.ac_identifier4
AND t.cp_cod_banca = c.ac_cod_banca
AND t.cp_id_conto = c.ac_id_conto
AND NVL(t.cp_flag_cancellata, 0) = 0
AND d.im_dta_rif >= to_date('20120101','yyyymmdd')
AND d.im_linea_coge = 'AAAA' )
WHERE rn = 1) b
ON (d.im_dta_rif = b.data_rif
AND d.im_cod_banca = b.cod_banca
AND d.im_identifier4 = b.id4
AND d.im_identifier1 = b.id1
AND d.im_identifier2 = b.id2
AND d.im_identifier3 = b.id3)
WHEN MATCHED THEN
UPDATE SET d.im_column_to_be_updt = b.column_to_be_updt,
d.id_conto = b.id_conto;Explain plan:
1 Plan hash value: 2232372467
2
3 --------------------------------------------------------------------------------------------------------------------------------------------------
4 | Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time | Pstart| Pstop |
5 --------------------------------------------------------------------------------------------------------------------------------------------------
6 | 0 | MERGE STATEMENT | | 437K| 49M| | 238K (2)| 00:00:10 | | |
7 | 1 | MERGE | BIG_TABLE | | | | | | | |
8 | 2 | VIEW | | | | | | | | |
9 |* 3 | HASH JOIN | | 437K| 97M| 26M| 238K (2)| 00:00:10 | | |
10 | 4 | PARTITION RANGE ITERATOR | | 246K| 23M| | 98073 (3)| 00:00:04 | 384 | 583 |
11 | 5 | PARTITION LIST SINGLE | | 246K| 23M| | 98073 (3)| 00:00:04 | 1 | 1 |
12 |* 6 | TABLE ACCESS STORAGE FULL | BIG_TABLE | 246K| 23M| | 98073 (3)| 00:00:04 | 384 | 583 |
13 |* 7 | VIEW | | 437K| 55M| | 135K (1)| 00:00:06 | | |
14 | 8 | SORT UNIQUE | | 437K| 39M| 47M| 135K (1)| 00:00:06 | | |
15 |* 9 | WINDOW SORT PUSHED RANK | | 437K| 39M| 47M| 135K (1)| 00:00:06 | | |
16 |* 10 | HASH JOIN | | 437K| 39M| | 117K (1)| 00:00:05 | | |
17 |* 11 | HASH JOIN | | 6325 | 376K| | 100K (1)| 00:00:04 | | |
18 | 12 | PARTITION RANGE ITERATOR | | 6325 | 228K| | 83821 (1)| 00:00:04 | 384 | 583 |
19 | 13 | PARTITION LIST SINGLE | | 6325 | 228K| | 83821 (1)| 00:00:04 | 1 | 1 |
20 |* 14 | TABLE ACCESS BY LOCAL INDEX ROWID| BIG_TABLE | 6325 | 228K| | 83821 (1)| 00:00:04 | 384 | 583 |
21 | 15 | BITMAP CONVERSION TO ROWIDS | | | | | | | | |
22 |* 16 | BITMAP INDEX SINGLE VALUE | DMC_BI_IM_UTILCOGE | | | | | | 384 | 583 |
23 |* 17 | INDEX STORAGE FAST FULL SCAN | DW_IDX_ACFW_AC_ABIL | 3709K| 84M| | 17133 (1)| 00:00:01 | | |
24 |* 18 | TABLE ACCESS STORAGE FULL | TABLE_SERVICES | 6138K| 193M| | 16102 (2)| 00:00:01 | | |
25 --------------------------------------------------------------------------------------------------------------------------------------------------
26
27 Predicate Information (identified by operation id):
28 ---------------------------------------------------
29
30 3 - access("BIG_TABLE"."IM_DTA_RIF"="DATA_RIF" AND "BIG_TABLE"."IM_COD_BANCA"="COD_BANCA" AND
31 "BIG_TABLE"."IM_COD_IDENTIFIER1"="ID1" AND "BIG_TABLE"."IM_COD_IDENTIFIER2"="ID2" AND "BIG_TABLE"."IM_COD_IDENTIFIER3"="ID3"
32 AND "BIG_TABLE"."IM_COD_IDENTIFIER4"="ID4")
33 6 - storage("IM_DTA_RIF">=TO_DATE(' 2012-01-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss'))
34 filter("IM_DTA_RIF">=TO_DATE(' 2012-01-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss'))
35 7 - filter("RN"=1 AND "DATA_RIF">=TO_DATE(' 2012-01-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss'))
36 9 - filter(RANK() OVER ( PARTITION BY "T"."CP_ID_CONTO" ORDER BY INTERNAL_FUNCTION("T"."CP_DATA_FINE_SOTTOSCR") DESC )<=1)
37 10 - access("T"."CP_COD_BANCA"="C"."AC_COD_BANCA" AND "T"."CP_ID_CONTO"="C"."AC_ID_CONTO")
38 11 - access("D"."IM_COD_BANCA"="C"."AC_COD_BANCA" AND "D"."IM_COD_IDENTIFIER2"="C"."AC_COD_IDENTIFIER2" AND
39 "D"."IM_COD_IDENTIFIER3"="C"."AC_COD_IDENTIFIER3" AND "D"."IM_COD_IDENTIFIER4"="C"."AC_COD_IDENTIFIER4" AND "D"."IM_COD_IDENTIFIER1"="C"."AC_COD_IDENTIFIER1")
40 14 - filter("D"."IM_DTA_RIF">=TO_DATE(' 2012-01-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss'))
41 16 - access("D"."IM_LINEA_COGE"='AAAA')
42 17 - storage("C"."AC_COD_IDENTIFIER3" IS NOT NULL AND "C"."AC_COD_IDENTIFIER4" IS NOT NULL AND "C"."AC_COD_IDENTIFIER1" IS NOT NULL AND
43 "C"."AC_COD_IDENTIFIER2" IS NOT NULL)
44 filter("C"."AC_COD_IDENTIFIER3" IS NOT NULL AND "C"."AC_COD_IDENTIFIER4" IS NOT NULL AND "C"."AC_COD_IDENTIFIER1" IS NOT NULL AND
45 "C"."AC_COD_IDENTIFIER2" IS NOT NULL)
46 18 - storage(NVL("T"."CP_FLAG_CANCELLATA",0)=0)
47 filter(NVL("T"."CP_FLAG_CANCELLATA",0)=0)
48
49 Note
50 -----
51 - dynamic sampling used for this statement (level=5)
52 - automatic DOP: Computed Degree of Parallelism is 1 because of parallel thresholdI don't have any other idea. I will see how will take the execution of this statement.
Similar Messages
-
Explain how to optimise time Process chain
Hello !
Can you explain me how to optimise the time in a process chain that i have to creat:
to load 5 ODS which take 10 minutes each one
and one ODS which takes 20 minutes.
i have to put them one after one ?
or to parallelize but how?
Thanks !Hi,
If your Data load are independent with each other you can schedule in Parallel and this will reduce your data load time with comparison to series load. When you are loading data in parallel, you have to keep your Background workprocess in mind. If you have three workprocess and four parallel data load in process chain, fourth will wait until it gets the free workprocess.
What he is telling is to split your info package based on selections to load less number of records, it ill speed up your loading time. For example inplace of loading the data for last five years in one package load five infopackages with one year selection.
I am not sure weather this will work in your case or not.
Regards,
Kams -
Itunes match how do you to select multiple songs or do you click each one
In ITunes match how do you to select multiple songs to download to pc or do you have to click each one.
First make sure you have the current version of iTunes, which is actually 10.5.1. I had to manually download it from apples website, for some reason, it wouldnt auto-update.
http://www.apple.com/itunes/download/
Once that is complete, go to the iTunes store. In the Quick Links secion to the right, you should see iTunes Match. This will prompt you to activate your subscription to iTunes match. After that it should ask you to add your computer and once youve done that, it should begin the process of scanning your library and adding it to the cloud
Alternatively, once you activate your subscription, you can also go to the Store dropdown menu in iTunes and select Turn On iTunes Match. -
How can I display selected tags across multiple e-mail addresses?
I receive email on a specific topic but via several e-mail addresses. How can I view selected tags where the resulting e-mails span several (7) email addresses. They are all active on my Thunderbird, but as far as I know, I can only display the selected tag on one of them at a time.
Any assistance greatly appreciated as this is a very big problem for me.
thanks, Ron75This solution does not appear to work across multiple e-mail addresses.
Perhaps I should have said "work across multiple e-mail address at the same time. I get e-mail on specific topics via several email addresses and wish to view all the tagged emails regardless of which email account in which they reside.
I could not get this solution to select more than one email account at a time. -
In BI how to filter the selection options based on inputs on top field
Hi Friends,
In BI, How to filter the selection options based on inputs on top field.
The system should automatically filter the lower level drop downs based on the selection of a higher level.
For e.g. :
If a user selects a Country then the States drop down should only display the State's belongs to the Country. Similarly when a State is selected, the District drop down should display only those District's belongs to the State.
Thanks in Advance.
Regards
Jayaram MHi Anil,
Thanks for reply but I couldn't use Compounding Characteristic here. Need some other solution.
Regards
Jayaram M -
How to use multi select in a query report
I defined a lov. This lov retuns name and a id. I want to use the result of this multi select in my query.
I always get invalid number when I choose two items of the select. When I debug I see that the return value of the multi select is 1:2. How can I change the seperator : in , I tried the following but this does't work.
if :P26_PRODUCTTYPE IS NOT NULL then
l_sql := l_sql ||' and producttype in
(REPLACE(:p26_producttype,'':'','','' ))';
end if;as you're finding, multiple values selected from html db multi-select list items (and checkboxes) are stored as a single, colon-delimited string. i explained an easy way to handle this via pl/sql in...
Multiple select list
...that post shows you how to throw the selected values into a pl/sql table and step through them as needed. it also showed how to use an instr to parse through the string if you want to go that route. you could use that same instr logic right in your sql query. so let's say your lov for your multi-select item (P1_MY_MULTISELECT, we'll call it) was defined as...
select ename, empno from emp order by 1
...and your user selected KING, FORD, and JONES. :P1_MY_MULTISELECT would store those values as...
7839:7902:7566
...you could then write a query to return the selected enames with something like...
select ename, job
from emp
where insrt (':'||:P1_MY_MULTISELECT||':',':'||empno||':') != 0
...hope this helps,
raj -
How to get the selected values from the shuttle
Hi
Please tell me how to get the selected option values from the shuttle leading list.
Thanksyou can also obtain the option values present in the leading and trailing lists using the
following methods:
public String[] getLeadingListOptionValues(OAPageContext pageContext, OAWebBean
webBean)
public String[] getTrailingListOptionValues(OAPageContext pageContext, OAWebBean
webBean)For example, the following code sample returns an array of values in the trailing list, ordered according to the
order in which they appear in the list:
String[] trailingItems =
shuttle.getTrailingListOptionValues(pageContext, shuttle);Thanks
--Anil -
How to get multiple selected fields in list
Hello all,
I am trying to get multiple selected value from a list but i dont know how to get multiple selected fields from a list though AS3.
Actually i want to pass the selected fields to php, so for that i need to get the selections and send to php.
Thankx..i want to put the selected fields of list in an array through AS3....
actually......i figured it out how to do that...........
Its simple......use
list.selectedItems[index]
and to get the number of items selected......
list.selectedItems.length
simple..... -
How to Retrieve the Selected Values from selectOrderShuttle using ADF 11g
Hi Every One,
Does anyone has idea how to retrieve the selected Items using shuttle and Order of the items using 'SelectOrderShuttle' component ?
Thanksshuttle's valuechangeevent would fire when you shuttle items back and forth.
public void selectOrderShuttle1_valueChangeListener(ValueChangeEvent valueChangeEvent) {
ArrayList list = new ArrayList(Arrays.asList(valueChangeEvent.getNewValue()));
if (list != null){
for (int i=0; i<list.size(); i++) {
int l = list.size()-1;
val = list.get(l).toString(); //returns , delimited string
if (val != null){
val = val.replaceAll("[\\[\\]]", "");
StringTokenizer st = new StringTokenizer (val, ",");
int nto = st.countTokens ();
for (int j = 0; j < nto; j++)
String token = st.nextToken ();
.......... -
How to execute a SELECT statement in java??
Hello !!
In my java program , i need to delete a record of number X, so
i accept the number X from the keyboard
Then before deleting it
i want the program to show me the name, age of the record which has the number X
How to do thishello kylas
actually i didnt get why this program example?? wats
its executing ??? Look at reply #3 in your other thread:
http://forum.java.sun.com/thread.jspa?threadID=713289&messageID=4126346
Notice the similarity? You've now asked "How to delete a record in Java" and "how to execute a select statement in java". You may have noticed that, aside from the SQL and the call to execute and executeUpdate (for delete) it's the same code. This is because you don't so much do these things in Java, you do them in SQL. The Java code simply asks the Driver to execute whatever SQL you write. So, I really hope your next post isn't "how do I execute an UPDATE statement in Java".
Good Luck
Lee -
How do I print selected pages from a multi page document
How do I print selected pages from a multi page document?
This question was solved.
View Solution.Hi,
It depends on the software you are using, what is it ? In general you can select a range or just a number of pages.
Regards
BH
**Click the KUDOS thumb up on the left to say 'Thanks'**
Make it easier for other people to find solutions by marking a Reply 'Accept as Solution' if it solves your problem. -
How to use multiple selection parameters in the data model
Hi, after have looked all the previous threads about how to use multiple selection parameters , I still have a problem;
I'm using Oracle BI Publisher 10.1.3.3.2 and I'm tried to define more than one multiple selection parameters inside the data template;
Inside a simple SQL queries they work perfectly....but inside the data template I have errors.
My data template is the following (it's very simple...I am just testing how the parameters work):
<dataTemplate name="Test" defaultPackage="bip_departments_2_parameters">
<parameters>
<parameter name="p_dep_2_param" include_in_output="false" datatype="character"/>
<parameter name="p_loc_1_param" include_in_output="false" datatype="character"/>
</parameters>
<dataTrigger name="beforeReport" source="bip_departments_2_parameters.beforeReportTrigger"/>
<dataQuery>
<sqlStatement name="Q2">
<![CDATA[
select deptno, dname,loc
from dept
&p_where_clause
]]>
</sqlStatement>
</dataQuery>
<dataStructure>
<group name="G_DEPT" source="Q2">
<element name="deptno" value="deptno"/>
<element name="dname" value="dname"/>
<element name="loc" value="loc"/>
</group>
</dataStructure>
</dataTemplate>
The 2 parameters are based on these LOV:
1) select distinct dname from dept (p_dep_2_param)
2) select distinct loc from dept (p_loc_1_param)
and both of them have checked the "Multiple selection" and "Can select all" boxes
The package I created, in order to use the lexical refence is:
CREATE OR REPLACE package SCOTT.bip_departments_2_parameters
as
p_dep_2_param varchar2(14);
p_loc_1_param varchar2(20);
p_where_clause varchar2(100);
function beforereporttrigger
return boolean;
end bip_departments_2_parameters;
CREATE OR REPLACE package body SCOTT.bip_departments_2_parameters
as
function beforereporttrigger
return boolean
is
l_return boolean := true;
begin
if (p_dep_2_param is not null) --and (p_loc_1_param is not null)
then
p_where_clause := 'where (dname in (' || replace (p_dep_1_param, '''') || ') and loc in (' || replace (p_loc_1_param, '''') || '))';
else
p_where_clause := 'where 1=1';
end if;
return (l_return);
end beforereporttrigger;
end bip_departments_2_parameters;
As you see, I tried to have only one p_where_clause (with more than one parameter inside)....but it doesn't work...
Using only the first parameter (based on deptno (which is number), the p_where_clause is: p_where_clause := 'where (deptno in (' || replace (p_dep_2_param, '''') || '))';
it works perfectly....
Now I don't know if the problem is the datatype, but I noticed that with a single parameter (deptno is number), the lexical refence (inside the data template) works.....with a varchar parameter it doesn't work....
So my questions are these:
1) how can I define the p_where_clause (inside the package) with a single varchar parameter (for example, the department location name)
2) how can I define the p_where_clause using more than one parameter (for example, the department location name and the department name) not number.
Thanks in advance for any suggestion
AlexAlex,
the missing thing in your example is the fact, that if only one value is selected, the parameter has exact this value like BOSTON. If you choose more than one value, the parameter includes the *'*, so that it looks like *'BOSTON','NEW YORK'*. So you need to check in the package, if there's a *,* in the parameter or not. If yes there's more than one value, if not it's only one value or it's null.
So change your package to (you need to expand your variables)
create or replace package bip_departments_2_parameters
as
p_dep_2_param varchar2(1000);
p_loc_1_param varchar2(1000);
p_where_clause varchar2(1000);
function beforereporttrigger
return boolean;
end bip_departments_2_parameters;
create or replace package body bip_departments_2_parameters
as
function beforereporttrigger
return boolean
is
l_return boolean := true;
begin
p_where_clause := ' ';
if p_dep_2_param is not null then
if instr(p_dep_2_param,',')>0 then
p_where_clause := 'WHERE DNAME in ('||p_dep_2_param||')';
else
p_where_clause := 'WHERE DNAME = '''||p_dep_2_param||'''';
end if;
if p_loc_1_param is not null then
if instr(p_loc_1_param,',')>0 then
p_where_clause := p_where_clause || ' AND LOC IN ('||p_loc_1_param||')';
else
p_where_clause := p_where_clause || ' AND LOC = '''||p_loc_1_param||'''';
end if;
end if;
else
if p_loc_1_param is not null then
if instr(p_loc_1_param,',')>0 then
p_where_clause := p_where_clause || 'WHERE LOC in ('||p_loc_1_param||')';
else
p_where_clause := p_where_clause || 'WHERE LOC = '''||p_loc_1_param||'''';
end if;
end if;
end if;
return (l_return);
end beforereporttrigger;
end bip_departments_2_parameters;
I've written a similar example at http://www.oracle.com/global/de/community/bip/tipps/Dynamische_Queries/index.html ... but it's in german.
Regards
Rainer -
How to use the select option to get the multiple bom explosion
hi friends,
i have completed the bom exp using parameters to get one material
input,but i need to adopt select option to give from and to materials
i ll gives from and to materials with description and bom deails
i here gave the coding also, pl give me a suggestion how to adpot the select
optoins instead of parameters ,very urgent
REPORT PP_BOM_EXPLOSION.
tables :mara,marc,stpo.
TYPE-POOLS : SLIS.
*parameters: p_werks like t001w-werks obligatory.
SELECT-OPTIONS : p_matnr FOR mara-matnr obligatory.
**select-options : p_matnr for mara-matnr obligatory.
PARAMETERS : P_WERKS LIKE T001W-WERKS OBLIGATORY,
P_MATNR LIKE MARA-MATNR OBLIGATORY.
*parameters: p_werks like marc-werks obligatory,
*p_matnr like marc-matnr obligatory.
constants c_x value 'X'.
data: begin of it_comp occurs 0,
matnr like mara-matnr,
maktl like makt-maktx,
idnrk like stpox-idnrk,
ojtxp like stpox-ojtxp,
menge like stpox-menge,
meins like stpox-meins,
matkl like stpox-matmk,
end of it_comp.
data : topmat like cstmat.
data: w_topmat like cstmat.
DATA : IT_MARA LIKE MARA OCCURS 0 WITH HEADER LINE.
DATA : IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
DATA : WA_FIELDCAT_LN LIKE LINE OF IT_FIELDCAT.
DATA : IT_EVENTCAT TYPE SLIS_T_EVENT.
DATA : WA_EVENTCAT_LN LIKE LINE OF IT_EVENTCAT.
DATA : IT_LAYOUT TYPE SLIS_LAYOUT_ALV.
DATA: S_COL_POS TYPE I.
start-of-selection.
perform explode_assembly.
PERFORM BUILD_FIELDCATALOG.
PERFORM DATA_DISPLAY.
*end-of-selection.
*perform write_report.
*top-of-page.
*perform print_header.
*form print_header.
*write: /(18) 'Component'(h00),
*(40) 'Description'(h01),
*'Mat.Group'(h02),
*(18) 'Quantity'(h03).
*uline.
*endform.
*form write_report.
*write: / w_topmat-matnr under text-h00 color col_heading,
*w_topmat-maktx under text-h01 color col_heading.
*loop at it_comp.
*write: /
*it_comp-idnrk under text-h00,
*it_comp-ojtxp under text-h01,
*it_comp-matkl under text-h02,
*it_comp-menge unit it_comp-meins under text-h03,
*it_comp-meins.
*endloop.
*uline.
*endform.
form explode_assembly.
data: it_stb like stpox occurs 0 with header line,
it_stb2 like stpox occurs 0 with header line,
it_stb3 like stpox occurs 0 with header line,
w_msg(255) type c.
SELECT MATNR FROM MARA INTO CORRESPONDING FIELDS OF TABLE IT_MARA
WHERE MATNR IN P_MATNR.
Explode highest level:
*LOOP AT IT_MARA.
call function 'CS_BOM_EXPL_MAT_V2'
exporting
auskz = c_x
capid = 'PP01'
cuols = c_x
datuv = sy-datum
knfba = c_x
ksbvo = c_x
mbwls = c_x
mdmps = c_x
BGIXO = c_x
MKMAT = c_x
MMAPS = c_x
FBSTP = c_x
FTREL = c_x
mtnrv = P_MATNR
werks = p_werks
importing
topmat = w_topmat
tables
stb = it_stb
exceptions
alt_not_found = 1
call_invalid = 2
material_not_found = 3
missing_authorization = 4
no_bom_found = 5
no_plant_data = 6
no_suitable_bom_found = 7
conversion_error = 8
others = 9.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
into w_msg.
*write: / w_msg.
exit.
endif.
Don't process documents
delete it_stb where idnrk is initial.
Don't process valid from furure:
delete it_stb where datuv >= sy-datum.
Explode phantom assemblies up to last level
*do.
it_stb2[] = it_stb[].
*delete it_stb2 where dumps is initial.
*if it_stb2[] is initial.
*exit.
*endif.
*delete it_stb where not dumps is initial.
delete it_stb where VPRSV <> 'S' OR MMSTA = '61'.
loop at it_stb2.
call function 'CS_BOM_EXPL_MAT_V2'
exporting
capid = 'PP01'
auskz = c_x
cuols = c_x
datuv = sy-datum
knfba = c_x
ksbvo = c_x
mbwls = c_x
mdmps = c_x
FBSTP = c_x
FTREL = c_x
mtnrv = it_stb2-idnrk
werks = p_werks
tables
stb = it_stb3
exceptions
alt_not_found = 1
call_invalid = 2
material_not_found = 3
missing_authorization = 4
no_bom_found = 5
no_plant_data = 6
no_suitable_bom_found = 7
conversion_error = 8
others = 9.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
into w_msg.
*write: / w_msg.
else.
delete it_stb3 where idnrk is initial.
delete it_Stb3 where sobsl = 50.
loop at it_stb3 .
multiply it_stb3-menge by it_stb2-menge.
modify it_stb3 transporting menge.
endloop.
append lines of it_stb3 to it_stb.
endif.
*ENDLOOP.
endloop.
*enddo.
Build table of components collecting the same components from
all levels
loop at it_stb.
it_comp-matkl = it_stb-matmk.
it_comp-idnrk = it_stb-idnrk.
it_comp-ojtxp = it_stb-ojtxp.
it_comp-menge = it_stb-menge.
CALL FUNCTION 'CONVERSION_EXIT_CUNIT_OUTPUT'
EXPORTING
INPUT = IT_STB-MEINS
LANGUAGE = SY-LANGU
IMPORTING
LONG_TEXT =
OUTPUT = IT_STB-MEINS
SHORT_TEXT =
EXCEPTIONS
UNIT_NOT_FOUND = 1
OTHERS = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
it_comp-meins = it_stb-meins.
collect it_comp.
clear it_comp.
endloop.
*READ TABLE IT_COMP INDEX 1.
*IF SY-SUBRC = 0.
IT_COMP-MATNR = w_topmat-matnr.
IT_COMP-MAKTL = w_topmat-maktx.
INSERT IT_COMP index 1.
*ENDIF.
ENDFORM.
FORM TO APPEND DATA INTO ALV FORM
FORM BUILD_FIELDCATALOG.
PERFORM BUILD_FIELDCAT USING 'MATKL' 'Component'.
PERFORM BUILD_FIELDCAT USING 'MATKL' 'Component'.
*loop at it_comp.
PERFORM BUILD_FIELDCAT USING 'MATNR' 'Material'.
PERFORM BUILD_FIELDCAT USING 'MAKTL' 'Material Description'.
PERFORM BUILD_FIELDCAT USING 'IDNRK' 'Component'.
PERFORM BUILD_FIELDCAT USING 'OJTXP' 'Description'.
PERFORM BUILD_FIELDCAT USING 'MATKL' 'Material Group'.
PERFORM BUILD_FIELDCAT USING 'MENGE' 'Quantity'.
PERFORM BUILD_FIELDCAT USING 'MEINS' 'Unit Of MEASUREMENT'.
*endloop.
ENDFORM.
FORM TO BUILD IN FIELD CATALOG FOR ALV FORM
FORM BUILD_FIELDCAT USING L_FIELDNAME LIKE DD03L-FIELDNAME S_TEXT LIKE DD03P-SCRTEXT_M.
CLEAR WA_FIELDCAT_LN.
ADD 1 TO S_COL_POS.
WA_FIELDCAT_LN-REF_TABNAME = 'IT_COMP'.
WA_FIELDCAT_LN-FIELDNAME = L_FIELDNAME.
WA_FIELDCAT_LN-SELTEXT_M = S_TEXT.
WA_FIELDCAT_LN-COL_POS = S_COL_POS.
WA_FIELDCAT_LN-QFIELDNAME = SPACE.
WA_FIELDCAT_LN-HOTSPOT = SPACE.
WA_FIELDCAT_LN-JUST = 'R'.
APPEND WA_FIELDCAT_LN TO IT_FIELDCAT.
ENDFORM.
FORM TO BUILD IN FIELD CATALOG FOR ALV FORM
FORM DATA_DISPLAY.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE = TEXT-001
I_GRID_SETTINGS =
IS_LAYOUT =
IT_FIELDCAT = IT_FIELDCAT
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = IT_COMP
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
endform.
Thanks in advance
Regards
senthilkumar Dtables :mara,marc,stpo.
parameters: p_werks like t001w-werks obligatory.
*p_matnr like mara-matnr obligatory.
*select-options : p_matnr for mara-matnr obligatory.
select-options : P_matnr for mara-matnr.
*parameters: p_werks like marc-werks obligatory,
*p_matnr like marc-matnr obligatory.
constants c_x value 'X'.
data: begin of it_comp occurs 0,
idnrk like stpox-idnrk,
ojtxp like stpox-ojtxp,
menge like stpox-menge,
meins like stpox-meins,
matkl like stpox-matmk,
end of it_comp.
data: w_topmat like cstmat.
data : begin of itab occurs 0,
matnr like mara-matnr,
end of itab.
*data : itab type table of mara with header line.
start-of-selection.
perform explode_assembly.
end-of-selection.
perform write_report.
top-of-page.
perform print_header.
form print_header.
write: /(18) 'Component'(h00),
(40) 'Description'(h01),
'Mat.Group'(h02),
(18) 'Quantity'(h03).
uline.
endform.
form write_report.
write: / w_topmat-matnr under text-h00 color col_heading,
w_topmat-maktx under text-h01 color col_heading.
loop at it_comp.
write: /
it_comp-idnrk under text-h00,
it_comp-ojtxp under text-h01,
it_comp-matkl under text-h02,
it_comp-menge unit it_comp-meins under text-h03,
it_comp-meins.
endloop.
uline.
endform.
form explode_assembly.
data: it_stb like stpox occurs 0 with header line,
it_stb2 like stpox occurs 0 with header line,
it_stb3 like stpox occurs 0 with header line,
w_msg(255) type c.
select matnr from mara into table itab where matnr between p_matnr-low and p_matnr-high.
loop at p_matnr.
itab-matnr = p_matnr-low.
append itab.
itab-matnr = p_matnr-high.
append itab.
clear itab.
endloop.
Explode highest level:
loop at itab.
call function 'CS_BOM_EXPL_MAT_V2'
exporting
auskz = c_x
capid = 'PP01'
cuols = c_x
datuv = sy-datum
knfba = c_x
ksbvo = c_x
mbwls = c_x
mdmps = c_x
BGIXO = c_x
MKMAT = c_x
MMAPS = c_x
FBSTP = c_x
FTREL = c_x
mtnrv = itab-matnr
werks = p_werks
importing
topmat = w_topmat
tables
stb = it_stb
exceptions
alt_not_found = 1
call_invalid = 2
material_not_found = 3
missing_authorization = 4
no_bom_found = 5
no_plant_data = 6
no_suitable_bom_found = 7
conversion_error = 8
others = 9.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
into w_msg.
write: / w_msg.
exit.
*else.
endif.
loop at it_stb.
it_comp-matkl = it_stb-matmk.
it_comp-idnrk = it_stb-idnrk.
it_comp-ojtxp = it_stb-ojtxp.
it_comp-menge = it_stb-menge.
it_comp-meins = it_stb-meins.
collect it_comp.
clear it_comp.
endloop.
endloop.
endform.
i got the low and high from selectoption and then move it into itab.
then i pass itab-matnr into fm. using loop.
but i got only one output
but ineet to got from and to output.
give me a solution
Regards
ds -
How to move a selection into another selection in elements 12
how to move a selection into another selection in elements 12
Open picture B, the one you wish to select something from to add to another picture.
Use one of the selection tools, e.g. selection brush, lasso tool, to select the object. You will see an outline ("marching ants") once the selection is complete
Go to Edit menu>copy to copy the selection to the clipboard
Open picture A, then go to Edit>paste
Use the move tool to position object from picture B.
In the layers palette you should see picture A as the background layer, and object B on a separate layer -
How to use direct select and insert or load to speedup the process instead of cursur
Hi friends,
I have stored procedure .In SP i am using cursur to load data from Parent to several child table.
I have attached the script with this message.
And my problem is how to use direct select and insert or load to speedup the process instead of cursur.
Can any one please suggest me how to change this scripts pls.
USE [IconicMarketing]
GO
/****** Object: StoredProcedure [dbo].[SP_DMS_INVENTORY] Script Date: 3/6/2015 3:34:03 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <ARUN,NAGARAJ>
-- Create date: <11/21/2014>
-- Description: <STORED PROCEDURE FOR DMS_INVENTORY>
-- =============================================
ALTER PROCEDURE [dbo].[SP_DMS_INVENTORY]
@Specific_Date varchar(20) ,
@DealerNum Varchar(6),
@Date_Daily varchar(50)
AS
BEGIN
SET NOCOUNT ON;
--==========================================================================
-- INVENTORY_CURSUR
--==========================================================================
DECLARE
@FileType varchar(50),
@ACDealerID varchar(50),
@ClientDealerID varchar(50),
@DMSType varchar(50),
@StockNumber varchar(50),
@InventoryDate datetime ,
@StockType varchar(100),
@DMSStatus varchar(50),
@InvoicePrice numeric(18, 2),
@CostPack varchar(50),
@SalesCost numeric(18, 2),
@HoldbackAmount numeric(18, 2),
@ListPrice numeric(18, 2),
@MSRP varchar(max),
@LotLocation varchar(50),
@TagLine varchar(max),
@Certification varchar(max),
@CertificationNumber varchar(max),
@VehicleVIN varchar(50),
@VehicleYear bigint ,
@VehicleMake varchar(50),
@VehicleModel varchar(50),
@VehicleModelCode varchar(50),
@VehicleTrim varchar(50),
@VehicleSubTrimLevel varchar(max),
@Classification varchar(max),
@TypeCode varchar(100),
@VehicleMileage bigint ,
@EngineCylinderCount varchar(10) ,
@TransmissionType varchar(50),
@VehicleExteriorColor varchar(50),
@VehicleInteriorColor varchar(50),
@CreatedDate datetime ,
@LastModifiedDate datetime ,
@ModifiedFlag varchar(max),
@InteriorColorCode varchar(50),
@ExteriorColorCode varchar(50),
@PackageCode varchar(50),
@CodedCost varchar(50),
@Air varchar(100),
@OrderType varchar(max),
@AgeDays bigint ,
@OutstandingRO varchar(50),
@DlrAccessoryRetail varchar(50),
@DlrAccessoryCost varchar(max),
@DlrAccessoryDesc varchar(max),
@ModelDesc varchar(50),
@Memo1 varchar(1000),
@Memo2 varchar(max),
@Weight varchar(max),
@FloorPlan numeric(18, 2),
@Purchaser varchar(max),
@PurchasedFrom varchar(max),
@InternetPrice varchar(50),
@InventoryAcctDollar numeric(18, 2),
@VehicleType varchar(50),
@DealerAccessoryCode varchar(50),
@AllInventoryAcctDollar numeric(18, 2),
@BestPrice varchar(50),
@InStock bigint ,
@AccountingMake varchar(50),
@GasDiesel varchar(max),
@BookValue varchar(10),
@FactoryAccessoryDescription varchar(max),
@TotalReturn varchar(10),
@TotalCost varchar(10),
@SS varchar(max),
@VehicleBody varchar(max),
@StandardEquipment varchar(max),
@Account varchar(max),
@CalculatedPrice varchar(10),
@OriginalCost varchar(10),
@AccessoryCore varchar(10),
@OtherDollar varchar(10),
@PrimaryBookValue varchar(10),
@AmountDue varchar(10),
@LicenseFee varchar(10),
@ICompany varchar(max),
@InvenAcct varchar(max),
@Field23 varchar(max),
@Field24 varchar(max),
@SalesCode bigint,
@BaseRetail varchar(10),
@BaseInvAmt varchar(10),
@CommPrice varchar(10),
@Price1 varchar(10),
@Price2 varchar(10),
@StickerPrice varchar(10),
@TotInvAmt varchar(10),
@OptRetail varchar(max),
@OptInvAmt varchar(10),
@OptCost varchar(10),
@Options1 varchar(max),
@Category varchar(max),
@Description varchar(max),
@Engine varchar(max),
@ModelType varchar(max),
@FTCode varchar(max),
@Wholesale varchar(max),
@Retail varchar(max),
@Draft varchar(max),
@myerror varchar(500),
@Inventoryid int,
@errornumber int,
@errorseverity varchar(500),
@errortable varchar(50),
@errorstate int,
@errorprocedure varchar(500),
@errorline varchar(50),
@errormessage varchar(1000),
@Invt_Id int,
@flatfile_createddate datetime,
@FtpDate date,
@Inv_cur varchar(1000),
@S_Year varchar(4),
@S_Month varchar(2),
@S_Date varchar(2),
@Date_Specfic varchar(50),
@Param_list nvarchar(max),
@Daily_Date Varchar(50);
--====================================================================================
--DECLARE CURSUR FOR SPECIFIC DATE (OR) DEALER-ID WITH SPECIFIC DATE (OR) CURRENT DATE
--====================================================================================
set @Date_Specfic = Substring(@Specific_Date,1,4) +'-'+Substring(@Specific_Date,5,2)+'-'+Substring(@Specific_Date,7,2);
set @Daily_Date = SUBSTRING(@Date_Daily,14,4) + '-' + SUBSTRING(@Date_Daily,18,2)+ '-' + SUBSTRING(@date_Daily,20,2)
IF @Daily_Date IS NOT NULL
BEGIN
Delete From [dbo].[DMS_INVENTORY_DETAILS]
Where DMSInventoryID in(select ID from [dbo].[DMS_INVENTORY] where CONVERT (date,FtpDate)=CONVERT (date,GETDATE()));
Delete From [dbo].[DMS_INVENTORY_AMOUNT]
Where DMSInventoryID in(select ID from [dbo].[DMS_INVENTORY] where CONVERT (date,FtpDate)=CONVERT (date,GETDATE()));
Delete From [dbo].[ICONIC_INVENTORY_VEHICLE]
Where DMSInventoryVehicleID in(select ID from [dbo].[DMS_INVENTORY] where CONVERT (date,FtpDate)=CONVERT (date,GETDATE()));
Delete From [dbo].[DMS_INVENTORY_VEHICLE]
Where DMSInventoryID in(select ID from [dbo].[DMS_INVENTORY] where CONVERT (date,FtpDate)=CONVERT (date,GETDATE()));
Delete From [dbo].[ICONIC_EQUITY_INVENTORY_COMPARE]
Where InventoryVehicleId in(select ID from [dbo].[DMS_INVENTORY] where CONVERT (date,FtpDate)=CONVERT (date,GETDATE()));
Delete From [dbo].[DMS_INVENTORY]
Where ID in(select ID from [dbo].[DMS_INVENTORY] where CONVERT (date,FtpDate)=CONVERT (date,GETDATE()));
DECLARE Inventory_Cursor CURSOR FOR
SELECT * from [dbo].[FLATFILE_INVENTORY] where
CONVERT (date,flatfile_createddate) = CONVERT (date,GETDATE()) order by flatfile_createddate;
END
Else
BEGIN
if (@Date_Specfic IS NOT NULL AND @DealerNum != '?????')
BEGIN
Delete From [dbo].[DMS_INVENTORY_DETAILS]
Where DMSInventoryID in(select ID from [dbo].[DMS_INVENTORY] where FtpDate=@Date_Specfic AND DMSDealerID='ACTEST' + @DealerNum);
Delete From [dbo].[DMS_INVENTORY_AMOUNT]
Where DMSInventoryID in(select ID from [dbo].[DMS_INVENTORY] where FtpDate=@Date_Specfic AND DMSDealerID='ACTEST' + @DealerNum);
Delete From [dbo].[ICONIC_INVENTORY_VEHICLE]
Where DMSInventoryVehicleID in(select ID from [dbo].[DMS_INVENTORY] where FtpDate=@Date_Specfic AND DMSDealerID='ACTEST' + @DealerNum);
Delete From [dbo].[DMS_INVENTORY_VEHICLE]
Where DMSInventoryID in(select ID from [dbo].[DMS_INVENTORY] where FtpDate=@Date_Specfic AND DMSDealerID='ACTEST' + @DealerNum);
Delete From [dbo].[ICONIC_EQUITY_INVENTORY_COMPARE]
Where InventoryVehicleId in(select ID from [dbo].[DMS_INVENTORY] where FtpDate=@Date_Specfic AND DMSDealerID='ACTEST' + @DealerNum);
Delete From [dbo].[DMS_INVENTORY]
Where ID in(select ID from [dbo].[DMS_INVENTORY] where FtpDate=@Date_Specfic AND DMSDealerID='ACTEST' + @DealerNum);
DECLARE Inventory_Cursor CURSOR FOR
SELECT * from [dbo].[FLATFILE_INVENTORY] where FtpDate=@Date_Specfic AND ACDealerID='ACTEST' + @DealerNum;
END
ELSE
BEGIN
Delete From [dbo].[DMS_INVENTORY_DETAILS]
Where DMSInventoryID in(select ID from [dbo].[DMS_INVENTORY] where FtpDate=@Date_Specfic);
Delete From [dbo].[DMS_INVENTORY_AMOUNT]
Where DMSInventoryID in(select ID from [dbo].[DMS_INVENTORY] where FtpDate=@Date_Specfic);
Delete From [dbo].[ICONIC_INVENTORY_VEHICLE]
Where DMSInventoryVehicleID in(select ID from [dbo].[DMS_INVENTORY] where FtpDate=@Date_Specfic);
Delete From [dbo].[DMS_INVENTORY_VEHICLE]
Where DMSInventoryID in(select ID from [dbo].[DMS_INVENTORY] where FtpDate=@Date_Specfic);
Delete From [dbo].[ICONIC_EQUITY_INVENTORY_COMPARE]
Where InventoryVehicleId in(select ID from [dbo].[DMS_INVENTORY] where FtpDate=@Date_Specfic);
Delete From [dbo].[DMS_INVENTORY]
Where ID in(select ID from [dbo].[DMS_INVENTORY] where FtpDate=@Date_Specfic);
DECLARE Inventory_Cursor CURSOR FOR
SELECT * from [dbo].[FLATFILE_INVENTORY] where FtpDate=@Date_Specfic;
END
END
OPEN Inventory_Cursor
FETCH NEXT FROM Inventory_Cursor
INTO
@FileType ,
@ACDealerID ,
@ClientDealerID ,
@DMSType ,
@StockNumber ,
@InventoryDate ,
@StockType ,
@DMSStatus ,
@InvoicePrice ,
@CostPack ,
@SalesCost ,
@HoldbackAmount ,
@ListPrice ,
@MSRP ,
@LotLocation ,
@TagLine ,
@Certification ,
@CertificationNumber ,
@VehicleVIN ,
@VehicleYear ,
@VehicleMake ,
@VehicleModel ,
@VehicleModelCode ,
@VehicleTrim ,
@VehicleSubTrimLevel ,
@Classification ,
@TypeCode ,
@VehicleMileage ,
@EngineCylinderCount ,
@TransmissionType ,
@VehicleExteriorColor ,
@VehicleInteriorColor ,
@CreatedDate ,
@LastModifiedDate ,
@ModifiedFlag ,
@InteriorColorCode ,
@ExteriorColorCode ,
@PackageCode ,
@CodedCost ,
@Air ,
@OrderType ,
@AgeDays ,
@OutstandingRO ,
@DlrAccessoryRetail ,
@DlrAccessoryCost ,
@DlrAccessoryDesc ,
@ModelDesc ,
@Memo1 ,
@Memo2 ,
@Weight ,
@FloorPlan ,
@Purchaser ,
@PurchasedFrom ,
@InternetPrice ,
@InventoryAcctDollar ,
@VehicleType ,
@DealerAccessoryCode ,
@AllInventoryAcctDollar ,
@BestPrice ,
@InStock ,
@AccountingMake ,
@GasDiesel ,
@BookValue ,
@FactoryAccessoryDescription ,
@TotalReturn ,
@TotalCost ,
@SS ,
@VehicleBody ,
@StandardEquipment ,
@Account ,
@CalculatedPrice ,
@OriginalCost ,
@AccessoryCore ,
@OtherDollar ,
@PrimaryBookValue ,
@AmountDue ,
@LicenseFee ,
@ICompany ,
@InvenAcct ,
@Field23 ,
@Field24 ,
@SalesCode ,
@BaseRetail ,
@BaseInvAmt ,
@CommPrice ,
@Price1 ,
@Price2 ,
@StickerPrice ,
@TotInvAmt ,
@OptRetail ,
@OptInvAmt ,
@OptCost ,
@Options1 ,
@Category ,
@Description ,
@Engine ,
@ModelType ,
@FTCode ,
@Wholesale ,
@Retail ,
@Draft ,
@flatfile_createddate,
@FtpDate;
WHILE @@FETCH_STATUS = 0
BEGIN
--==========================================================================
-- INSERT INTO INVENTORY (PARENT TABLE)
--==========================================================================
BEGIN TRY
INSERT INTO [dbo].[DMS_INVENTORY]
DMSDealerID,
StockNumber,
DMSType,
InventoryDate,
FtpDate
VALUES (@ClientDealerID,@StockNumber,@DMSType,@InventoryDate,@FtpDate);
END TRY
BEGIN CATCH
SELECT
@errornumber = ERROR_NUMBER(),
@errorseverity = ERROR_SEVERITY(),
@errortable = 'DMS_INVENTORY',
@errorstate = ERROR_STATE(),
@errorprocedure = ERROR_PROCEDURE(),
@errorline = ERROR_LINE(),
@errormessage = ERROR_MESSAGE();
--==========================================================================
-- INSERT ERRORS INTO DMSLOG_INVENTORY_ERROR
--==========================================================================
EXEC [SP_DMS_INVENTORY_ERROR] @FileType,@ACDealerID,@ClientDealerID,@DMSType,@StockNumber,@InventoryDate,@StockType,@DMSStatus,@InvoicePrice,@CostPack,
@SalesCost,@HoldbackAmount,@ListPrice,@MSRP,@LotLocation,@TagLine,@Certification,@CertificationNumber,@VehicleVIN,@VehicleYear,@VehicleMake,@VehicleModel,@VehicleModelCode,
@VehicleTrim,@VehicleSubTrimLevel,@Classification,@TypeCode,@VehicleMileage,@EngineCylinderCount,@TransmissionType,@VehicleExteriorColor,@VehicleInteriorColor,
@CreatedDate,@LastModifiedDate,@ModifiedFlag,@InteriorColorCode,@ExteriorColorCode,@PackageCode,@CodedCost,@Air,@OrderType,@AgeDays,@OutstandingRO,
@DlrAccessoryRetail,@DlrAccessoryCost,@DlrAccessoryDesc,@ModelDesc,@Memo1,@Memo2,@Weight,@FloorPlan,@Purchaser,@PurchasedFrom,@InternetPrice,
@InventoryAcctDollar,@VehicleType,@DealerAccessoryCode,@AllInventoryAcctDollar,@BestPrice,@InStock,@AccountingMake,@GasDiesel,@BookValue,
@FactoryAccessoryDescription,@TotalReturn,@TotalCost,@SS,@VehicleBody,@StandardEquipment,@Account,@CalculatedPrice,@OriginalCost,@AccessoryCore,
@OtherDollar,@PrimaryBookValue,@AmountDue,@LicenseFee,@ICompany,@InvenAcct,@Field23,@Field24,@SalesCode,@BaseRetail,@BaseInvAmt,@CommPrice,@Price1,
@Price2,@StickerPrice,@TotInvAmt,@OptRetail,@OptInvAmt,@OptCost,@Options1,@Category,@Description,@Engine,@ModelType,@FTCode,@Wholesale,@Retail,@Draft,
@ERRORNUMBER,@ERRORSEVERITY,@ERRORTABLE,@ERRORSTATE,@ERRORPROCEDURE,@ERRORLINE,@errormessage,@FtpDate
END CATCH
-- PRINT @errornumber;
-- PRINT @errorseverity;
-- PRINT @errortable;
-- PRINT @errorprocedure;
-- PRINT @errorline;
-- PRINT @errormessage;
-- PRINT @errorstate;
set @myerror = @@ERROR;
-- This -- PRINT statement -- PRINTs 'Error = 0' because
-- @@ERROR is reset in the IF statement above.
-- PRINT N'Error = ' + @myerror;
set @Inventoryid = scope_identity();
-- PRINT @Inventoryid;
--==========================================================================
-- INSERT INTO DMS_INVENTORY_DETAILS (CHILD TABLE)
--==========================================================================
BEGIN TRY
INSERT INTO [dbo].[DMS_INVENTORY_DETAILS]
DMSInventoryID,
StockType,
DMSStatus,
LotLocation,
TagLine,
Certification,
CertificationNumber,
CreatedDate,
LastModifiedDate,
ModifiedFlag,
PackageCode,
OrderType,
AgeDays,
OutstandingRO,
Memo1,
Memo2,
Purchaser,
PurchasedFrom,
DealerAccessoryCode,
InStock,
AccountingMake,
SS,
Account,
AccessoryCore,
ICompany,
InvenAcct,
Field23,
Field24,
SalesCode,
Draft,
FTCode,
FtpDate
VALUES (
@InventoryID,
@StockType,
@DMSStatus,
@LotLocation,
@TagLine,
@Certification,
@CertificationNumber,
@CreatedDate,
@LastModifiedDate,
@ModifiedFlag,
@PackageCode,
@OrderType,
@AgeDays,
@OutstandingRO,
@Memo1,
@Memo2,
@Purchaser,
@PurchasedFrom,
@DealerAccessoryCode,
@InStock,
@AccountingMake,
@SS,
@Account,
@AccessoryCore,
@ICompany,
@InvenAcct,
@Field23,
@Field24,
@SalesCode,
@Draft,
@FTCode,
@FtpDate
END TRY
BEGIN CATCH
SELECT
@errornumber = ERROR_NUMBER(),
@errorseverity = ERROR_SEVERITY(),
@errorstate = ERROR_STATE(),
@errortable = 'DMS_INVENTORY_DETAILS',
@errorprocedure = ERROR_PROCEDURE(),
@errorline = ERROR_LINE(),
@errormessage = ERROR_MESSAGE();
--==========================================================================
-- INSERT ERRORS INTO DMSLOG_INVENTORY_ERROR
--==========================================================================
EXECUTE [SP_DMS_INVENTORY_ERROR] @FileType,@ACDealerID,@ClientDealerID,@DMSType,@StockNumber,@InventoryDate,@StockType,@DMSStatus,@InvoicePrice,@CostPack,
@SalesCost,@HoldbackAmount,@ListPrice,@MSRP,@LotLocation,@TagLine,@Certification,@CertificationNumber,@VehicleVIN,@VehicleYear,@VehicleMake,@VehicleModel,@VehicleModelCode,
@VehicleTrim,@VehicleSubTrimLevel,@Classification,@TypeCode,@VehicleMileage,@EngineCylinderCount,@TransmissionType,@VehicleExteriorColor,@VehicleInteriorColor,
@CreatedDate,@LastModifiedDate,@ModifiedFlag,@InteriorColorCode,@ExteriorColorCode,@PackageCode,@CodedCost,@Air,@OrderType,@AgeDays,@OutstandingRO,
@DlrAccessoryRetail,@DlrAccessoryCost,@DlrAccessoryDesc,@ModelDesc,@Memo1,@Memo2,@Weight,@FloorPlan,@Purchaser,@PurchasedFrom,@InternetPrice,
@InventoryAcctDollar,@VehicleType,@DealerAccessoryCode,@AllInventoryAcctDollar,@BestPrice,@InStock,@AccountingMake,@GasDiesel,@BookValue,
@FactoryAccessoryDescription,@TotalReturn,@TotalCost,@SS,@VehicleBody,@StandardEquipment,@Account,@CalculatedPrice,@OriginalCost,@AccessoryCore,
@OtherDollar,@PrimaryBookValue,@AmountDue,@LicenseFee,@ICompany,@InvenAcct,@Field23,@Field24,@SalesCode,@BaseRetail,@BaseInvAmt,@CommPrice,@Price1,
@Price2,@StickerPrice,@TotInvAmt,@OptRetail,@OptInvAmt,@OptCost,@Options1,@Category,@Description,@Engine,@ModelType,@FTCode,@Wholesale,@Retail,@Draft,
@ERRORNUMBER,@ERRORSEVERITY,@ERRORTABLE,@ERRORSTATE,@ERRORPROCEDURE,@ERRORLINE,@errormessage,@FtpDate
END CATCH
--==========================================================================
-- INSERT INTO DMS_INVENTORY_AMOUNT (CHILD TABLE)
--==========================================================================
BEGIN TRY
INSERT INTO [dbo].[DMS_INVENTORY_AMOUNT]
DMSInventoryID,
AllInventoryAcctDollar,
OtherDollar,
PrimaryBookValue,
AmountDue,
LicenseFee,
CalculatedPrice,
OriginalCost,
BookValue,
TotalReturn,
TotalCost,
DlrAccessoryRetail,
DlrAccessoryCost,
DlrAccessoryDesc,
InternetPrice,
InventoryAcctDollar,
BestPrice,
Weight,
FloorPlan,
CodedCost,
InvoicePrice,
CostPack,
SalesCost,
HoldbackAmount,
ListPrice,
MSRP,
BaseRetail,
BaseInvAmt,
CommPrice,
Price1,
Price2,
StickerPrice,
TotInvAmt,
OptRetail,
OptInvAmt,
OptCost,
Wholesale,
Retail,
FtpDate
VALUES (
@InventoryID,
@AllInventoryAcctDollar,
@OtherDollar,
@PrimaryBookValue,
@AmountDue,
@LicenseFee,
@CalculatedPrice,
@OriginalCost,
@BookValue,
@TotalReturn,
@TotalCost,
@DlrAccessoryRetail,
@DlrAccessoryCost,
@DlrAccessoryDesc,
@InternetPrice,
@InventoryAcctDollar,
@BestPrice,
@Weight,
@FloorPlan,
@CodedCost,
@InvoicePrice,
@CostPack,
@SalesCost,
@HoldbackAmount,
@ListPrice,
@MSRP,
@BaseRetail,
@BaseInvAmt,
@CommPrice,
@Price1,
@Price2,
@StickerPrice,
@TotInvAmt,
@OptRetail,
@OptInvAmt,
@OptCost,
@Wholesale,
@Retail,
@FtpDate
END TRY
BEGIN CATCH
SELECT
@errornumber = ERROR_NUMBER(),
@errorseverity = ERROR_SEVERITY(),
@errortable = 'DMS_INVENTORY_AMOUNT',
@errorstate = ERROR_STATE(),
@errorprocedure = ERROR_PROCEDURE(),
@errorline = ERROR_LINE(),
@errormessage = ERROR_MESSAGE();
--==========================================================================
-- INSERT ERRORS INTO DMSLOG_INVENTORY_ERROR
--==========================================================================
EXEC [SP_DMS_INVENTORY_ERROR] @FileType,@ACDealerID,@ClientDealerID,@DMSType,@StockNumber,@InventoryDate,@StockType,@DMSStatus,@InvoicePrice,@CostPack,
@SalesCost,@HoldbackAmount,@ListPrice,@MSRP,@LotLocation,@TagLine,@Certification,@CertificationNumber,@VehicleVIN,@VehicleYear,@VehicleMake,@VehicleModel,@VehicleModelCode,
@VehicleTrim,@VehicleSubTrimLevel,@Classification,@TypeCode,@VehicleMileage,@EngineCylinderCount,@TransmissionType,@VehicleExteriorColor,@VehicleInteriorColor,
@CreatedDate,@LastModifiedDate,@ModifiedFlag,@InteriorColorCode,@ExteriorColorCode,@PackageCode,@CodedCost,@Air,@OrderType,@AgeDays,@OutstandingRO,
@DlrAccessoryRetail,@DlrAccessoryCost,@DlrAccessoryDesc,@ModelDesc,@Memo1,@Memo2,@Weight,@FloorPlan,@Purchaser,@PurchasedFrom,@InternetPrice,
@InventoryAcctDollar,@VehicleType,@DealerAccessoryCode,@AllInventoryAcctDollar,@BestPrice,@InStock,@AccountingMake,@GasDiesel,@BookValue,
@FactoryAccessoryDescription,@TotalReturn,@TotalCost,@SS,@VehicleBody,@StandardEquipment,@Account,@CalculatedPrice,@OriginalCost,@AccessoryCore,
@OtherDollar,@PrimaryBookValue,@AmountDue,@LicenseFee,@ICompany,@InvenAcct,@Field23,@Field24,@SalesCode,@BaseRetail,@BaseInvAmt,@CommPrice,@Price1,
@Price2,@StickerPrice,@TotInvAmt,@OptRetail,@OptInvAmt,@OptCost,@Options1,@Category,@Description,@Engine,@ModelType,@FTCode,@Wholesale,@Retail,@Draft,
@ERRORNUMBER,@ERRORSEVERITY,@ERRORTABLE,@ERRORSTATE,@ERRORPROCEDURE,@ERRORLINE,@errormessage,@FtpDate
END CATCH
--==========================================================================
-- INSERT INTO DMS_INVENTORY_VEHICLE (CHILD TABLE)
--==========================================================================
BEGIN TRY
INSERT INTO [dbo].[DMS_INVENTORY_VEHICLE]
DMSInventoryID,
InteriorColorCode,
ExteriorColorCode,
Air,
ModelDesc,
VehicleType,
VehicleVIN,
VehicleYear,
VehicleMake,
VehicleModel,
VehicleModelCode,
VehicleTrim,
VehicleSubTrimLevel,
Classification,
TypeCode,
VehicleMileage,
FtpDate,
EngineCylinderCount
VALUES (
@InventoryID,
@InteriorColorCode,
@ExteriorColorCode,
@Air,
@ModelDesc,
@VehicleType,
@VehicleVIN,
@VehicleYear,
@VehicleMake,
@VehicleModel,
@VehicleModelCode,
@VehicleTrim,
@VehicleSubTrimLevel,
@Classification,
@TypeCode,
@VehicleMileage,
@FtpDate,
@EngineCylinderCount
END TRY
BEGIN CATCH
SELECT
@errornumber = ERROR_NUMBER(),
@errorseverity = ERROR_SEVERITY(),
@errortable = 'DMS_INVENTORY_VEHICLE',
@errorstate = ERROR_STATE(),
@errorprocedure = ERROR_PROCEDURE(),
@errorline = ERROR_LINE(),
@errormessage = ERROR_MESSAGE();
--==========================================================================
-- INSERT ERRORS INTO DMSLOG_INVENTORY_ERROR
--==========================================================================
EXEC [SP_DMS_INVENTORY_ERROR] @FileType,@ACDealerID,@ClientDealerID,@DMSType,@StockNumber,@InventoryDate,@StockType,@DMSStatus,@InvoicePrice,@CostPack,
@SalesCost,@HoldbackAmount,@ListPrice,@MSRP,@LotLocation,@TagLine,@Certification,@CertificationNumber,@VehicleVIN,@VehicleYear,@VehicleMake,@VehicleModel,@VehicleModelCode,
@VehicleTrim,@VehicleSubTrimLevel,@Classification,@TypeCode,@VehicleMileage,@EngineCylinderCount,@TransmissionType,@VehicleExteriorColor,@VehicleInteriorColor,
@CreatedDate,@LastModifiedDate,@ModifiedFlag,@InteriorColorCode,@ExteriorColorCode,@PackageCode,@CodedCost,@Air,@OrderType,@AgeDays,@OutstandingRO,
@DlrAccessoryRetail,@DlrAccessoryCost,@DlrAccessoryDesc,@ModelDesc,@Memo1,@Memo2,@Weight,@FloorPlan,@Purchaser,@PurchasedFrom,@InternetPrice,
@InventoryAcctDollar,@VehicleType,@DealerAccessoryCode,@AllInventoryAcctDollar,@BestPrice,@InStock,@AccountingMake,@GasDiesel,@BookValue,
@FactoryAccessoryDescription,@TotalReturn,@TotalCost,@SS,@VehicleBody,@StandardEquipment,@Account,@CalculatedPrice,@OriginalCost,@AccessoryCore,
@OtherDollar,@PrimaryBookValue,@AmountDue,@LicenseFee,@ICompany,@InvenAcct,@Field23,@Field24,@SalesCode,@BaseRetail,@BaseInvAmt,@CommPrice,@Price1,
@Price2,@StickerPrice,@TotInvAmt,@OptRetail,@OptInvAmt,@OptCost,@Options1,@Category,@Description,@Engine,@ModelType,@FTCode,@Wholesale,@Retail,@Draft,
@ERRORNUMBER,@ERRORSEVERITY,@ERRORTABLE,@ERRORSTATE,@ERRORPROCEDURE,@ERRORLINE,@errormessage,@FtpDate
END CATCH
--==========================================================================
-- MOVE CURSUR TO NEXT RECORD
--==========================================================================
FETCH NEXT FROM Inventory_Cursor
INTO @FileType ,
@ACDealerID ,
@ClientDealerID ,
@DMSType ,
@StockNumber ,
@InventoryDate ,
@StockType ,
@DMSStatus ,
@InvoicePrice ,
@CostPack ,
@SalesCost ,
@HoldbackAmount ,
@ListPrice ,
@MSRP ,
@LotLocation ,
@TagLine ,
@Certification ,
@CertificationNumber ,
@VehicleVIN ,
@VehicleYear ,
@VehicleMake ,
@VehicleModel ,
@VehicleModelCode ,
@VehicleTrim ,
@VehicleSubTrimLevel ,
@Classification ,
@TypeCode ,
@VehicleMileage ,
@EngineCylinderCount ,
@TransmissionType ,
@VehicleExteriorColor ,
@VehicleInteriorColor ,
@CreatedDate ,
@LastModifiedDate ,
@ModifiedFlag ,
@InteriorColorCode ,
@ExteriorColorCode ,
@PackageCode ,
@CodedCost ,
@Air ,
@OrderType ,
@AgeDays ,
@OutstandingRO ,
@DlrAccessoryRetail ,
@DlrAccessoryCost ,
@DlrAccessoryDesc ,
@ModelDesc ,
@Memo1 ,
@Memo2 ,
@Weight ,
@FloorPlan ,
@Purchaser ,
@PurchasedFrom ,
@InternetPrice ,
@InventoryAcctDollar ,
@VehicleType ,
@DealerAccessoryCode ,
@AllInventoryAcctDollar ,
@BestPrice ,
@InStock ,
@AccountingMake ,
@GasDiesel ,
@BookValue ,
@FactoryAccessoryDescription ,
@TotalReturn ,
@TotalCost ,
@SS ,
@VehicleBody ,
@StandardEquipment ,
@Account ,
@CalculatedPrice ,
@OriginalCost ,
@AccessoryCore ,
@OtherDollar ,
@PrimaryBookValue ,
@AmountDue ,
@LicenseFee ,
@ICompany ,
@InvenAcct ,
@Field23 ,
@Field24 ,
@SalesCode ,
@BaseRetail ,
@BaseInvAmt ,
@CommPrice ,
@Price1 ,
@Price2 ,
@StickerPrice ,
@TotInvAmt ,
@OptRetail ,
@OptInvAmt ,
@OptCost ,
@Options1 ,
@Category ,
@Description ,
@Engine ,
@ModelType ,
@FTCode ,
@Wholesale ,
@Retail ,
@Draft ,
@flatfile_createddate,
@FtpDate;
END
CLOSE Inventory_Cursor;
DEALLOCATE Inventory_Cursor;
SET ANSI_PADDING OFF
END
Arunraj KumarThank you.
And another question if the data is already there in the child table if i try to load alone it must delete the old data in the child tablee and need to get load the new data and
How to do this ?
Arunraj Kumar
You can do that with an IF EXISTS condition
IF EXISTS (SELECT 1
FROM YourChildTable c
INNER JOIn @temptable t
ON c.Bkey1 = t.Bkey1
AND c.Bkey2 = t.Bkey2
DELETE t
FROM YourChildTable c
INNER JOIn @temptable t
ON c.Bkey1 = t.Bkey1
AND c.Bkey2 = t.Bkey2
INSERT INTO YourChildTable
where Bkey1,Bkey2 etc forms the business key of the table
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook Page
Maybe you are looking for
-
Importing files from a Synology Nas to Itunes on my Mac Mini
I have managed to import about 50 CDs from my NAS to a MAc Mini I am using as a music server to my HiFi system. A folder appears on the Mac with the items loaded onto I tunes and files waiting to add. I simply clicked and dragged the folders to Autom
-
I just saved a file in CC, and when I try to reopen the file, I get "Could not complete your request because the file is not compatible with this version of Photoshop." These are big files, and I have been working on them for about a month without pr
-
Regarding documents with .docx extension
we have a fully functional knowledge repository .my requirement is when i upload a document of extension .docx and when i try opening it the portal is not supporting the format . (same with pptx). i have tried creating a new mime type under content m
-
Wip for the wbs not found for particular month
Hi What are the reason a wip not found for a wbs for a particular month while doing rrb billing ,while it is again found in the next month
-
Installed CS6 but will not open raw photos from 5DMarklll- I had to install beta bridge 6.7 to open photos before buying CS6- want to leave CS5 on my computer- but don't see a way to just unintall bridge 6.7 so that bridge 7.0 will open my raw files.