2017-07-30 23 views
-2

我想打印出我的两个表不匹配(通过某些标准)ORA-6504型号不匹配

CREATE OR REPLACE PROCEDURE one_two_mismatch(p_rc OUT SYS_REFCURSOR, 
    p_rc2 OUT SYS_REFCURSOR) 
    AS 
    BEGIN 
    dbms_output.put_line('T1 Table'); 
    OPEN p_rc 
    FOR select t1.ENTITY_KEY, t1.ENTITY_ID, t1.COMPONENT_ID, t1.PARENT_KEY, 
    t1.ENTITY_TYPE_KEY from entity t1,(select entity_id from (select 
    c.entity_id, count(e.component_id) as ONE_CNT, count(c.component_id) as 
    TWO_CNT from entity e, entity_cmm c where e.entity_id = 
    c.entity_id group 
    by c.entity_id) where ONE_CNT <> TWO_CNT) t2 where t1.ENTITY_ID = 
    t2.ENTITY_ID; 

    dbms_output.put_line('T2 Table'); 
    OPEN p_rc2 
    FOR select t3.ENTITY_KEY, t3.ENTITY_ID, t3.COMPONENT_ID, t3.PARENT_KEY, 
    t3.ENTITY_TYPE_KEY from entity_cmm t3,(select entity_id from 
    (select c.entity_id, count(e.component_id) as ONE_CNT, 
    count(c.component_id) as TWO_CNT from est_entity e, entity_cmm c 
    where e.entity_id = c.entity_id group by c.entity_id) where ONE_CNT <> 
    TWO_CNT) 
    t4 where t3.ENTITY_ID = t4.ENTITY_ID; 
    END one_two_mismatch; 

我写的记录,我已经在我的程序如下查询下面我在PL/SQL开发SQL窗口下面的语句来执行上面的过程,但我遇到的第9行的错误,表示结果的类型设置变量或查询不匹配

declare 
    p_rc sys_refcursor; 
    p_rc2 sys_refcursor; 
    l_rec est_entity%rowtype; 
    m_rec est_entity_cmm%rowtype; 
    begin 
     one_two_MISMATCH(p_rc, p_rc2); 
    LOOP 
     FETCH p_rc INTO l_rec; 
     EXIT WHEN p_rc%NOTFOUND; 
     DBMS_OUTPUT.put_line(l_rec.ENTITY_KEY || ',' || l_rec.ENTITY_ID || 
     ',' || l_rec.COMPONENT_ID ||',' || l_rec.PARENT_KEY ||','|| 
     l_rec.ENTITY_TYPE_KEY); 
    END LOOP; 

    CLOSE p_rc; 

LOOP 
FETCH p_rc2 INTO m_rec; 
EXIT WHEN p_rc2%NOTFOUND; 
DBMS_OUTPUT.put_line(m_rec.ENTITY_KEY || ',' || m_rec.ENTITY_ID || ',' || 
m_rec.COMPONENT_ID ||',' || m_rec.PARENT_KEY ||','|| 
m_rec.ENTITY_TYPE_KEY); 
END LOOP; 

    CLOSE p_rc2; 
end; 

是否有人可以帮忙吗?

+0

由于我们无法看到您的行号,请更具体地说明您的错误。 – Difster

+0

它给出了这些行错误: 'l_rec est_entity%ROWTYPE;'' m_rec est_entity_cmm%ROWTYPE;' –

+0

你确定你是在检索光标从'est_entity'表中的所有列? – Incognito

回答

1

根据提供的信息,它听起来像过程cmm_st_mismatch中的一个或两个查询没有正确的列列表。在匿名块中,声明接收引用游标记录的两个变量

l_rec est_entity%rowtype; 
m_rec est_entity_cmm%rowtype; 

被声明为行类型。从中获取的引用游标必须与rowtype变量声明中引用的表具有相同的数量,类型和顺序。从你描述的错误来看,存在着不匹配。