Materialized View, ORA-12008: error in materialized view refresh path

I want to refresh a materialized view, but I get an ORA-12008 error.
Does anybody have an idea? I do not find any errors in my refresh statement.
CREATE MATERIALIZED VIEW scott.dummy_mv
  TABLESPACE test
  BUILD IMMEDIATE
  USING INDEX TABLESPACE idx_test
  REFRESH
     START WITH sysdate
     NEXT ROUND(SYSDATE)+5/24          
     WITH PRIMARY KEY
  ENABLE QUERY REWRITE
  AS
  SELECT KM.ID ID
          ,KM.USERNAME USERNAME
       ,KM.ABTID ABTID     
  FROM my_table KM
scott@orcl>desc dummy_mv
Name                                      Null?    Typ
ID                                        NOT NULL NUMBER(4)
USERNAME                                  NOT NULL VARCHAR2(30)
ABTID                                     NOT NULL NUMBER(4)
scott@orcl>
BEGIN
  SYS.DBMS_JOB.REMOVE(6579);
COMMIT;
END;
DECLARE
  X NUMBER;
BEGIN
  SYS.DBMS_JOB.SUBMIT
  ( job       => X
   ,what      => 'dbms_refresh.refresh(''"scott"."dummy_mv"'');'
   ,next_date => to_date('07.01.2009 05:00:00','dd/mm/yyyy hh24:mi:ss')
   ,interval  => 'ROUND(SYSDATE)+5/24              '
   ,no_parse  => FALSE
  SYS.DBMS_OUTPUT.PUT_LINE('Job Number is: ' || to_char(x));
COMMIT;
END;
scott@orcl>exec dbms_refresh.refresh('dummy_mv');
BEGIN dbms_refresh.refresh('dummy_mv'); END;
FEHLER in Zeile 1:
ORA-12008: error in materialized view refresh path
ORA-00947: not enough values
ORA-06512: in "SYS.DBMS_SNAPSHOT", Zeile 820
ORA-06512: in "SYS.DBMS_SNAPSHOT", Zeile 877
ORA-06512: in "SYS.DBMS_IREFRESH", Zeile 683
ORA-06512: in "SYS.DBMS_REFRESH", Zeile 195
ORA-06512: in Zeile 1
scott@orcl>

crupper wrote:
I get the same error:
scott@orcl>exec dbms_mview.refresh('dummy_mv','c');
BEGIN dbms_mview.refresh('dummy_mv','c'); END;
FEHLER in Zeile 1:
ORA-12008: error in materialized view refresh path
ORA-00947: not enough values
ORA-06512: in "SYS.DBMS_SNAPSHOT", Zeile 820
ORA-06512: in "SYS.DBMS_SNAPSHOT", Zeile 877
ORA-06512: in "SYS.DBMS_SNAPSHOT", Zeile 858
ORA-06512: in Zeile 1
I would first check the "query" information of the DBA_SNAPSHOTS/DBA_MVIEWS dictionary views if it reveals anything obvious.
But it looks more like an internal error while processing the refresh. You can get more information about the error by tracing the session. A "alter session set sql_trace = true;" before running the refresh should be sufficient. Disconnect afterwards and check the generated trace file for errors either using "tkprof" and checking the output or by manually searching for "err=" in the trace file.
Which 4-digit version of Oracle are you using?
Regards,
Randolf
Oracle related stuff blog:
http://oracle-randolf.blogspot.com/
SQLTools++ for Oracle (Open source Oracle GUI for Windows):
http://www.sqltools-plusplus.org:7676/
http://sourceforge.net/projects/sqlt-pp/

Similar Messages

  • ORA-12008: error in materialized view refresh path ;;; PLZ HELP ME

    Hi all,
    I 'm using Oracle Database 10g Enterprise Edition Release 10.2.0.1.0; I got these errors when I tried to refresh my materialized view ;
    ORA-12008: error in materialized view refresh path
    ORA-01555: snapshot too old: rollback segment number 5 with name "_SYSSMU5$"
    too small
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2255
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2461
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2430
    I don't understand what mean these errors and why i got them?
    Someone can help me please ?
    Thanks
    regards,

    thank you Justin,
    I found in my alertDB.log this line ;
    Mon Aug 20 03:00:54 2007
    ORA-01555 caused by SQL statement below (SQL ID: 64a7sdbbvknta, Query Duration=1021 sec, SCN: 0x0004.4a145344):
    Mon Aug 20 03:00:54 2007
    INSERT /*+ BYPASS_RECURSIVE_CHECK */ INTO "MANAGEMENT"."MVIEW_COMPUTERS"("ID","WINVERSION","ANTIVIRUS","GUID","INSTALLDT","CONNECTION_TYPE","GROUPID
    ","QUOVACOUNTRY") SELECT "C"."ID","C"."WINVERSION","C"."ANTIVIRUS","C"."GUID","C"."INSTALLDT","C"."CONNECTIONTYPE","C"."GROUPID","C"."QUOVACOUNTRY"
    FROM "MANAGEMENT"."COMPUTERS" "C"
    So i execute this query to found the TUNED_UNDORETENTION value ;
    SELECT *
    FROM V$UNDOSTAT v
    WHERE v.MAXQUERYID = '64a7sdbbvknta'
    and i have this result :
    BEGIN_TIME     20070820 02:53:42
    END_TIME     20070820 03:03:42
    UNDOTSN     1
    UNDOBLKS     51242
    TXNCOUNT     5012
    MAXQUERYLEN     1060
    MAXQUERYID     64a7sdbbvknta
    MAXCONCURRENCY     21
    UNXPSTEALCNT     0
    UNXPBLKRELCNT     0
    UNXPBLKREUCNT     0
    EXPSTEALCNT     14
    EXPBLKRELCNT     51392
    EXPBLKREUCNT     0
    SSOLDERRCNT     1
    NOSPACEERRCNT     0
    ACTIVEBLKS     606920
    UNEXPIREDBLKS     19896
    EXPIREDBLKS     612728
    TUNED_UNDORETENTION     1841
    I don't know exactly which value i should set my parameter?
    Message was edited by:
    HAGGAR

  • ORA-12008: error in materialized view refresh path with ORA-01652

    I have a temp tablespace with 2 tempfiles of 2GB each (total 4GB) but still refresh of materialized view is failing with following error:
    5646690 - BIS Materialized View Refresh Program
    ORA-12008: error in materialized view refresh path
    ORA-01652: unable to extend temp segment by 128 in tablespace TEMP1
    I checked and temp ts is completly filled
    SQL> select TABLESPACE_NAME, BYTES_USED, BYTES_FREE from V$TEMP_SPACE_HEADER;
    TABLESPACE_NAME BYTES_USED BYTES_FREE
    TEMP1 2147483648 0
    TEMP1 2147483648 0
    My question is how do I find out how much space I need for temp tablespace. what 's the best practise to size temp tablespace when running refresh. refresh is done by client who is submitting a request thru ebiz apps so I 'd like to size it correctly without having to keep guessing.
    Thanks so much in advance for any help

    Hello,
    Temp tablespace size depends how much sort by , order by operation your application performing. You can create new temp tablespace and drop old one with bigger file size
    CREATE  TEMPORARY TABLESPACE TEMP02 TEMPFILE '\mypath_to_temp\TEMP02' SIZE 256M REUSE AUTOEXTEND ON NEXT 256M MAXSIZE 8192M EXTENT MANAGEMENT LOCAL;
    ALTER DATABASE DEFAULT TEMPORARY TABLESPACE TEMP02;
    Drop tablespace temp including contents; -- Make sure you delete on temp data files.Here is link for your reading purpose
    http://www.idevelopment.info/data/Oracle/DBA_tips/Tablespaces/TBS_3.shtml
    Regards
    Edited by: OrionNet on Mar 6, 2009 6:15 PM

  • ORA-12008: error in materialized view refresh path... Bug?

    SQL> select * from v$version;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit 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.0 - Production
    SQL> drop materialized view log on test_tbl;
    Materialized view log dropped.
    SQL> drop materialized view mv_test_tbl;
    Materialized view dropped.
    SQL> drop table test_tbl;
    Table dropped.
    SQL> create table test_tbl(
      2   test_id   number(10)   primary key,
      3   test_name varchar2(10) not null)
      4  ;
    Table created.
    SQL> insert into test_tbl values (1,'bob');
    1 row created.
    SQL> insert into test_tbl values (2,'joe');
    1 row created.
    SQL> insert into test_tbl values (3,'john');
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> create materialized view log on test_tbl
      2  with primary key , rowid, sequence
      3  (
      4   test_name
      5  )
      6  including new values;
    Materialized view log created.
    SQL> create materialized view mv_test_tbl
      2  refresh fast on commit
      3  as
      4  select test_id,
      5         test_name
      6  from   test_tbl;
    Materialized view created.
    SQL> update test_tbl set test_name = 'hello' where test_id = 1000;
    0 rows updated.
    SQL> commit;
    Commit complete.Ok, so that's all good. Now if I create the materialized view log with the COMMIT SCN option:
    SQL> drop materialized view log on test_tbl;
    Materialized view log dropped.
    SQL> drop materialized view mv_test_tbl;
    Materialized view dropped.
    SQL> create materialized view log on test_tbl
      2  with primary key , rowid, sequence
      3  (
      4   test_name
      5  ),
      6  commit scn
      7  including new values;
    Materialized view log created.
    SQL> create materialized view mv_test_tbl
      2  refresh fast on commit
      3  as
      4  select test_id,
      5         test_name
      6  from   test_tbl;
    Materialized view created.
    SQL> update test_tbl set test_name = 'hello' where test_id = 1000;
    0 rows updated.
    SQL> commit;
    commit
    ERROR at line 1:
    ORA-12008: error in materialized view refresh path
    ORA-01006: bind variable does not exist
    SQL>Committing an update that updates no rows against a master table for a single table fast refreshable materialized view results in the error above when the materialized view log on the master table is created with the COMMIT SCN option. I'm guessing that this isn't how things are supposed to work. Or am I missing something here? Anyone else encountered this before?
    Cheers.
    Edited by: Stain on Jan 25, 2013 1:27 PM

    Query Rewrite is an option for a Materialized View, not a Materialized View Log. Also, query rewrite is used as an optimization technique which "transforms a SQL statement expressed in terms of tables or views into a statement accessing one or more materialized views that are defined on the detail tables". I don't think it plays any role in the refresh path.
    Regardless, it made no difference.
    SQL> create materialized view mv_test_tbl
      2  refresh fast on commit
      3  ENABLE QUERY REWRITE
      4  as
      5  select test_id,
      6         test_name
      7  from   test_tbl
      8  ;
    Materialized view created.
    SQL> update test_tbl set test_name = 'hello' where test_id = 1000;
    0 rows updated.
    SQL> commit;
    commit
    ERROR at line 1:
    ORA-12008: error in materialized view refresh path
    ORA-01006: bind variable does not exist
    SQL>Edited by: Stain on Jan 25, 2013 2:06 PM

  • ORA-12008: error in materialized view refresh path in 10g

    Hi, all.
    The database is on 10gr2.
    I am testing materized view refresh.
    However, I got the following errors.
    exec dbms_refresh.refresh('"STGFAB"."MV_OPTION_TEST_HO1"');
    ORA-12008: error in materialized view refresh path
    ORA-01008: not all variables bound
    ORA-02063: preceding line from L8ZFAB
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2254
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2460
    ORA-06512: at "SYS.DBMS_IREFRESH", line 683
    ORA-06512: at "SYS.DBMS_REFRESH", line 195
    ORA-06512: at line 1
    Thanks in advance.
    Best Regards.

    Subject:      Materialized View Refresh Fails on Second Attempt With ORA-01008 'Not All Variables Bound' Error
         Doc ID:      Note:472261.1      Type:      
    --MM                                                                                                                                                                                                                                                                                                           

  • Materialed View Refresh Error ORA-12008: error in materialized view refresh

    Hi,
    I am trying to refersh the following materialized view with the below command and getting the below error
    begin
    DBMS_MVIEW.REFRESH('GLVW_MIS_ADB');
    end;
    The following error has occurred:
    ORA-12008: error in materialized view refresh path
    ORA-12840: cannot access a remote table after parallel/insert direct load txn
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 803
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 860
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 841
    ORA-06512: at line 2
    Please advice on this.
    Thanks & Regards,
    Kartik

    $ oerr ora 12840
    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.
    $                                                                   

  • Error: ORA-12008: error in materialized view refresh path

    Hello Dba' s
    We are on 12.0.6 EBS with 10.2.0.5 DB on Sun solaris SPARC 64 bit.
    We are getting below error while Refreshing Materialized View.
    Start of log messages from FND_FILE
    Error: ORA-12008: error in materialized view refresh path
    ORA-00600: internal error code, arguments: [kcblasm_1], [103], [], [], [], [], [], [] Occured while Refreshing Materialized View
    End of log messages from FND_FILE
    Not sure how to proceed.We have just upgraded our database from 10.2.0.3 to 10.2.0.5.
    Also we still have our test instance with 10.2.0.3 database ,there refreshing MV completed successfully.
    Also refreshing through TOAD gives below error:-
    BEGIN
    DBMS_SNAPSHOT.REFRESH(
    LIST => 'XXPPL.XXPPL_OPM_TRANSACTIONS_MV'
    ,PUSH_DEFERRED_RPC => TRUE
    ,REFRESH_AFTER_ERRORS => FALSE
    ,PURGE_OPTION => 1
    ,PARALLELISM => 0
    ,ATOMIC_REFRESH => TRUE
    ,NESTED => FALSE);
    END;
    Error at line 2
    ORA-12008: error in materialized view refresh path
    ORA-00600: internal error code, arguments: [kcblasm_1], [103], [], [], [], [], [], []
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2256
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2462
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2431
    ORA-06512: at line 2
    Please advice.
    Thanks,
    Edited by: user12209274 on Nov 23, 2010 2:10 AM

    thank you Justin,
    I found in my alertDB.log this line ;
    Mon Aug 20 03:00:54 2007
    ORA-01555 caused by SQL statement below (SQL ID: 64a7sdbbvknta, Query Duration=1021 sec, SCN: 0x0004.4a145344):
    Mon Aug 20 03:00:54 2007
    INSERT /*+ BYPASS_RECURSIVE_CHECK */ INTO "MANAGEMENT"."MVIEW_COMPUTERS"("ID","WINVERSION","ANTIVIRUS","GUID","INSTALLDT","CONNECTION_TYPE","GROUPID
    ","QUOVACOUNTRY") SELECT "C"."ID","C"."WINVERSION","C"."ANTIVIRUS","C"."GUID","C"."INSTALLDT","C"."CONNECTIONTYPE","C"."GROUPID","C"."QUOVACOUNTRY"
    FROM "MANAGEMENT"."COMPUTERS" "C"
    So i execute this query to found the TUNED_UNDORETENTION value ;
    SELECT *
    FROM V$UNDOSTAT v
    WHERE v.MAXQUERYID = '64a7sdbbvknta'
    and i have this result :
    BEGIN_TIME     20070820 02:53:42
    END_TIME     20070820 03:03:42
    UNDOTSN     1
    UNDOBLKS     51242
    TXNCOUNT     5012
    MAXQUERYLEN     1060
    MAXQUERYID     64a7sdbbvknta
    MAXCONCURRENCY     21
    UNXPSTEALCNT     0
    UNXPBLKRELCNT     0
    UNXPBLKREUCNT     0
    EXPSTEALCNT     14
    EXPBLKRELCNT     51392
    EXPBLKREUCNT     0
    SSOLDERRCNT     1
    NOSPACEERRCNT     0
    ACTIVEBLKS     606920
    UNEXPIREDBLKS     19896
    EXPIREDBLKS     612728
    TUNED_UNDORETENTION     1841
    I don't know exactly which value i should set my parameter?
    Message was edited by:
    HAGGAR

  • ORA-12008: error in materialized view refresh path

    Hi everyone,
    I'm getting a weird error when I try to do a fast refresh on my materialized view. My basic approach is simple, I got a MV log on my fact table with all the columns needed by the materialized view, sequence, rowid INCLUDING NEW VALUES.
    I've got my materialized view setup with a my summary level data, COUNT(*), and COUNT(EXP) for every SUM(EXP). I check the MV_CAPABILITIES_TABLE, and sure enough, it can be ran with fast refresh. I've got my fact table in schema USER1 and my materialized view in schema USER2.
    When I create the materialized view, there's no problem. If I immediately execute a fast refresh (EXEC DBMS_MVIEW.REFRESH('MY_MV','F'); ), again, no problem.
    However, if I run the ETLs which update the source fact table, and then I run the fast refresh again, I get the ORA-120008.
    But if I make the exact same MV in the USER1 schema, I have no problem doing fast refreshes. What's up with that? Does the table owner have to be the one with the materialized view? USER1 and USER2 are on the same DB and have the same table space. Does USER2 need any additional grants besides select on the source fact table? Do I need to grant select on the MVIEW log somehow?
    Thanks for the help!
    -Joe

    I just granted select on the base table. I assumed that since the MV log is attached to the table, that select on the table also gave select to the MV Log. But I've been wrong before.
    Is there some special syntax to grant on the MV Log?
    -Joe

  • Mview refresh and ORA-12008 error

    I am getting the following when I try to refresh a materialized view. This error occurs the first time I try to refresh, then if I try again, the refresh is successful.
    Most of what I have been able to glean about this error is that it is related to M$log changes, however, this view does not use nor build upon an other views that use, mview logs. Any ideas?
    ORA-12008: error in materialized view refresh path
    ORA-01555: snapshot too old: rollback segment number 13 with name "_SYSSMU13$" too small
    ORA-02063: preceding line from db1
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2537
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2743
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2712
    ORA-06512: at line 2

    Hi j_70!
    I'm not exactly sure about the answer, but I guess that the ORA-01555 is the main problem. Have you tried to grow your Undotablespace? I think that the refresh of the MVIEW takes a long time (like a long SELECT-Statement) and if there are many UPDATE and INSERT-Statements while the refresh is in progress than ORA-01555 may be the consequence.
    If you have Oracle 10g use the Undo-Advisor to look for the problem.
    Hope this helps!

  • ORA-12096: error in materialized view log

    Hi All,
    I had created a fast refresh materialized view. Log was also created.
    Now i dropped the mv and the logs.
    But now every time i update or insert into this customer table i get error message.
    ORA-12096: error in materialized view log on Customer
    ORA-00942: table or view does not exist
    There are entries in the DBA_MVIEW_LOGS for customer table.
    Please suggest.

    Hi,
    What database version are you on?
    And do you have access to Metalink/My Oracle Support?
    Found this, by the way:
    ORA-12096: error in materialized view log on <table>
    If problems occur when you try to access a log file for a materialized view, the system issues an ORA-12096 error message which is followed by the actual error. If the ORA-12096 error message is accompanied by an ORA-00942 message, the problem may be due to an online reorganization that was only partially undone. In this case, you can drop the log file for the materialized view manually (after you have verified that it is no longer required):
    DROP MATERIALIZED VIEW LOG ON <table>;
    Edited by: hoek on Jul 29, 2009 2:15 PM

  • ORA-12096: error in materialized view log on ORA-01301:insufficient privile

    Hi,
    One of our ebusiness Apps 11510 instances has database that was
    upgraded from 9.2.0.6 to 10.2.0.4 with Database Vault.
    After that, we are getting an error:
    ORA-12096: error in materialized view log on "SCHEMA"."TABLE_NAME" ORA-01301:insufficient privileges
    Can you please let know what can be the reason. Which user is being checked for the privileges?
    Regards

    I am facing the same issue in one of our internal instances.
    Apps Environment has been upgraded from Database 9.2.0.6 to Database 10.2.0.4 with Database Vault. We started facing this issue and the same error after the upgrade. MLOG definition has not changed.
    What privilege is it expecting to be present for the schema.
    The definition of the MLOG is as given below
    LOG_TRIGGER = NULL
    ROWIDS = YES
    PRIMARY_KEY = NO
    OBJECT_ID = NO
    FILTER_COLUMNS = NO
    SEQUENCE = NO
    INCLUDE_NEW_VALUES = NO

  • ORA-12096: error in materialized view log on a table

    Hi while updating a table getting below error
    ORA-12096: error in materialized view log on "FII"."FII_GL_JE_SUMMARY_B"
    What might be the problem.
    Thanks.

    might be table definition has changed, you may need to drop the mview log and recreate it.

  • ORA-12096 error in materialized view log on %s . %s

    Hi,
    I faced the peculiar error message "ORA-12096 error in materialized view log on ..." when trying to insert into a table. But .. there is not a materialized view log (none in the current schema nor in other users' schema).
    Note:I use OraDB10g v2
    Thanks ....a lot
    Sim

    Sim,
    NOthing relevant is coming up over metalink for the erorr. Some non-required results are coming but I dnt think that they are helpful. The most nearest to your error is this thread over google,
    http://translate.google.com/translate?hl=en&sl=zh-CN&u=http://blog.chinaunix.net/u/7121/showart_460192.html&sa=X&oi=translate&resnum=8&ct=result&prev=/search%3Fq%3DORA-12096%2Berror%2Bin%2Bmaterialized%2Bview%2Blog%2Bon%2BORA-00942%2Btable%2Bor%2Bview%2Bdoes%2Bnot%2Bexist....%26hl%3Den%26rls%3Dcom.microsoft:en-US:%26rlz%3D1I7GGLJ%26pwst%3D1
    It does talk abot the same thing, mview logs.
    Do let me know what you got.
    Cheers
    Aman....

  • ORA-12008: error in snapshot refresh path

    I am getting this error even i am specifying to use other rollback segment
    ALTER ROLLBACK SEGMENT R02 SHRINK;
    SET TRANSACTION USE ROLLBACK SEGMENT R02;
    alter materialized view PAY_REV_BREAKUPWITHWOFF NOLOGGING;
    BEGIN dbms_mview.refresh('PAY_REV_BREAKUPWITHWOFF') ; END;
    ERROR at line 1:
    ORA-12008: error in snapshot refresh path
    ORA-01562: failed to extend rollback segment number 1
    ORA-01628: max # extents (505) reached for rollback segment SYS_RBS
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 617
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 674
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 654
    ORA-06512: at line 1

    The reason why it's still using SYS_RBS seems to be that since you are refreshing a materialized view, it might be doing parallel DMLs. In this case the clause of specifying a particular rollback segment is ignored.
    In addition to the above, try taking the rollback segment offline by executing
    alter rollback segment SYS_RBS offline;
    and then drop it by running
    drop rollback segment SYS_RBS;
    Then create new one and see if it works.
    if the above mentioned doesn't work somehow...
    try to change the extents storage parameter by running
    alter rollback segment sys_rbs storage (MAXEXTENTS 1000);
    Can't be sure as i currently don't have access to my system
    Hope this helps
    Message was edited by:
    thrilller

  • ORA-00911 error creating a view with PL/SQL

    Hello. Working with SQL Developer, I'm trying to write a procedure that creates a view.
    After a successful compilation, each time I try to execute it I get an ORA-00911 error and I'm not able to find the reason.
    Here's my code. Thanks in advance.
      CREATE OR REPLACE PROCEDURE "DWH_STAR"."STORICO_DATA" (
      DATA_INPUT IN VARCHAR2
    )AS
    BEGIN
      EXECUTE IMMEDIATE '
        CREATE OR REPLACE FORCE VIEW DWH_STAR.V_PORT_STOR_DATA (DATA_DESC, CLIENTE_KEY, PRODOTTO_KEY, AGENTE_KEY, TIPOLOGIA_KEY,
        NUM_ORDINE, NUM_UNITA, RICAVO_LORDO, RICAVO_NETTO, COSTO_STD_TOTALE, GROSS_PROFIT) AS
        SELECT
          dt.DATA_DESC,
          fv.CLIENTE_KEY,
          fv.PRODOTTO_KEY,
          fv.AGENTE_KEY,
          fv.TIPOLOGIA_KEY,
          fv.NUM_ORDINE,
          SUM (NUM_UNITA) NUM_UNITA,
          SUM (RICAVO_LORDO) RICAVO_LORDO,
          SUM (RICAVO_NETTO) RICAVO_NETTO,
          SUM (COSTO_STD_TOTALE) COSTO_STD_TOTALE,
          SUM (GROSS_PROFIT) GROSS_PROFIT
        FROM
          F_VENDUTO fv, D_TEMPO dt
        WHERE
          fv.TEMPO_KEY = dt.TEMPO_KEY
          AND TO_NUMBER(TO_CHAR(dt.DATA_DESC,''YYYYMMDD'')) <=' || DATA_INPUT ||'
        GROUP BY
          fv.CLIENTE_KEY,
          fv.PRODOTTO_KEY,
          fv.AGENTE_KEY,
          fv.TIPOLOGIA_KEY,
          fv.NUM_ORDINE,
          dt.DATA_DESC
        ORDER BY
          dt.DATA_DESC,
          fv.CLIENTE_KEY,
          fv.PRODOTTO_KEY,
          fv.AGENTE_KEY,
          fv.TIPOLOGIA_KEY,
          fv.NUM_ORDINE;
        UNION
        SELECT
          dt.DATA_DESC,
          fs.CLIENTE_KEY,
          fs.PRODOTTO_KEY,
          fs.AGENTE_KEY,
          fs.TIPOLOGIA_KEY,
          fs.NUM_ORDINE,
          - SUM (NUM_UNITA) NUM_UNITA,
          - SUM (RICAVO_LORDO) RICAVO_LORDO,
          - SUM (RICAVO_NETTO) RICAVO_NETTO,
          - SUM (COSTO_STD_TOTALE) COSTO_STD_TOTALE,
          - SUM (GROSSO_PROFIT) GROSS_PROFIT
        FROM
          F_SPEDITO fs, D_TEMPO dt
        WHERE
          (fs.CAUSA_RESO_KEY = 0
           AND fs.TEMPO_KEY = dt.TEMPO_KEY
           AND TO_NUMBER(TO_CHAR(dt.DATA_DESC,''YYYYMMDD'')) <=' || DATA_INPUT ||'
        GROUP BY
          fs.CLIENTE_KEY,
          fs.PRODOTTO_KEY,
          fs.AGENTE_KEY,
          fs.TIPOLOGIA_KEY,
          fs.NUM_ORDINE,
          dt.DATA_DESC
        ORDER BY
          dt.DATA_DESC,
          fs.CLIENTE_KEY,
          fs.PRODOTTO_KEY,
          fs.AGENTE_KEY,
          fs.TIPOLOGIA_KEY,
          fs.NUM_ORDINE
    END;

    remove the order by and semi-colon (;) from the first select. I hope you know that union operator needs the same set of columns to be selected.
    But try avoid creating objects on the fly unless and until it's absolutely necessary and unavoidable.
    Regards
    Raj
    Edited by: R.Subramanian on Jun 21, 2010 7:52 AM
    Edited by: R.Subramanian on Jun 21, 2010 7:53 AM

Maybe you are looking for

  • Dead Hard Drive - What replacement can I use for iBook G4?

    I have a Machine Model: iBook G4 CPU Type: PowerPC G4 (3.3) Number Of CPUs: 1 CPU Speed: 933 MHz L2 Cache (per CPU): 256 KB Memory: 384 MB (Upgraded to 1Gig) Bus Speed: 133 MHz Mac OSX 10.3.9. The hard drive died. What type and manufacrure do I need.

  • Access to view blocking sessions in sql server 2008

    Hi, One of my client wrote a stored procedure. we scheduled this SP in a job. while job is running, it is blocking other sessions. It is happening frequently. So, client is asking me to grant permission to view blocking session( want to execute sp_wh

  • How to put documents in portal

    Dear Friends, I have an issue like, our client having some help documents, that they want to put in portal through worksets (role base access). help me Regards Suresh

  • Varchar2 Data type modification to BLOB

    I am trying to change a VARCHAR2(20) data type into a BLOB. I have researched the web and found what I thought was the solution. That was to create a new Temp column that was a BLOB data type which I did, UPDATE the information from the column I what

  • Conf Control Key

    Hi Experts I have a requirement to implement Conf Control key in only one of the Plant. What are all the factors to be considered before going for it ? What are all the Impacts of it ?