Improvement in the script

Dúvidas, dicas e truques de PL/SQL. Aqui também vão assuntos relacionados a pacotes, triggers, funções, Java-Stored Procedures, etc
Post Reply
snowblacksoul
Rank: Estagiário Sênior
Rank: Estagiário Sênior
Posts: 9
Joined: Wed, 25 Nov 2009 9:34 am
Location: sp
snowblacksoul@hotmail.com
analista de suporte

Hello everyone, I need your help, please, I work in a company where the tables have 30millions of records, you need to make a bulk collection, because it's the performance is better, but it's giving error and I can not do the update I want .

looks at the error

Select all

 
ORA-06550: linha 52, coluna 24: 
PL/SQL: ORA-00904: : identificador inválido 
ORA-06550: linha 41, coluna 7: 
PL/SQL: SQL Statement ignored 
Please help me!


Select all

 
declare 
v_dt_inicio timestamp; 
v_dt_fim    timestamp; 
 
 
 
 CURSOR c1 IS  
 SELECT a.rowid,  
                      b.nrc, 
                      b.id_status_pc, 
                      b.id_status_conta, 
                      b.id_localidade, 
                      b.terminal, 
                      b.cod_subtp_produto_comercial, 
                      b.dt_ins_prqe, 
                      b.in_stop_faturamento, 
                      b.seg_cnta 
                  FROM tabela1 a, 
                       tabela2 b 
                 WHERE a.flag_atis IS NOT NULL 
                   AND NVL(a.sis_ant,a.sis_atu) = b.sistema 
                   AND a.produto_comercial = b.produto_comercial 
                   AND b.dt_ini_cnta = (SELECT MAX(c.dt_ini_cnta) 
                                          FROM tabela3 c 
                                         WHERE c.produto_comercial = b.produto_comercial 
                                           AND b.sistema = c.sistema); 
                                            
 TYPE fetch_array IS TABLE OF c1%ROWTYPE;  
 s_array fetch_array;  
BEGIN  
v_dt_inicio := systimestamp; 
  OPEN c1;  
  LOOP  
    FETCH c1 BULK COLLECT INTO s_array LIMIT 1000;  
 
        EXIT WHEN s_array.COUNT = 0;  
    FORALL i IN 1..s_array.COUNT  
 
 --insert /*+RULE*/ into  system.tmp_batimento VALUES s_array(i); 
  
      UPDATE tabela1 a 
         SET a.nrc = nrc(i)||':', 
             a.id_status_pc_ant = id_status_pc(i)||':', 
             a.id_status_conta_ant = id_status_conta(i)||':', 
             a.id_localidade_ant = id_localidade(i)||':', 
             a.terminal = terminal(i)||':', 
             a.classe_ant = cod_subtp_produto_comercial(i)||':', 
             a.cod_subtp_prod_com_ant = cod_subtp_produto_comercial(i)||':', 
             a.dt_ins_prqe_ant = dt_ins_prqe(i)||':', 
             a.in_stop_fat_ant = in_stop_faturamento(i)||':', 
             a.seg_ant = NVL(seg_ant(i),seg_cnta(i))||':' 
       WHERE a.rowid = rowid(i); 
    
  END LOOP;  
  v_dt_fim := systimestamp; 
 
dbms_output.put_line('Tempo processamento: '||to_char(v_dt_fim - v_dt_inicio,'dd/mm/yyyy hh24:mi:ss.ff')); 
 
  CLOSE c1;  
  COMMIT;  
END;              
 
/ 
Quote / quote]
ishii
Rank: Analista Júnior
Rank: Analista Júnior
Posts: 82
Joined: Tue, 28 Dec 2010 7:41 pm
Location: São Paulo - SP

Hello,

Place an alias on the Rowid column so that there is no confusion in the SQL parse.

