Home » SQL & PL/SQL » SQL & PL/SQL » How to implement Materialized view in PL/SQL using Collections (Oracle Database 11g Release 11.2.0.3.0 - Production PL/SQL Release 11.2.0.3.0 - Production "CORE 11.2.0.3.0 Production" TNS for Linux: Version 11.2.0.3.0 - Production NLSRTL Version 11.2.0.3)
How to implement Materialized view in PL/SQL using Collections [message #641625] Wed, 19 August 2015 08:10 Go to next message
Lingaraju H C
Messages: 4
Registered: July 2015
Location: India
Junior Member
CREATE MATERIALIZED VIEW EMP_VW(ENAME,DNAME,JOB,SAL,COMM,DEPTNO)
AS
SELECT IV.EMP_NAME,
IV.JOB,
IV.SALARY,
IV.COMMISSION,
IV.DEPARTMENT_NO,
IV.DEPARTMENT_NAME
FROM( SELECT EMP.ENAME AS EMP_NAME,
EMP.JOB AS JOB,
EMP.SAL AS SALARY,
EMP.COMM AS COMMISSION,
EMP.DEPTNO AS DEPARTMENT_NO,
DEPT.DNAME AS DEPARTMENT_NAME
FROM SCOTT.EMP INNER JOIN SCOTT.DEPT
ON EMP.DEPTNO=DEPT.DEPTNO
AND EMP.DEPTNO IN(10,20)
ORDER BY EMP.DEPTNO) IV;
Re: How to implement Materialized view in PL/SQL using Collections [message #641626 is a reply to message #641625] Wed, 19 August 2015 08:14 Go to previous messageGo to next message
Michel Cadot
Messages: 68776
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator

select * from VIEW EMP_VW;

Re: How to implement Materialized view in PL/SQL using Collections [message #641628 is a reply to message #641626] Wed, 19 August 2015 08:24 Go to previous messageGo to next message
Lingaraju H C
Messages: 4
Registered: July 2015
Location: India
Junior Member
Thanks.I am new to ORACLE and PL/SQL.So need to know how can i achieve that.
Re: How to implement Materialized view in PL/SQL using Collections [message #641629 is a reply to message #641628] Wed, 19 August 2015 08:25 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
Please read and follow the forum guidelines, to enable us to help you:
OraFAQ Forum Guide
How to use {code} tags and make your code easier to read
Re: How to implement Materialized view in PL/SQL using Collections [message #641631 is a reply to message #641629] Wed, 19 August 2015 08:31 Go to previous messageGo to next message
Lingaraju H C
Messages: 4
Registered: July 2015
Location: India
Junior Member
CREATE materialized VIEW emp_vw
(ename, dname, job, sal, comm, deptno)
AS SELECT IV.emp_name,
          IV.job,
          IV.salary,
          IV.commission,
          IV.department_no,
          IV.department_name
   FROM   (SELECT emp.ename  AS EMP_NAME,
                  emp.job    AS JOB,
                  emp.sal    AS SALARY,
                  emp.comm   AS COMMISSION,
                  emp.deptno AS DEPARTMENT_NO,
                  dept.dname AS DEPARTMENT_NAME
           FROM   scott.emp
                  inner join scott.dept
                          ON emp.deptno = dept.deptno
                             AND emp.deptno IN( 10, 20 )
           ORDER  BY emp.deptno) IV;

[Updated on: Wed, 19 August 2015 08:32]

Report message to a moderator

Re: How to implement Materialized view in PL/SQL using Collections [message #641632 is a reply to message #641631] Wed, 19 August 2015 08:35 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
How will I know when correct answer has been posted here?
What problem needs to be solved?
Re: How to implement Materialized view in PL/SQL using Collections [message #641635 is a reply to message #641632] Wed, 19 August 2015 08:44 Go to previous messageGo to next message
Lingaraju H C
Messages: 4
Registered: July 2015
Location: India
Junior Member
I have to get output same as that materialized view using collections method.
Re: How to implement Materialized view in PL/SQL using Collections [message #641638 is a reply to message #641635] Wed, 19 August 2015 09:10 Go to previous messageGo to next message
cookiemonster
Messages: 13975
Registered: September 2008
Location: Rainy Manchester
Senior Member
And what are the collections supposed to do here?
Re: How to implement Materialized view in PL/SQL using Collections [message #641645 is a reply to message #641638] Wed, 19 August 2015 10:02 Go to previous messageGo to next message
Michel Cadot
Messages: 68776
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator

And what is/are "collections method"?

Re: How to implement Materialized view in PL/SQL using Collections [message #641646 is a reply to message #641645] Wed, 19 August 2015 10:04 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
Provide Posting Guidelines #10, please.
Re: How to implement Materialized view in PL/SQL using Collections [message #641654 is a reply to message #641631] Wed, 19 August 2015 21:42 Go to previous message
John Watson
Messages: 9003
Registered: January 2010
Location: Global Village
Senior Member
Can you explain what you want to do? Your MV creation statement so far is can't be right. Never mind that it has an unnecessary subquery, look at what it produces:
orclz> CREATE materialized VIEW emp_vw
  2  (ename, dname, job, sal, comm, deptno)
  3  AS SELECT IV.emp_name,
  4            IV.job,
  5            IV.salary,
  6            IV.commission,
  7            IV.department_no,
  8            IV.department_name
  9     FROM   (SELECT emp.ename  AS EMP_NAME,
 10                    emp.job    AS JOB,
 11                    emp.sal    AS SALARY,
 12                    emp.comm   AS COMMISSION,
 13                    emp.deptno AS DEPARTMENT_NO,
 14                    dept.dname AS DEPARTMENT_NAME
 15             FROM   scott.emp
 16                    inner join scott.dept
 17                            ON emp.deptno = dept.deptno
 18                               AND emp.deptno IN( 10, 20 )
 19             ORDER  BY emp.deptno) IV;

Materialized view created.

orclz> select * from emp_vw;

ENAME      DNAME            JOB        SAL       COMM DEPTNO
---------- --------- ---------- ---------- ---------- --------------
CLARK      MANAGER         2450                    10 ACCOUNTING
KING       PRESIDENT       5000                    10 ACCOUNTING
MILLER     CLERK           1300                    10 ACCOUNTING
JONES      MANAGER         2975                    20 RESEARCH
SCOTT      ANALYST         3000                    20 RESEARCH
ADAMS      CLERK           1100                    20 RESEARCH
FORD       ANALYST         3000                    20 RESEARCH

7 rows selected.

orclz>

Previous Topic: check the column is numeric or data
Next Topic: Merge String
Goto Forum:
  


Current Time: Wed Aug 12 08:13:34 CDT 2026