Magic Of Materialized views!
Dear All,
I have created a procedure which runs for 5hrs approximately.I have a query in a procedure which alone takes 41/2 hrs. The reason being we have so many aggregated column values in the query and the result is grouped witha group by clause.
Now I have created a materialized view on the prebuilt table which is build on the result of the query which runs for 41/2 hrs as i said before.Now when I use the materialized view instead of the query it finished in 5 mins.
Now the problem here is I run the procedure daily and base tables of the longtime running query are updated daily.So I have to refresh the materialized view everytime.But Refreshing itself takes upto 41/2 hrs.In that sense there is no use of the materialized views if its running the same time as the query in the procedure.
Note:Here I cant refresh the materialized view on commit because Query is quite complex.So I am forced to refresh the materialized view on demand.
Can anyone help me solve this issue?How can I make the refreshing of the databse fast?
If your query needs XX hours to complete then it simply needs them and you cannot do anything.
BUT
You can try to tune it.
And look here for initial steps When your query takes too long ...
As you have mentioned many aggregates I suggest you to look how much you need temporary space, probably you can increase it for your session that is doing the query be it MV create or simple select without MV.
Gints Plivna
http://www.gplivna.eu
Similar Messages
-
Are Cube organized materialized view with Year to Date calculated measure eligible for Query Rewrite
Hi,
Will appreciate if someone can help me with a question regarding Cube organized MV (OLAP).
Does cube organized materialized view with calculated measures based on time series Year to date, inception to date eg.
SUM(FCT_POSITION.BASE_REALIZED_PNL) OVER (HIERARCHY DIM_CALENDAR.CALENDAR BETWEEN UNBOUNDED PRECEDING AND CURRENT MEMBER WITHIN ANCESTOR AT DIMENSION LEVEL DIM_CALENDAR."YEAR")
are eligible for query rewrites or these are considered advanced for query rewrite purposes.
I was hoping to find an example with YTD window function on physical fact dim tables with optimizer rewriting it to Cube Org. MV but not much success.
Thanks in advanceI dont think this is possible.
(My own reasoning)
Part of the reason query rewrite works for base measures only (not calc measures in olap like ytd would be) is due to the fact that the data is staged in olap but its lineage is understandable via the olap cube mappings. That dependency/source identification is lost when we build calculated measures in olap and i think its almost impossible for optimizer to understand the finer points relating to an olap calculation defined via olap calculation (olap dml or olap expression) and also match it with the equivalent calculation using relational sql expression. The difficulty may be because both the olap ytd as well as relational ytd defined via sum() over (partition by ... order by ...) have many non-standard variations of the same calculation/definition. E.g: You can choose to use or choose not to use the option relating to IGNORE NULLs within the sql analytic function. OLAP defn may use NASKIP or NASKIP2.
I tried to search for query rewrite solutions for Inventory stock based calculations (aggregation along time=last value along time) and see if olap cube with cube aggregation option set to "Last non-na hierarchical value" works as an alternative to relational calculation. My experience has been that its not possible. You can do it relationally or you can do it via olap but your application needs to be aware of each and make the appropriate backend sql/call. In such cases, you cannot make olap (aw/cubes/dimensions) appear magically behind the scenes to fulfill the query execution while appearing to work relationally.
HTH
Shankar -
MATERIALIZED VIEW ORA-12006 and ORA-08103
We have an old 9.2.0.6 database which uses materialized views to access information from other systems via database links. One of these views though will no longer refresh, the others are OK including ones using the same database link and source system.
When we try to refresh get:
CREATE MATERIALIZED VIEW <user>.<materialized view>
REFRESH FORCE
AS SELECT *
FROM <source user>.<source table>@<database link>
AS SELECT *
ERROR at line 3:
ORA-12006: a materialized view with the same user.name already exists
drop MATERIALIZED VIEW <user>.<materialized view>
ERROR at line 1:
ORA-08103: object no longer exists
Obviously we can't rename the view and because of various restrictions I can't upgrade the database, we are in the process of migrating it to 11g.
Does anyone have a magic bullet to resolve this as I have been looking around and haven't found an answer as yet.Sorry you think the results are confusing but they are the results, obviously I have to protect exact names etc...
Materialized View system:
Shows other views for other source systems but not the ones for this source system.
It shows these ones as an object_type of TABLE in dba_objects even though they were created as materilized views.
Source system select:
OBJECT_NAME OBJECT_TYPE OWNER
<table name> TABLE <table owner>
<table name> SYNONYM PUBLIC
If I use a new name yes it does resolve the issue but I don't want to use a different name if possible as either the application guys have to change some code or I will have to build in another level of synonyms to translate the new name. At the end of the day if this is the only solution! -
Refresh/Update data in a materialized view
Hi,
I have question about the data in a materialized view and how it is refreshed. My mat view has all my dimension-ids and my (for my specialize needs) aggregated measures from my fact table. I used the mat view wizard to create my view - which works perfectly. But now I wonder if I have to create some sort of mapping(?) or some sort of trigger to refresh the data in the mat view. Or is the data automatically refreshed when I start my fact table mappings. I use OWB 11gR2
thxMVs have properties for refresh - you an refresh based on schedules or when dependent data is committed or manually.
Cheers
David -
How can I fast refresh the materialized view !!
I created a MV base on some tables in order to improve the querey speed.
but the mv I have created falied to refresh fast.
because there are two same table in the from clause:
jcdm jc1,jcdm jc2
create materialized view temp_mv
nologging
pctfree 0
storage (initial 2048k next 2048k pctincrease 0)
parallel
build immediate
refresh force
on demand
as
select
TAB_GSHX.rowid hx_rid,
TAB_GSHD.rowid hd_rid ,
JC1.rowid jc1_rid ,
JC2.rowid jc2_rid ,
YSHD_ID HXID,
JC1.JCDM QFD,
JC2.JCDM JLD
FROM
TAB_GSHX,
TAB_GSHD,
jCDM JC1,
JCDM JC2
WHERE
YSHD_ID=YSHX_ID
AND YSHD_QFD=JC1.JBJC_ID
AND YSHD_JLD=JC2.JBJC_ID
AND TO_CHAR(YSHX_time,'YYYYMMDD')='20030101'
the column msgtxt of the table MV_CAPABILITIES_TABLE is :
"the multiple instances of the same table or view" and " one or more joins present in mv".
How can I succeed in fast refresh the above temp_mv!!!
thanks.lianjun,
When you are using Oracle9i there is a procedure which can help you setup the materialized view. If some option isn't working it gives you hint why it doesn't work.
The procedure is dbms_mview.explain_mview.
Take a look at the documentation how to use it. (In the Oracle9i DWH guide the package is explained.)
Hope this helps
With kind regards,
Bas Roelands -
How to get Materialized View to ignore unused columns in source table
When updating a column in a source table, records are generated in the corresponding materialized view log table. This happens even if the column being updated is not used in any MV that references the source table. That could be OK, so long as those updates are ignored. However they are not ignored, so when the MV is fast refreshed, I find it can take over a minute, even though no changes are required or made. Is there some way of configuring the materialized view log such that the materialized view refresh ignores these updates ?
So for examle if I have table TEST:
CREATE table test (
d_id NUMBER(10) PRIMARY KEY,
d_name VARCHAR2(100),
d_desc VARCHAR2(256)
This has an MV log MLOG$_TEST:
CREATE MATERIALIZED VIEW LOG ON TEST with rowid, sequence, primary key;
CREATE MATERIALIZED VIEW test_mv
refresh fast on demand
as
select d_id, d_name
from test;
INSERT 200,000 records
exec dbms_mview.refresh('TEST_MV','f');
update test set d_desc = upper(d_desc) ;
exec dbms_mview.refresh('TEST_MV','f'); -- This takes 37 seconds, yet no changes are required.
Oracle 10g/11gI would love to hear a positive answer to this question - I have the exact same issue :-)
In the "old" days (version 8 I think it was) populating the materialized view logs was done by Oracle auto-creating triggers on the base table. A "trick" could then make that trigger become "FOR UPDATE OF <used_column_list>". Now-a-days it has been internalized so such "triggers" are not visible and modifiable by us mere mortals.
I have not found a way to explicitly tell Oracle "only populate MV log for updates of these columns." I think the underlying reason is that the MV log potentially could be used for several different materialized views at possibly several different target databases. So to be safe that the MV log can be used for any MV created in the future - Oracle always populates MV log at any update (I think.)
One way around the problem is to migrate to STREAMS replication rather than materialized views - but it seems to me like swatting a fly with a bowling ball...
One thing to be aware of: Once the MV log has been "bloated" with a lot of unneccessary logging, you may perhaps see that all your FAST REFRESHes afterwards becomes slow - even after the one that checked all the 200000 unneccessary updates. We have seen that it can happen that Oracle decides on full table scanning the MV log when it does a fast refresh - which usually makes sense. But after a "bloat" has happened, the high water mark of the MV log is now unnaturally high, which can make the full table scan slow by scanning a lot of empty blocks.
We have a nightly job that checks each MV log if it is empty. If it is empty, it locks the MV log and locks the base table, checks for emptiness again, and truncates the MV log if it is still empty, before finally unlocking the tables. That way if an update during the day has happened to bloat the MV log, all the empty space in the MV log will be reclaimed at night.
But I hope someone can answer both you and me with a better solution ;-) -
Materialized View to run only once in a year...
Hi everybody...
I want to create a materialized view which will run only once in a year and specifically some minutes after 00:00 a.m. on new year's day,
so i created the following:
CREATE MATERIALIZED VIEW <mv_name>
BUILD IMMEDIATE
REFRESH START WITH TO_DATE('01/01/2007 00:15:00','DD/MM/RRRR HH24:MI:SS')
NEXT SYSDATE+366
I have two notes:
1) how to declare the refresh to be done the first new year's day after the day it'll be created , i mean not static date (01/01/2007)
2)some years are leap and some are not , so in order to run every new year's day how should i transform the above..????
3)is there any view which displays the next run of a materialized view..???
the view DBA_MV_REFRESH_TIMES displays the last refresh of mv's...
I use Oracle 10.2.0.1 on XP ...
Thanks , a lot
Simon1).
use the expression that evaluates to next january first.
SQL> select sysdate, add_months(trunc(sysdate, 'yyyy'), 12) from dual ;
SYSDATE ADD_MONTHS(
19-JUN-2006 01-JAN-2007
1 row selected.
SQL>2). for this also use the same expression that will evaluate to the january first of the year after that. -
Is it possible to refresh the table from a Materialized view
Hi,
Is it possible to update the underlying table on which a Materialized view is created when some changes in a Materialized view is done.Is this reverse compatibility possible in Materialized View?
Thanks in Advance,
V.DennisIf you created the materialized view as UPDATEABLE then changes to it should automatically be relected in the underlying table. If this is not occurring I suggest you check the replication jobs. You probably have a stack of errors in DEFERROR.
Cheers, APC -
The data of my materialized view....in the while
Hello
We have problems with materialized views
We have one wich re-build each a short period of time
¿Can i avoid the data to dissapear in the time process of refresh?
Is so annoing to our clients to see that "from time to time" the data just dissapear for one period of time -the time while the materialized view is refreshing-
Thank you in advance
Bruno. Madrid. Spain> Is so annoing to our clients to see that "from time to time" the data just dissapear for
one period of time -the time while the materialized view is refreshing-
Have a similar problem. And dealing with large data volumes that makes the DELETE of the MV a very undesirable feature. Not as much a the resource footprint required, but the time it takes to do this - and the very tight processing windows that exist.
The solution is a self-rolled and very likely not ideal for most - but it works well enough for us in production.
No MV. Create a partition table. Create a staging table. Do a manual "full refresh" of the staging table (TRUNCATE and direct path INSERT). Follow this by a partition exchange with the partition table (no validation and including indexes). The result is that the data is replaced in the partitioned table within a second - no long running and expensive DELETE. End-users not effected by having a truncate pulling the data from beneath their reports. -
Exporting data from a materialized view in Oracle 10g
Can anybody tell me how to export data to a remote server and import data in that remote server without using ftp utility. Actually I want to export the data from a materialized view to the remote server and import the same in the remote server.
If everything works well, I'll put the exporting and importing in a cronjob.
Please let me know how can I do that if that's possible .
Any reply would be appreciated.
Thanks.Here is what I'm trying to do.
I created materialized views using multiple base tables in my local server and the base tables got populated using a long process.
Now I want to copy those data alone to some remote server since it doesn't have any base tables in it. For now, the remote server should depends on the localserver's data. I'm going to use the remote server's data for some testing purposes.
I know it is easy to create mat.views in the remote server but it doesn't have I don't want to do that now. I just want to copy the snapshots from my local server to the remote server.
Please let me know how to do that.
Thanks. -
Issue with creation of a materialized view
Hi,
I have a SQL query that works fine.
But when I create a materialized view using the query, a few columns in the MV do not get populated at all.
What could be the issue here?
regards
PremHi,
Thanks for the reply. Here is the code.
CREATE MATERIALIZED VIEW EDW.MV_OPPTY_ACTIVITY_AGG
TABLESPACE EDW_DIM_DAT
NOCACHE
LOGGING
NOCOMPRESS
NOPARALLEL
BUILD IMMEDIATE
REFRESH COMPLETE ON DEMAND
WITH PRIMARY KEY
AS
select
OPPTY_ID OPPTY_ID,
OPPORTUNITY_KEY OPPORTUNITY_KEY,
oppty_number oppty_number ,
SALES_CONSULTANT_HIST_KEY SALES_CONSULTANT_HIST_KEY ,
company_add_source_key company_add_source_key,
SALES_CONSULTANT_ID SALES_CONSULTANT_ID,
ACTIVITY_TYPE ACTIVITY_TYPE ,
activity_DATE activity_DATE ,
LAST_MODIFIED_DATE LAST_MODIFIED_DATE ,
CUSTOMER_FLAG CUSTOMER_FLAG,
SALES_EMPLOYEE_HIST_KEY,
milestone_KEY,
oppty_milestone_name_hist stage_name,
oppty_milestone_id_hist stage_id,
milestone_prob prob_to_close,
start_date oppty_start_date,
oppty_close_date oppty_close_date,
end_date oppty_end_date,
sum(DURATION) TOTAL_DURATION,
sum (CASE WHEN ACTIVITY_type IN ('CU14', 'CU15', 'CU16', 'CU17',
'CU18', 'CU19', 'CU20', 'CU21') THEN DURATION ELSE 0 END ) CQM_DURATION,
sum (CASE WHEN ACTIVITY_type = 'CU01' THEN DURATION ELSE 0 END ) TRADE_SEM_DURATION,
sum( CASE WHEN ACTIVITY_type = 'CU02' THEN DURATION ELSE 0 END ) RFP_RFI_DURATION,
sum( CASE WHEN ACTIVITY_type = 'CU03' THEN DURATION ELSE 0 END ) INFO_GATH_DURATION,
sum( CASE WHEN ACTIVITY_type = 'CU04' THEN DURATION ELSE 0 END ) PREP_DURATION,
sum( CASE WHEN ACTIVITY_type = 'CU05' THEN DURATION ELSE 0 END ) PRES_DEMO_DURATION,
sum( CASE WHEN ACTIVITY_type = 'CU06' THEN DURATION ELSE 0 END ) POC_DURATION,
sum ( CASE WHEN ACTIVITY_type = 'CU07' THEN DURATION ELSE 0 END ) PRE_CUST_SUPP_DURATION,
sum( CASE WHEN ACTIVITY_type = 'CU08' THEN DURATION ELSE 0 END ) POST_CUST_SUPP_DURATION,
sum( CASE WHEN ACTIVITY_type = 'CU09' THEN DURATION ELSE 0 END ) PARTNER_SUPP_DURATION,
sum( CASE WHEN ACTIVITY_type = 'CU10' THEN DURATION ELSE 0 END ) TRAVEL_DURATION,
sum( CASE WHEN ACTIVITY_type = 'CU11' THEN DURATION ELSE 0 END ) KEYCODES_DURATION,
sum( CASE WHEN ACTIVITY_type = 'CU12' THEN DURATION ELSE 0 END ) SI_SUPP_DURATION,
sum ( CASE WHEN ACTIVITY_type = 'CU13' THEN DURATION ELSE 0 END ) CHANNEL_SUPP_DURATION,
sum( CASE WHEN ACTIVITY_type = 'CU23' THEN DURATION ELSE 0 END ) MIGRATION_DURATION ,
max(LICENSE_USD) LICENSE_USD ,
MAX(LICENSE_LOCAL) LICENSE_LOCAL,
MAX(maintAINANCE_usd) maintAINANCE_usd,
MAX(maintAINANCE_LOCAL) maintAINANCE_LOCAL,
MAX(TRAINING_USD) training_usd,
MAX(TRAINING_LOCAL) training_LOCAL,
MAX(CONSULTING_USD) consulting_usd,
MAX(CONSULTING_LOCAL) consulting_LOCAL,
MAX(RENEWALS_USD) renewals_usd ,
MAX(RENEWAL_local) RENEWAL_local,
max(LOBANALYTICS2_LOCAL) epm_local,
max(LOBDATAINTEGRATION2_LOCAL) eim_local,
max(IDD_AMOUNT_LOCAL) idd_local,
max(ONDEMAND_AMOUNT_LOCAL) ondemand_local,
max(LOBANALYTICS2_usd) epm_usd,
max(LOBDATAINTEGRATION2_usd) eim_usd,
max(IDD_AMOUNT_usd) idd_usd,
max(ONDEMAND_AMOUNT_usd) ondemand_usd
FROM edw.sales_consulting_activity_fct t1 ,
select
o.oppty_id_number,
o.oppty_id,
O.OPPORTUNITY_KEY,
LICENSE_USD LICENSE_USD ,
LICENSE_LOCAL LICENSE_LOCAL,
o.FYM_USD maintAINANCE_usd,
o.FYM_LOCAL maintAINANCE_LOCAL,
o.TRAINING_USD training_usd,
o.TRAINING_LOCAL training_LOCAL,
o.CONSULTING_USD consulting_usd,
o.CONSULTING_LOCAL consulting_LOCAL,
o.RENEWAL_USD renewals_usd ,
o.RENEWAL_local RENEWAL_local ,
o.LOBANALYTICS2_LOCAL,
o.LOBANALYTICS2_usd,
o.LOBDATAINTEGRATION2_LOCAL,
o.IDD_AMOUNT_LOCAL,
o.ONDEMAND_AMOUNT_LOCAL,
o.LOBDATAINTEGRATION2_usd,
o.IDD_AMOUNT_usd,
o.ONDEMAND_AMOUNT_usd
from edw.opportunity_hist_fact o
where o.SOURCE_SYSTEM='SFDC'
and upper(status)='ACTIVE'
and o.last_modified_date = (select max(last_modified_date )from edw.opportunity_hist_fact o2 where o.opportunity_key = o2.opportunity_key))T2,
( Select activity_key,OPPTY_ID_NUMBER, MIL.milestone_KEY,MIL.milestone_name oppty_milestone_name_hist,milestone_id
oppty_milestone_id_hist, milestone_prob,start_date,oppty_close_date,end_date FROM
EDW.opportunity_hist_fact OPP,
edw.milestone MIL,
edw.sales_consulting_activity_fct act WHERE
ACTIVITY_DATE >=start_date (+) and activity_date <=opp.last_modified_date(+)
and OPP.OPPTY_ID_NUMBER (+) =act.OPPTY_NUMBER
and OPP.milestone_key =MIL.milestone_key(+) ) T3
where t1.oppty_NUMBER (+) =T2.OPPTY_ID_NUMBER
and t1.activity_key=t3.activity_key
--and oppty_number ='279749'
GROUP BY OPPTY_ID,
oppty_number,
OPPORTUNITY_KEY,
SALES_CONSULTANT_HIST_KEY ,
company_add_source_key,
SALES_CONSULTANT_ID,
SALES_EMPLOYEE_HIST_KEY,
ACTIVITY_TYPE ,
ACTIVITY_DATE ,
LAST_MODIFIED_DATE,
CUSTOMER_FLAG,
milestone_KEY,
oppty_milestone_name_hist,
oppty_milestone_id_hist,
milestone_prob,
start_date,
oppty_close_date,
end_date;
Regards,
Prem -
Select query in materialized view with two dblinks
Hi All,
We have oracle 10g On windows.
We are trying to create materialized view. Scenario is we have base table on other database and we are creating mview on different database.
Basa database have two schema's and i am selecting records from that two schema's using two private db links.
But when i am tryin gto create mview its not getting created. After 15 hrs. its still showing creation command and not finished.
Query is :-
Is it good practice to have two db links in select query of materialized view.Billy Verreynne wrote:
Chanchal Wankhade wrote:
Is it good practice to have two db links in select query of materialized view.Same db link being used twice, or two different db links?
If the former, you ideally want the local Oracle db to send the join to the remote database, and for the remote database to drive the join between those 2 tables. There is a hint (<i>driving_site</i>) that can be used - or the join query can be defined on the remote database as a view, and the local materialised view can then use that remote view.
If you have 2 different db links and joining across these - usually a bad idea to perform distributed database joins. There are lots of limitations as to how the tables can be joined. Worse case, full table scans of both remote tables, pulling all the rows from the 2 remote database tables to the local database, and joining these on the local database.
I have seen some severe performance issues in the past as a result of distributed joins. I'll rather use 2 materialised views for pulling both distributed tables's data locally, and then do the join on local data (using indexes, partition pruning, etc)Hi Billy,
My scenario is i have two database database A and database B. Database A is having two schema's SCOTT AND HR. SCOTT schema have select privileges on HR schema.
DB LINK is between Database B to Database A. name is db.link.B.A.oracle.com.
What if i priovide while creating materialized view, the schema name before the table name in database B for this particuler table so it will pick up the table from that schema using same DB LINK(db.link.B.A.oracle.com.) that i am using to fetch records from SCOTT schema.
Above schnario is like two base schema's and one db link using two schema. -
Leave a distinct value in a materialized view on two tables
Hi and thank you for reading,
I have the following problem. I am creating a materialized view out of two tables, with "where a.id = b.id".
The resulting materialized view list several values twice. For example, one customer name has several contact details and thus the customer name is listed several times. Now I would like to join each customer name with just ONE contact detail, how can I do that? (Even if I would loose some information while doing this).
Thanks
EvgenyHi,
You can do this
SELECT deptno, empno, ename, job, mgr, hiredate, sal, comm
FROM emp_test
ORDER BY deptno;
DEPTNO EMPNO ENAME JOB MGR HIREDATE SAL COMM
10 7782 CLARK MANAGER 7839 1981-06-09 2450
10 7839 KING PRESIDENT 1981-11-17 5000 0
10 7934 MILLER CLERK 7782 1982-01-23 1300
20 7566 JONES MANAGER 7839 1981-04-02 2975
20 7902 FORD ANALYST 7566 1981-12-03 3000
20 7876 ADAMS CLERK 7788 1987-05-23 1100
20 7369 SMITH CLERK 7902 1980-12-17 800
20 7788 SCOTT ANALYST 7566 1987-04-19 3000
30 7521 WARD SALESMAN 7698 1981-02-22 1250 500
30 7844 TURNER SALESMAN 7698 1981-09-08 1500
30 7499 ALLEN SALESMAN 7698 1981-02-20 1600 300
30 7900 JAMES CLERK 7698 1981-12-03 950
30 7698 BLAKE MANAGER 7839 1981-05-01 2850
30 7654 MARTIN SALESMAN 7698 1981-09-28 1250 1400
14 rows selected.
SELECT CASE
WHEN ROW_NUMBER () OVER (PARTITION BY deptno ORDER BY empno) =
1
THEN deptno
END deptno,
empno, ename, job, mgr, hiredate, sal, comm
FROM emp_test;
DEPTNO EMPNO ENAME JOB MGR HIREDATE SAL COMM
10 7782 CLARK MANAGER 7839 1981-06-09 2450
7839 KING PRESIDENT 1981-11-17 5000 0
7934 MILLER CLERK 7782 1982-01-23 1300
20 7369 SMITH CLERK 7902 1980-12-17 800
7566 JONES MANAGER 7839 1981-04-02 2975
7788 SCOTT ANALYST 7566 1987-04-19 3000
7876 ADAMS CLERK 7788 1987-05-23 1100
7902 FORD ANALYST 7566 1981-12-03 3000
30 7499 ALLEN SALESMAN 7698 1981-02-20 1600 300
7521 WARD SALESMAN 7698 1981-02-22 1250 500
7654 MARTIN SALESMAN 7698 1981-09-28 1250 1400
7698 BLAKE MANAGER 7839 1981-05-01 2850
7844 TURNER SALESMAN 7698 1981-09-08 1500
7900 JAMES CLERK 7698 1981-12-03 950
14 rows selected.Edited by: Salim Chelabi on 2009-09-14 08:13 -
Use of db sequence in a materialized view
Hi,
Will it be possible to use a database sequence in a materialized view?
The materialized view is to return the result set of query that joins multiple tables. One of the columns in the result set - the to-be-created materialized view - is null and requires a sequence.
Will it be possible to include a db sequence in the query?
Example:
create materialized view example_mview
as
select example_sequence.nextval, table1.'*', table2.'*'
from example_table1 table1, example_table2 table2
where table1.id=table2.idWhat is the purpose of such numbering? To number each row?
If so - then use ROWNUM as 1st column.
SQL>with ddd
as
(select 333 COL from dual union all select 5444 COL from dual)
select rownum,COL from ddd;ROWNUM COL
1 333
2 5444 -
Sdo_cs.transform procedure in a materialized view
Hi all,
Oracle version :10.2.0.4
I am trying to do perform reprojection in a materialised view ( refresh on demand, complete mode).
It seems everytime I refresh the MV ,this error pops up.
SQL> exec dbms_mview.refresh('SUPER', 'C');
BEGIN dbms_mview.refresh('SUPER', 'C'); END;
ERROR at line 1:
ORA-12008: error in materialized view refresh path
ORA-06531: Reference to uninitialized collection
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2251
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2457
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2426
ORA-06512: at line 1
<code>
CREATE MATERIALIZED VIEW "SUPER" ORGANIZATION HEAP PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "DATA_DATA" BUILD DEFERRED USING INDEX REFRESH COMPLETE ON DEMAND USING DEFAULT LOCAL ROLLBACK SEGMENT DISABLE QUERY REWRITE
AS
SELECT seq_nextval AS PID,
SITE,
STATE,
reproject(geoloc)
FROM BJON;
<code>
The procedure of reproject
create or replace
FUNCTION "REPROJECT" (p_coordinates in SDO_GEOMETRY)
return SDO_GEOMETRY deterministic
as v_coordinates SDO_GEOMETRY;
BEGIN
v_coordinates := sdo_cs.transform (p_coordinates, 4326);
RETURN v_coordinates;
end REPROJECT;
Can anyone let me know hw I can put plug thereprojection in a materialized view.
Edited by: CrackerJack on May 2, 2012 11:00 PMHi all,
Any clues?
I have died of anymore ideas to make this work.
All I need is a updated table with
Primary key ,
GEOMETRY 4326
spatial index.
metadata
Teh materialized view is perfect except I can't do the reprojections.
ORA-06531: Reference to uninitialized collection means have some null values in the array , but if you remove the Reproject function and just geometry itself , the materialised view works brilliant.
I tried converting to 0,0 point in the function to tackle the nulls in array if any.. but doesn't work.
sdo_cs.transform(nvl(geoloc, mdsys.sdo_geometry(2001, 8307, mdsys.sdo_point_type(0,0,NULL),NULL,NULL)),82027).get_wkt()
Any ideas is much appreciated.
Edited by: CrackerJack on May 6, 2012 10:27 PM
Maybe you are looking for
-
Flickering vs double buffering
Hello, flickering is a common problem and is prevented by using offscreen images. And that's what I'm doing (though, I'm not sure whether I'm doing it right). Now, there's a cycle of images displayed as an animation in my program and the flickering i
-
PROBLEM WITH 'COMMIT' COMMAND IN FORM 4.5
During any process if I use COMMIT command after insert, update or delete command in table which is not the base table of current form a message appears on screen 'No changes to save' and changes are saved in the table. How can I stop this message? I
-
I need help transfering data from old phone to new
-
How To Update Your Blu-ray Player's Firmware
Does your Blu-ray player not play the latest and greatest movies? There might be a firmware update available from the manufacturer. Here is a video that describes how to update the firmware: Jacob|Web Planner | Best Buy® Corporate
-
Class to Characteristic Values
In a development I want to give input of Class and in output should be all the characterstics assigned to class and all the equipments where class is assigned and the characteristics values of equipments. For ex: CLASS - MOTOR Characterstics - KW