Select all

 
declare  
v_dt_inicio timestamp;  
v_dt_fim    timestamp;  
 
 
 
 CURSOR c1 IS  
 SELECT a.rowid ID_LINHA,  
                      b.nrc,  
                      b.id_status_pc,  
                      b.id_status_conta,  
                      b.id_localidade,  
                      b.terminal,  
                      b.cod_subtp_produto_comercial,  
                      b.dt_ins_prqe,  
                      b.in_stop_faturamento,  
                      b.seg_cnta  
                  FROM tabela1 a,  
                       tabela2 b  
                 WHERE a.flag_atis IS NOT NULL  
                   AND NVL(a.sis_ant,a.sis_atu) = b.sistema  
                   AND a.produto_comercial = b.produto_comercial  
                   AND b.dt_ini_cnta = (SELECT MAX(c.dt_ini_cnta)  
                                          FROM tabela3 c  
                                         WHERE c.produto_comercial = b.produto_comercial  
                                           AND b.sistema = c.sistema);  
                                             
 TYPE fetch_array IS TABLE OF c1%ROWTYPE;  
 s_array fetch_array;  
BEGIN  
v_dt_inicio := systimestamp;  
  OPEN c1;  
  LOOP  
    FETCH c1 BULK COLLECT INTO s_array LIMIT 1000;  
 
        EXIT WHEN s_array.COUNT = 0;  
    FORALL i IN 1..s_array.COUNT  
 
 --insert /*+RULE*/ into  system.tmp_batimento VALUES s_array(i);  
   
      UPDATE tabela1 a  
         SET a.nrc = nrc(i)||':',  
             a.id_status_pc_ant = id_status_pc(i)||':',  
             a.id_status_conta_ant = id_status_conta(i)||':',  
             a.id_localidade_ant = id_localidade(i)||':',  
             a.terminal = terminal(i)||':',  
             a.classe_ant = cod_subtp_produto_comercial(i)||':',  
             a.cod_subtp_prod_com_ant = cod_subtp_produto_comercial(i)||':',  
             a.dt_ins_prqe_ant = dt_ins_prqe(i)||':',  
             a.in_stop_fat_ant = in_stop_faturamento(i)||':',  
             a.seg_ant = NVL(seg_ant(i),seg_cnta(i))||':'  
       WHERE a.rowid = ID_LINHA(i);  
     
  END LOOP;  
  v_dt_fim := systimestamp;  
 
dbms_output.put_line('Tempo processamento: '||to_char(v_dt_fim - v_dt_inicio,'dd/mm/yyyy hh24:mi:ss.ff'));  
 
  CLOSE c1;  
  COMMIT;  
END;               
 
/  

[] S ISHII
snowblacksoul
Rank: Estagiário Sênior
Rank: Estagiário Sênior
Posts: 9
Joined: Wed, 25 Nov 2009 9:34 am
Location: sp
snowblacksoul@hotmail.com
analista de suporte

Fabio was worth responding heimm !! Much obliged!

But I did the test and now has the following error

Select all

 
Relatório de erro: 
ORA-06550: linha 52, coluna 24: 
PL/SQL: ORA-00904: "ID_LINHA": identificador inválido 
ORA-06550: linha 41, coluna 7: 
PL/SQL: SQL Statement ignored 
06550. 00000 -  "line %s, column %s:\n%s" 
*Cause:    Usually a PL/SQL compilation error. 
*Action: 
Tineks
Rank: DBA Sênior
Rank: DBA Sênior
Posts: 365
Joined: Tue, 24 May 2005 2:24 pm
Location: Araraquara - SP
Cristiano (Tineks)
Araraquara - SP

And then brow, beauty?

You need to hit your update, it is not using the Type fetch_array.

Select all

 
      update tabela1 a 
         set a.nrc                    = s_array(i).nrc || ':' 
            ,a.id_status_pc_ant       = s_array(i).id_status_pc || ':' 
            ,a.id_status_conta_ant    = s_array(i).id_status_conta || ':' 
            ,a.id_localidade_ant      = s_array(i).id_localidade || ':' 
            ,a.terminal               = s_array(i).terminal || ':' 
            ,a.classe_ant             = s_array(i).cod_subtp_produto_comercial || ':' 
            ,a.cod_subtp_prod_com_ant = s_array(i).cod_subtp_produto_comercial || ':' 
            ,a.dt_ins_prqe_ant        = s_array(i).dt_ins_prqe || ':' 
            ,a.in_stop_fat_ant        = s_array(i).in_stop_faturamento || ':' 
            ,a.seg_ant                = nvl(s_array(i).seg_ant,s_array(i).seg_cnta) || ':' 
       where a.rowid = s_array(i).id_linha(i); 
