2016-08-03 62 views
0

ich vor kurzem von Oracle 10g Oracle 12c bewegen habe und wenn ich versuche, eine materialisierte Ansicht erstellen Ich erhalte diesen FehlerOracle materialisierten Ansicht nicht ORA-12840 und ORA-06512:

Error report - 
SQL Error: ORA-12840: cannot access a remote table after parallel/insert direct load txn 
ORA-06512: at "Internal_function", line 11 
12840. 00000 - "cannot access a remote table after parallel/insert direct load txn" 
*Cause: Within a transaction, an attempt was made to perform distributed 
      access after a PDML or insert direct statement had been issued. 
*Action: Commit/rollback the PDML transaction first, and then perform 
      the distributed access, or perform the distributed access before the 
      first PDML statement in the transaction. 

I‘ m verwirrt, weil auf Oracle 10g die materialisierte Ansicht funktioniert gut, aber wenn ich dieselbe SQL-Anweisung auf Oracle 12c ausführen, erhalte ich den Fehler.

Dies ist die SQL-Anweisungen, die ich die materialisierte Ansicht

create materialized view vm_xxx as 
SELECT 
     id,  
     Internal_function(id) Internal_value 
FROM tableA 

Und dies ist der Code von Internal_function Funktion

create or replace FUNCTION  "Internal_function" 
(
    v_id in varchar2 
) RETURN VARCHAR2 AS 


total_count number; 
RETURN_VALUE varchar2(1):='N'; 
BEGIN 

    SELECT count(*) 
    INTO total_count 
    FROM 
    tableA e, 
    tableB t 
    WHERE 
    E.id =T.id(+) 
    AND 
    (
    e.v_id1 = v_id 
    OR 
    e.v_id2= v_id 
    OR 
    T.v_id3= v_id); 

    if total_count > 0 then 
     RETURN_VALUE:='Y'; 
    end if; 

    return RETURN_VALUE; 
END Internal_function; 

erstellen Wie kann mir sagen, was könnte ich dies tun zu lösen Problem? o mir Alternativen vorschlagen, diese Ansicht dieses

Antwort

0

Schauen Sie sich materialisiert zu erstellen:

create materialized view test_mw as 
SELECT e.id, 
     case 
     when count(*) > 0 then 
      'Y' 
     else 
      'N' 
     end as internal_value 
FROM tableA e, 
     tableB t 
WHERE E.id = T.id(+) 
AND (e.v_id1 = v_id OR e.v_id2 = v_id OR T.v_id3 = v_id) 
group by e.id;