I encounter an error whenever I refresh my Materialized view, so I created a PIPELINE function and left join it to my Main table, the creation of Materialized view runs smoothly, but when I tried to do a refresh, then the error message appeared.
ORA-00942: table or view does not exist
Please, need help on this.
create materialized view mv_test as
SELECT
id,
id1,
id2,
id3,
id4,
id5,
lpad(substr(ab.column_value, 3), 4, '0') ab
FROM
tbl1 t1 left join
TABLE ( split_str_by_delim(t1.id1, '|')) ab on substr(ab.column_value,1,2) =
'AB'
WHERE id2= sysdate;
Refresh:
begin
dbms_mview.refresh('MV_TEST','C');
end;
/
I also tried the snapshot refresh, and still doesn't work.
BEGIN
DBMS_SNAPSHOT.REFRESH( '"MV_TEST"','C');
end;
Below is the error I encounter.
Materialized view MV_TEST created.
Error starting at line : 22 in command -
begin
dbms_mview.refresh('MV_TEST','C');
end;
Error report -
ORA-00942: table or view does not exist
ORA-06512: at "SYS.DBMS_SNAPSHOT_KKXRCA", line 3020
ORA-06512: at "SYS.DBMS_SNAPSHOT_KKXRCA", line 2432
ORA-06512: at "SYS.DBMS_SNAPSHOT_KKXRCA", line 88
ORA-06512: at "SYS.DBMS_SNAPSHOT_KKXRCA", line 253
ORA-06512: at "SYS.DBMS_SNAPSHOT_KKXRCA", line 2413
ORA-06512: at "SYS.DBMS_SNAPSHOT_KKXRCA", line 2976
ORA-06512: at "SYS.DBMS_SNAPSHOT_KKXRCA", line 3263
ORA-06512: at "SYS.DBMS_SNAPSHOT_KKXRCA", line 3295
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 16
ORA-06512: at line 2
00942. 00000 - "table or view does not exist"
*Cause:
*Action:
Edit: Added my Function PIPELINE and TYPE
Type:
create or replace TYPE split_tbl as TABLE OF VARCHAR2(32767);
Function:
create or replace FUNCTION split_str_by_delim (p_list VARCHAR2, p_del
VARCHAR2)
RETURN split_tbl
PIPELINED IS
l_idx PLS_INTEGER;
l_list VARCHAR2 (32767) := p_list;
l_value VARCHAR2 (32767);
BEGIN
LOOP
l_idx := INSTR (l_list, p_del);
IF l_idx > 0 THEN
PIPE ROW (SUBSTR (l_list, 1, l_idx - 1));
l_list := SUBSTR (l_list, l_idx + LENGTH (p_del));
ELSE
PIPE ROW (l_list);
EXIT;
END IF;
END LOOP;
RETURN;
END split_str_by_delim;
regards, NelzKi
So, It works. I just added this additional join and it works like magic.
left join dual on 1=1
materialized view refresh has been successful.
Full Script:
create materialized view mv_test as
SELECT
id,
id1,
id2,
id3,
id4,
id5,
lpad(substr(ab.column_value, 3), 4, '0') ab
FROM
tbl1 t1 left join
TABLE ( split_str_by_delim(t1.id1, '|')) ab on substr(ab.column_value,1,2) = 'AB'
left join dual on 1=1
WHERE id2 = sysdate;
NelzKi
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.