Another thing, you need to put in the select of the cursor, the seg_ant field.

falow !!!!
[] S !!
snowblacksoul
Rank: Estagiário Sênior
Rank: Estagiário Sênior
Posts: 9
Joined: Wed, 25 Nov 2009 9:34 am
Location: sp
snowblacksoul@hotmail.com
analista de suporte

Speak big beleza !!!
face is getting worse the rsrsrs, I did exactly how he told me, but now he's giving several mistakes, because in fact the table comes with repeated names

Select all

 
 
Relatório de erro: 
ORA-06550: linha 29, coluna 31: 
PLS-00402: apelido obrigatório na lista de cursor SELECT para evitar nomes duplicados de coluna 
ORA-06550: linha 29, coluna 2: 
PL/SQL: Item ignored 
ORA-06550: linha 35, coluna 32: 
PLS-00597: expressão 'S_ARRAY' na lista INTO tem o tipo incorreto 
ORA-06550: linha 35, coluna 5: 
PL/SQL: SQL Statement ignored 
ORA-06550: linha 50, coluna 30: 
PLS-00487: Referência inválida para a variável 'C1%ROWTYPE' 
ORA-06550: linha 50, coluna 30: 
PLS-00382: a expressão é do tipo incorreto 
ORA-06550: linha 50, coluna 49: 
PLS-00487: Referência inválida para a variável 'C1%ROWTYPE' 
ORA-06550: linha 50, coluna 49: 
PLS-00382: a expressão é do tipo incorreto 
ORA-06550: linha 49, coluna 34: 
PLS-00487: Referência inválida para a variável 'C1%ROWTYPE' 
ORA-06550: linha 49, coluna 34: 
PLS-00382: a expressão é do tipo incorreto 
ORA-06550: linha 48, coluna 34: 
PLS-00487: Referência inválida para a variável 'C1%ROWTYPE' 
ORA-06550: linha 48, coluna 34: 
PLS-00382: a expressão é do tipo incorreto 
ORA-06550: linha 47, coluna 41: 
PLS-00487: Referência inválida para a variável 'C1%ROWTYPE' 
ORA-06550: linha 47, coluna 41: 
PLS-00382: a expressão é do tipo incorreto 
ORA-06550: linha 46, coluna 29: 
PLS-00487: Referência inválida para a variável 'C1%ROWTYPE' 
ORA-06550: linha 46, coluna 29: 
PLS-00382: a expressão é do tipo incorreto 
ORA-06550: linha 45, coluna 27: 
PLS-00487: Referência inválida para a variável 'C1%ROWTYPE' 
ORA-06550: linha 45, coluna 27: 
PLS-00382: a expressão é do tipo incorreto 
ORA-06550: linha 44, coluna 36: 
PLS-00487: Referência inválida para a variável 'C1%ROWTYPE' 
ORA-06550: linha 44, coluna 36: 
PLS-00382: a expressão é do tipo incorreto 
06550. 00000 -  "line %s, column %s:\n%s" 
*Cause:    Usually a PL/SQL compilation error. 
*Action: 
Tineks
Rank: DBA Sênior
Rank: DBA Sênior
Posts: 365
Joined: Tue, 24 May 2005 2:24 pm
Location: Araraquara - SP
Cristiano (Tineks)
Araraquara - SP

And then brow, beauty?

has a detail in this script, in the cursor only loads fields from "table2" .. The update is pointing to "table1" ... would that be that?

If you can, send the "CREATE TABLE" script of these tables, so it is easier to help ...

Thanks!
[] SSS!
snowblacksoul
Rank: Estagiário Sênior
Rank: Estagiário Sênior
Posts: 9
Joined: Wed, 25 Nov 2009 9:34 am
Location: sp
snowblacksoul@hotmail.com
analista de suporte

Speak big excuse for the delay, run !!
So that's right you can see that it picks up from Table 1 and Table2 then makes an update in Table 1 with, but in fact it's using but 2 data than one, but it makes a comparison with WHERE !!
Tineks
Rank: DBA Sênior
Rank: DBA Sênior
Posts: 365
Joined: Tue, 24 May 2005 2:24 pm
Location: Araraquara - SP
Cristiano (Tineks)
Araraquara - SP

Speak Brow, beauty?

I set up a script with a similar environment to your ..
to make an update using forall, you would have 2 options, or create a variable for each field that the cursor will use , or you can use a Type Object as in the example below ... whatever doubt just ask!

[] S!

Select all

 
Connected to Oracle Database 10g Enterprise Edition Release 10.2.0.3.0  
Connected as ccm 
 
SQL>  
SQL> drop table tabela1 
  2  / 
 
Table dropped 
 
SQL> drop table tabela2 
  2  / 
 
Table dropped 
 
SQL> drop table tabela3 
  2  / 
 
Table dropped 
 
SQL> drop type tbl_tabela 
  2  / 
 
Type dropped 
 
SQL> drop type typ_tabela 
  2  / 
 
Type dropped 
 
SQL> create table TABELA2 
  2    (nrc                         number(3) 
  3    ,id_status_pc                number(3) 
  4    ,id_status_conta             number(3) 
  5    ,id_localidade               number(3) 
  6    ,terminal                    number(3) 
  7    ,cod_subtp_produto_comercial number(3) 
  8    ,dt_ins_prqe                 date 
  9    ,in_stop_faturamento         varchar(1) 
 10    ,seg_ant                     number(3) 
 11    ,seg_cnta                    number(3) 
 12    ,sistema                     number(3) 
 13    ,produto_comercial           varchar(1) 
 14    ,dt_ini_cnta                 date 
 15    ) 
 16  / 
 
Table created 
 
SQL> create table TABELA1 
  2    (nrc                         number(3) 
  3    ,id_status_pc                number(3) 
  4    ,id_status_pc_ant            number(3) 
  5    ,id_status_conta             number(3) 
  6    ,id_status_conta_ant         number(3) 
  7    ,id_localidade_ant           number(3) 
  8    ,id_localidade               number(3) 
  9    ,terminal                    number(3) 
 10    ,classe_ant                  number(3) 
 11    ,cod_subtp_produto_comercial number(3) 
 12    ,cod_subtp_prod_com_ant      number(3) 
 13    ,dt_ins_prqe_ant             date 
 14    ,dt_ins_prqe                 date 
 15    ,in_stop_fat_ant             varchar(1) 
 16    ,in_stop_faturamento         varchar(1) 
 17    ,seg_ant                     number(3) 
 18    ,seg_cnta                    number(3) 
 19    ,flag_atis                   varchar(1) 
 20    ,sistema                     number(3) 
 21    ,produto_comercial           varchar(1) 
 22    ,dt_ini_cnta                 date 
 23    ,sis_ant                     number(3) 
 24    ,sis_atu                     number(3) 
 25    ) 
 26  / 
 
Table created 
 
SQL> create table TABELA3 
  2    (produto_comercial           varchar(1) 
  3    ,sistema                     number(3) 
  4    ,dt_ini_cnta                 date 
  5    ) 
  6  / 
 
Table created 
 
SQL> insert into tabela1 (nrc 
  2                      ,id_status_pc 
  3                      ,id_status_conta 
  4                      ,id_localidade 
  5                      ,terminal 
  6                      ,cod_subtp_produto_comercial 
  7                      ,cod_subtp_prod_com_ant 
  8                      ,dt_ins_prqe_ant 
  9                      ,dt_ins_prqe 
 10                      ,in_stop_fat_ant 
 11                      ,in_stop_faturamento 
 12                      ,seg_ant 
 13                      ,seg_cnta 
 14                      ,flag_atis 
 15                      ,sistema 
 16                      ,produto_comercial 
 17                      ,dt_ini_cnta 
 18                      ,sis_ant 
 19                      ,sis_atu) 
 20               values (1 
 21                      ,12 
 22                      ,13 
 23                      ,14 
 24                      ,123 
 25                      ,333 
 26                      ,444 
 27                      ,trunc(sysdate) 
 28                      ,trunc(sysdate) 
 29                      ,'A' 
 30                      ,'F' 
 31                      ,888 
 32                      ,999 
 33                      ,'X' 
 34                      ,10 
 35                      ,'1' 
 36                      ,trunc(sysdate) 
 37                      ,10 
 38                      ,10) 
 39  / 
 
1 row inserted 
 
SQL> insert into tabela2 (nrc 
  2                      ,id_status_pc 
  3                      ,id_status_conta 
  4                      ,id_localidade 
  5                      ,terminal 
  6                      ,cod_subtp_produto_comercial 
  7                      ,dt_ins_prqe 
  8                      ,in_stop_faturamento 
  9                      ,seg_ant 
 10                      ,seg_cnta 
 11                      ,sistema 
 12                      ,produto_comercial 
 13                      ,dt_ini_cnta) 
 14               values (1 
 15                      ,12 
 16                      ,13 
 17                      ,14 
 18                      ,123 
 19                      ,333 
 20                      ,trunc(sysdate) 
 21                      ,'F' 
 22                      ,888 
 23                      ,999 
 24                      ,10 
 25                      ,'1' 
 26                      ,trunc(sysdate)) 
 27  / 
 
1 row inserted 
 
SQL> insert into TABELA3 values ('1',10,trunc(sysdate)) 
  2  / 
 
1 row inserted 
 
SQL> CREATE OR REPLACE TYPE typ_tabela AS object (linha                         varchar(18) 
  2                                              ,nrc                         number(3) 
  3                                              ,id_status_pc                number(3) 
  4                                              ,id_status_conta             number(3) 
  5                                              ,id_localidade               number(3) 
  6                                              ,terminal                    number(3) 
  7                                              ,cod_subtp_produto_comercial number(3) 
  8                                              ,dt_ins_prqe                 date 
  9                                              ,in_stop_faturamento         varchar(1) 
 10                                              ,seg_ant                     number(3) 
 11                                              ,seg_cnta                    number(3) 
 12                                              ) 
 13  / 
 
Type created 
 
SQL> CREATE TYPE tbl_tabela AS TABLE OF typ_tabela; 
  2  / 
 
Type created 
 
SQL> declare 
  2    v_dt_inicio timestamp; 
  3    v_dt_fim    timestamp; 
  4   
  5    cursor c1 is 
  6      select typ_tabela(a.rowid, 
  7                        b.nrc, 
  8                        b.id_status_pc, 
  9                        b.id_status_conta, 
 10                        b.id_localidade, 
 11                        b.terminal, 
 12                        b.cod_subtp_produto_comercial, 
 13                        b.dt_ins_prqe, 
 14                        b.in_stop_faturamento, 
 15                        a.seg_ant, 
 16                        a.seg_cnta) 
 17        from tabela1 a 
 18            ,tabela2 b 
 19       where a.flag_atis is not null 
 20         and nvl(a.sis_ant, a.sis_atu) = b.sistema 
 21         and a.produto_comercial       = b.produto_comercial 
 22         and b.dt_ini_cnta             = (select max(c.dt_ini_cnta) 
 23                                            from tabela3 c 
 24                                           where c.produto_comercial = b.produto_comercial 
 25                                             and b.sistema           = c.sistema); 
 26   
 27    t_tabela tbl_tabela; 
 28  begin 
 29    open c1; 
 30    loop 
 31      fetch c1 bulk collect 
 32        into t_tabela limit 1000; 
 33      exit when t_tabela.count = 0; 
 34   
 35      forall i in 1 .. t_tabela.count 
 36        update tabela1 a 
 37           set a.nrc                     = treat(t_tabela(i) as typ_tabela).nrc 
 38              ,a.id_status_pc_ant        = treat(t_tabela(i) as typ_tabela).id_status_pc 
 39              ,a.id_status_conta_ant     = treat(t_tabela(i) as typ_tabela).id_status_conta 
 40              ,a.id_localidade_ant       = treat(t_tabela(i) as typ_tabela).id_localidade 
 41              ,a.terminal                = treat(t_tabela(i) as typ_tabela).terminal 
 42              ,a.classe_ant              = treat(t_tabela(i) as typ_tabela).cod_subtp_produto_comercial 
 43              ,a.cod_subtp_prod_com_ant  = treat(t_tabela(i) as typ_tabela).cod_subtp_produto_comercial 
 44              ,a.dt_ins_prqe_ant         = treat(t_tabela(i) as typ_tabela).dt_ins_prqe 
 45              ,a.in_stop_fat_ant         = treat(t_tabela(i) as typ_tabela).in_stop_faturamento 
 46              ,a.seg_ant                 = treat(t_tabela(i) as typ_tabela).seg_ant 
 47         where rowid = treat(t_tabela(i) as typ_tabela).linha; 
 48      dbms_output.put_line('Linha atualizadas : '|| sql%rowcount); 
 49    end loop; 
 50    close c1; 
 51  end; 
 52  / 
 
Linha atualizadas : 1 
 
PL/SQL procedure successfully completed 
snowblacksoul
Rank: Estagiário Sênior
Rank: Estagiário Sênior
Posts: 9
Joined: Wed, 25 Nov 2009 9:34 am
Location: sp
snowblacksoul@hotmail.com
analista de suporte

Speak big beleza !!!
Thank you very much for the help you saw !!, ours is helping and a lot !!
to resolve good part

These are the tables that use in the script

Select all

 
describe system.FAT_20110227_20110127_TMP 
Nome                           Nulo     Tipo                                                                                                                                                                                           
------------------------------ -------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------  
PRODUTO_COMERCIAL                       NUMBER                                                                                                                                                                                         
SIS_ANT                                 NUMBER                                                                                                                                                                                         
SIS_ATU                                 NUMBER                                                                                                                                                                                         
CICLO_ANT                               NUMBER                                                                                                                                                                                         
CICLO_ATU                               NUMBER                                                                                                                                                                                         
CLASSE_ANT                              VARCHAR2(30)                                                                                                                                                                                   
CLASSE_ATU                              VARCHAR2(30)                                                                                                                                                                                   
SEG_ANT                                 NUMBER                                                                                                                                                                                         
SEG_ATU                                 NUMBER                                                                                                                                                                                         
VL_CRED_M_ANT                           NUMBER                                                                                                                                                                                         
VL_CRED_M_ATU                           NUMBER                                                                                                                                                                                         
VL_DEBT_M_ANT                           NUMBER                                                                                                                                                                                         
VL_DEBT_M_ATU                           NUMBER                                                                                                                                                                                         
VL_CRED_T_ANT                           NUMBER                                                                                                                                                                                         
VL_CRED_T_ATU                           NUMBER                                                                                                                                                                                         
VL_DEBT_T_ANT                           NUMBER                                                                                                                                                                                         
VL_DEBT_T_ATU                           NUMBER                                                                                                                                                                                         
FLAG_ATIS                               VARCHAR2(1)                                                                                                                                                                                    
FLAG_LEGADO                             VARCHAR2(1)                                                                                                                                                                                    
FLAG_MIGRADO                            VARCHAR2(1)                                                                                                                                                                                    
FLAG_ESTAVEL                            VARCHAR2(1)                                                                                                                                                                                    
FLAG_ENTRATE                            VARCHAR2(1)                                                                                                                                                                                    
FLAG_SAINTE                             VARCHAR2(1) 
 
---------------------------------------------------------------- 
describe system.PARQUE_CONTRATADO_20110324 
Nome                           Nulo     Tipo                                                                                                                                                                                           
------------------------------ -------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------  
NRC                                     VARCHAR2(50)                                                                                                                                                                                   
SISTEMA                                 VARCHAR2(50)                                                                                                                                                                                   
ID_CONTA                                VARCHAR2(50)                                                                                                                                                                                   
DT_INI_PRQE                             VARCHAR2(50)                                                                                                                                                                                   
DT_FIM_PRQE                             VARCHAR2(50)                                                                                                                                                                                   
DT_INS_PRQE                             VARCHAR2(50)                                                                                                                                                                                   
DT_RET_PRQE                             VARCHAR2(50)                                                                                                                                                                                   
TERMINAL                                VARCHAR2(50)                                                                                                                                                                                   
ID_LOCALIDADE                           VARCHAR2(50)                                                                                                                                                                                   
COD_SUBTP_PRODUTO_COMERCIAL             VARCHAR2(50)                                                                                                                                                                                   
ID_STATUS_PC                            VARCHAR2(50)                                                                                                                                                                                   
ID_MOTIVO_PC                            VARCHAR2(50)                                                                                                                                                                                   
CD_CONTA                                VARCHAR2(50)                                                                                                                                                                                   
DT_ALT_CNTA                             VARCHAR2(50)                                                                                                                                                                                   
DT_BAI_CNTA                             VARCHAR2(50)                                                                                                                                                                                   
DT_INI_CNTA                             VARCHAR2(50)                                                                                                                                                                                   
DT_FIM_CNTA                             VARCHAR2(50)                                                                                                                                                                                   
ID_STATUS_CONTA                         VARCHAR2(50)                                                                                                                                                                                   
IN_STOP_FATURAMENTO                     VARCHAR2(50)                                                                                                                                                                                   
SEG_CNTA                                VARCHAR2(50)                                                                                                                                                                                   
CONTA                                   VARCHAR2(6)                                                                                                                                                                                    
PRODUTO_COMERCIAL                       NUMBER(25)    
 
-------------------------------------------------------------- 
Aqui a query, juntamente com o erro de rowid, as tabelas não tem chaves primarias, infelizmente!! 
 
 
Erro ao iniciar na linha 1 no comando 
declare  
      v_dt_inicio timestamp;  
      v_dt_fim    timestamp;  
     
      cursor c1 is  
        select typ_tabela(a.rowid,  
                          b.nrc,  
                          b.id_status_pc,  
                          b.id_status_conta,  
                         b.id_localidade,  
                         b.terminal,  
                         b.cod_subtp_produto_comercial,  
                         b.dt_ins_prqe,  
                         b.in_stop_faturamento,  
                         a.seg_ant,  
                         a.seg_atu)  
         from FAT_20110227_20110127_TMP a  
             ,PARQUE_CONTRATADO_20110324 b   
        where a.flag_atis is not null  
          and nvl(a.sis_ant, a.sis_atu) = b.sistema  
          and a.produto_comercial       = b.produto_comercial  
          and b.dt_ini_cnta             = (select max(c.dt_ini_cnta)  
                                             from PARQUE_CONTRATADO_20110324 c  
                                            where c.produto_comercial = b.produto_comercial  
                                              and b.sistema           = c.sistema);  
    
     t_tabela tbl_tabela;  
   begin  
     open c1;  
     loop  
       fetch c1 bulk collect  
         into t_tabela limit 1000;  
       exit when t_tabela.count = 0;  
    
       forall i in 1 .. t_tabela.count  
         update tabela1 a  
            set a.nrc                     = treat(t_tabela(i) as typ_tabela).nrc  
               ,a.id_status_pc_ant        = treat(t_tabela(i) as typ_tabela).id_status_pc  
               ,a.id_status_conta_ant     = treat(t_tabela(i) as typ_tabela).id_status_conta  
               ,a.id_localidade_ant       = treat(t_tabela(i) as typ_tabela).id_localidade  
               ,a.terminal                = treat(t_tabela(i) as typ_tabela).terminal  
               ,a.classe_ant              = treat(t_tabela(i) as typ_tabela).cod_subtp_produto_comercial  
               ,a.cod_subtp_prod_com_ant  = treat(t_tabela(i) as typ_tabela).cod_subtp_produto_comercial  
               ,a.dt_ins_prqe_ant         = treat(t_tabela(i) as typ_tabela).dt_ins_prqe  
               ,a.in_stop_fat_ant         = treat(t_tabela(i) as typ_tabela).in_stop_faturamento  
              ,a.seg_ant                 = treat(t_tabela(i) as typ_tabela).seg_ant 
               where rowid = treat(t_tabela(i) as typ_tabela).linha;  
       dbms_output.put_line('Linha atualizadas : '|| sql%rowcount);  
     end loop;  
     close c1;  
   end;  
    
Relatório de erro: 
ORA-01410: ROWID inválido 
ORA-06512: em line 35 
01410. 00000 -  "invalid ROWID" 
*Cause:     
*Action: 
 
 
snowblacksoul
Rank: Estagiário Sênior
Rank: Estagiário Sênior
Posts: 9
Joined: Wed, 25 Nov 2009 9:34 am
Location: sp
snowblacksoul@hotmail.com
analista de suporte

Speak big beleza !!!!
I want to thank for the attention, to be able to do, that broke a huge branch expensive, thanks, thank you

Hugs stay in peace!
Tineks
Rank: DBA Sênior
Rank: DBA Sênior
Posts: 365
Joined: Tue, 24 May 2005 2:24 pm
Location: Araraquara - SP
Cristiano (Tineks)
Araraquara - SP

Beauty Brow !!!

Thanks, Hugs !!!!
Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 4 guests