Syntax help needed in update using 'WITH' Clause

Update     CP_JP_CORP_FSASA_FEEDUPLOAD_r r
                         set     (
                               gfrn,                              
                               tenor_code,
                               tenor_description,
                               exposure_category,          
                               frr,          
                               facility_classification,
                               limit_amount,
                               limit_usd,
                               approval_ccy,
                               approval_date,
                               expiry_date,
                               avail_status_code,
                               avail_status_desc,
                               revolving_indicator,
                               committed_flag,
                               committed_until_date,
                               committed_amount,
                               advised_flag,
                               advised_amount,
                               facility_long_description,
                               booking_unit_code,
                               extending_unit_code,
                               extending_unit_short_desc,
                               approving_unit_code,
                               approving_unit_short_des,
                               transaction_type,
                               branch_no
                               =
                                        With t as
                                             Select     fac.gfrn,fac.tenor_code,fac.tenor_description,fac.exposure_category,fac.frr,
                                                  fac.facility_classification,fac.limit_amount,fac.limit_usd,fac.approval_ccy,
                                                  fac.approval_date,fac.expiry_date,fac.avail_status_code,fac.avail_status_desc,
                                                  fac.revolving_indicator,fac.committed_flag,fac.committed_until_date,fac.committed_amount,
                                                  fac.advised_flag,fac.advised_amount,fac.facility_long_description,fac.booking_unit_code,
                                                  fac.extending_unit_code,fac.extending_unit_short_desc,fac.approving_unit_code,fac.approving_unit_short_des,
                                                  /*'Check' normalflag,
                                                  cust.adjusted_orr fsasaorr1stborrower,
                                                  'Normal' category1stborrower,
                                                  cust.adjusted_orr fsasaorr2ndborrower,
                                                  'Normal' category2ndborrower,
                                                  cust.adjusted_orr fsasaorrfinal,
                                                  'Normal' categoryfinal */
                                                  txn.transaction_type,txn.branch_no,txn.gfcid,txn.transaction_id
                                             from     cp_fsa_boj_corp_cr_fac_hist fac,
                                                       --cp_fsa_boj_corp_cr_cust_hist cust,
                                                       cp_fsa_boj_corp_cr_txn_hist txn
                                             where     fac.gfcid = txn.gfcid
                                                       and fac.facility_id = txn.facility_id
                                                       and fac.as_of_date = txn.as_of_date
                                                       and to_char(fac.as_of_date,'yyyymm') = p_financial_period
                                                       and fac.as_of_date = last_day(fac.as_of_date)
                                        select      t.gfrn,
                                                  t.tenor_code,
                                                  t.tenor_description,
                                                  t.exposure_category,
                                                  t.frr,
                                                  t.facility_classification,
                                                  t.limit_amount,
                                                  t.limit_usd,                                             
                                                  t.approval_ccy,                                             
                                                  t.approval_date,                                             
                                                  t.expiry_date,                                             
                                                  t.avail_status_code,                                             
                                                  t.avail_status_desc,                                             
                                                  t.revolving_indicator,                                             
                                                  t.committed_flag,                                             
                                                  t.committed_until_date,                                             
                                                  t.committed_amount,                                             
                                                  t.advised_flag,                                             
                                                  t.advised_amount,                                             
                                                  t.facility_long_description                                             
                                                  t.booking_unit_code,                                             
                                                  t.extending_unit_code,                                             
                                                  t.extending_unit_short_desc,                                        
                                                  t.approving_unit_code,                                             
                                                  t.approving_unit_short_des,                                             
                                                  t.transaction_type,
                                                  t.branch_no
                                        from     t
                                   where      r.financialperiod           = p_financial_period
                                             and exists
                                                       Select     1
                                                       from     t
                                                       where     t.transaction_id = r.ce_trans_id
                                                  )I'm facing syntax problem

Hii All,
This is my actual update.(I stopped performing dml operations in cursors following Karthick Arp) :-)
Update     CP_JP_CORP_FSASA_FEEDUPLOAD_r r
                         set     (
                               gfrn,                              
                               tenor_code,
                               tenor_description,
                               exposure_category,          
                               frr,          
                               facility_classification,
                               limit_amount,
                               limit_usd,
                               approval_ccy,
                               approval_date,
                               expiry_date,
                               avail_status_code,
                               avail_status_desc,
                               revolving_indicator,
                               committed_flag,
                               committed_until_date,
                               committed_amount,
                               advised_flag,
                               advised_amount,
                               facility_long_description,
                               booking_unit_code,
                               extending_unit_code,
                               extending_unit_short_desc,
                               approving_unit_code,
                               approving_unit_short_des,
                               transaction_type,
                               branch_no
                               = (          
                                   Select     fac.gfrn,fac.tenor_code,fac.tenor_description,fac.exposure_category,fac.frr,
                                        fac.facility_classification,fac.limit_amount,fac.limit_usd,fac.approval_ccy,
                                        fac.approval_date,fac.expiry_date,fac.avail_status_code,fac.avail_status_desc,
                                        fac.revolving_indicator,fac.committed_flag,fac.committed_until_date,fac.committed_amount,
                                        fac.advised_flag,fac.advised_amount,fac.facility_long_description,fac.booking_unit_code,
                                        fac.extending_unit_code,fac.extending_unit_short_desc,fac.approving_unit_code,fac.approving_unit_short_des,
                                        txn.transaction_type,txn.branch_no
                                   from     cp_fsa_boj_corp_cr_fac_hist fac,
                                             --cp_fsa_boj_corp_cr_cust_hist cust,
                                             cp_fsa_boj_corp_cr_txn_hist txn
                                   where     fac.gfcid = txn.gfcid
                                             and fac.facility_id = txn.facility_id
                                             and fac.as_of_date = txn.as_of_date
                                             and to_char(fac.as_of_date,'yyyymm') = p_financial_period
                                             and fac.as_of_date = last_day(fac.as_of_date)
                         where Exists
                                             Select     1
                                             from     cp_fsa_boj_corp_cr_fac_hist fac,
                                                       cp_fsa_boj_corp_cr_txn_hist txn
                                             where     fac.gfcid = txn.gfcid
                                                       and fac.facility_id = txn.facility_id
                                                       and fac.as_of_date = txn.as_of_date
                                                       and to_char(fac.as_of_date,'yyyymm') = p_financial_period
                                                       and fac.as_of_date = last_day(fac.as_of_date)
                                                       and txn.transaction_id = r.ce_trans_id
                                        )Now in my update I'm using same 'SELECT' twice once in 'SET' and again in 'EXISTS' clause. I'd like to make use of 'WITH' Clause and avoid unnecessary 'SELECT' . Please help me.

Similar Messages

  • Need help using WITH clause

    I have an update statement that is using the same suquery twice.
    I am not usre if WITh clause be used in update statements?
    Is there a way the below statement can be modified to use WITH clause?
    UPDATE EMP_TRACKING_LIST L
    SET ACTIVE_FLAG = DECODE((SELECT COUNT(*)
    FROM EMP_TRACKING_LIST L2
    WHERE L.NAME = L2.NAME AND
    L.EMP_CODE = L2.EMP_CODE AND
    L2.EMP_FLAG = 'Y'), 0, 'N', 'Y')
    WHERE ACTIVE_FLAG != DECODE((SELECT COUNT(*)
    FROM EMP_TRACKING_LIST L2
    WHERE L.NAME = L2.NAME AND
    L.EMP_CODE = L2.EMP_CODE AND
    L2.EMP_ACTIVE_FLAG = 'Y'), 0, 'N', 'Y')
    OR EMP_ACTIVE_FLAG IS NULL;
    I would really appreciate your input
    Edited by: user10937534 on Sep 2, 2009 4:47 PM

    Hi,
    WITH comes immediately before SELECT, not before UPDATE.
    To use WITH in an UPDATE statement, you would say something like:
    UPDATE  EMP_TRACKING_LIST  L
    SET     ACTIVE_FLAG =
            WITH  sub_q  AS
                SELECT  ...
            SELECT  ...
            FROM    sub_q  ...
    ;I don't think there's any way to use values from the sub-query in the WHERE clause of the UPDATE statement itself; MERGE is a much better bet for eliminating redundancy there.
    Sorry, I'm not at a database now, so I can test anything.

  • Help needed I updated my ipad2 with iOS5 but few of my dashbaords are not working now can any one let me know how to downgrade the OS

    Help needed I updated my ipad2 with iOS5 but few of my dashbaords (HTML5) are not working now ,can any one let me know how to downgrade the OS as we have a meeting coming up .. its urgent

    Downgrading the iOS is not supported. If you are using Safari this try clearing its cache via Settings > Safari.
    If that doesn't work then try closing Safari completely and then re-open it : from the home screen (i.e. not with Safari 'open' on-screen) double-click the home button to bring up the taskbar, then press and hold any of the apps on the taskbar for a couple of seconds or so until they start shaking, then press the '-' in the top left of the Safari app to close it, and touch any part of the screen above the taskbar so as to stop the shaking and close the taskbar.
    A third option is a reset : press and hold both the sleep and home buttons for about 10 to 15 seconds (ignore the red slider), after which the Apple logo should appear - you won't lose any content, it's the iPad equivalent of a reboot.

  • 'Missing select' error for update statement using WITH clause

    Hi,
    I am getting the below error for update statement using WITH clause
    SQL Error: ORA-00928: missing SELECT keyword
      UPDATE A
      set A.col1 = 'val1'
         where
      A.col2 IN (
      WITH D AS
      SELECT col2 FROM
      (SELECT col2, MIN(datecol) col3 FROM DS
      WHERE <conditions>
        GROUP BY PATIENT) D2
      WHERE
      <conditions on A.col4 and D2.col3>

    Hi,
    The format of a query using WITH is:
    WITH  d  AS
        SELECT  ...  -- sub_query
    SELECT  ...   -- main query
    You don't have a main query.  The keyword FROM has to come immediately after the right ')' that ends the last WITH clause sub-query.
    That explains the problem based on what you posted.  I can't tell if the real problem is in the conditions that you didn't post.
    I hope this answers your question.
    If not, post a complete test script that people can run to re-create the problem and test their ideas.  Include a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables involved, and the results you want from that data.
    In the case of a DML operation (such as UPDATE) the sample data should show what the tables are like before the DML, and the results will be the contents of the changed table(s) after the DML.
    Explain, using specific examples, how you get those results from that data.
    Always say what version of Oracle you're using (e.g. 11.2.0.2.0).
    See the forum FAQ: https://forums.oracle.com/message/9362002

  • How to use "with clause query" in DBadapter

    Hi all,
    I need to implement a "with clause" query in oracle soa 11g bpel. When i put the query in db adapter in pure sql, the schema is not getting generated properly. Can any one suggest a solution to my problem.
    Regards,
    Kaushik

    Pure SQL won't work because it is expecting the first word in the SQL to be SELECT (or INSERT,UPDATE,DELETE).
    If your query is WITH ... SELECT ...
    try this:
    delete everything before SELECT. Copy and paste the generated XSD to another window. The SQL test may fail, but that will just mean that it couldn't fill in the types of the columns in the SELECT ... FROM list. You can always do that yourself by hand editing the XSD (including in the wizard before you hit next). Then put back the WITH ... clause before the remaining SELECT .... If the XSD gets overwritten, copy the version you saved in the other window and paste it over top. Then hit next and the runtime should still work.
    Keep in mind that SQL is very complex and hard to fully parse in the UI. However the minimum information the DbAdapter needs is quite limited; basically just the name and number of columns that are coming back. The XSD is meant to be editable in the wizard if the SQL is too complex.
    Thanks
    Steve

  • Construct a Sql block using With Clause to improve the performance

    I have got four diff parametrized cursor in my Pl/Sql Procedure. As the performance of the Procedure is very pathetic,so i have been asked to tune the Select statements used in those cursors.
    So I am trying to use the With Clause in order to club all those four Select Statements.
    I would appreciate if anybody can help me to construct the Sql Block using With Clause.
    My DB version is..
    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
    PL/SQL Release 11.1.0.7.0 - Production
    Four Diff cursors are defined below.
    CURSOR all_iss (
          b_batch_end_date   IN   TIMESTAMP,
       IS
          SELECT isb.*
                FROM IMPLMN_STEP_BREKPN  isb
               , ISSUE iss
          WHERE isb.issue_id = iss.issue_id
           AND iss.issue_status_id  =  50738
           AND ewo_no IN
          (SELECT TO_CHAR(wo_no)
            FROM MGO_PLANT_AUDIT
           WHERE dml_status = 'U' OR dml_status = 'I')
          UNION ALL
          SELECT isb.*
           FROM IMPLMN_STEP_BREKPN  isb
            , ISSUE iss
           WHERE isb.issue_id = iss.issue_id
           AND iss.issue_status_id  =  50738
           AND CAST (isb.last_updt_timstm AS TIMESTAMP) >=
                                                                  b_batch_end_date;
          CURSOR ewo_plant  ( p_ewo_no IN  IMPLMN_STEP_BREKPN.ewo_no%TYPE)
          IS
          SELECT DISTINCT wo_no ,
          plant_code
          FROM MGO_PLANT
          WHERE TO_CHAR(wo_no) = p_ewo_no;
          CURSOR iss_ewo_plnt (
          p_issue_id IN IMPLMN_STEP_BREKPN.issue_id%TYPE ,
          p_ewo_no IN IMPLMN_STEP_BREKPN.EWO_NO%TYPE,
          p_plnt_code IN IMPLMN_STEP_BREKPN.PLT_FACLTY_ID%TYPE)
          IS
          SELECT *
          FROM IMPLMN_STEP_BREKPN
          WHERE issue_id = p_issue_id
          AND ewo_no = p_ewo_no
          AND
          (plt_faclty_id = p_plnt_code
          OR
          plt_faclty_id IS NULL);
          CURSOR iss_ewo_plnt_count (
          p_issue_id IN IMPLMN_STEP_BREKPN.issue_id%TYPE ,
          p_ewo_no IN IMPLMN_STEP_BREKPN.EWO_NO%TYPE,
          p_plnt_code IN IMPLMN_STEP_BREKPN.PLT_FACLTY_ID%TYPE)
          IS
          SELECT COUNT(*)
          FROM IMPLMN_STEP_BREKPN
          WHERE issue_id = p_issue_id
          AND ewo_no = p_ewo_no
          AND
          (plt_faclty_id = p_plnt_code
          OR
          plt_faclty_id IS NULL);

    Not tested. Some thing like below. i just made the queries as tables and given name as a,b,c and substituted columns for the parameters used in the 2nd cursor and third cursor. Try like this.
    CURSOR all_iss (
    b_batch_end_date IN TIMESTAMP,
    IS
    select a.*,b.*,c.* from
    ( SELECT isb.*
    FROM IMPLMN_STEP_BREKPN isb
    , ISSUE iss
    WHERE isb.issue_id = iss.issue_id
    AND iss.issue_status_id = 50738
    AND ewo_no IN
    (SELECT TO_CHAR(wo_no)
    FROM MGO_PLANT_AUDIT
    WHERE dml_status = 'U' OR dml_status = 'I')
    UNION ALL
    SELECT isb.*
    FROM IMPLMN_STEP_BREKPN isb
    , ISSUE iss
    WHERE isb.issue_id = iss.issue_id
    AND iss.issue_status_id = 50738
    AND CAST (isb.last_updt_timstm AS TIMESTAMP) >=
    b_batch_end_date) a,
    ( SELECT DISTINCT wo_no ,
    plant_code
    FROM MGO_PLANT
    WHERE TO_CHAR(wo_no) = p_ewo_no) b,
    ( SELECT *
    FROM IMPLMN_STEP_BREKPN
    WHERE issue_id = p_issue_id
    AND ewo_no = p_ewo_no
    plt_faclty_id IS NULL) c
    where b.wo_no = c.ewo_no and
    c.issue_id = a.issue_id ;
    vinodh
    Edited by: Vinodh2 on Jul 11, 2010 12:03 PM

  • Help needed in tibco Configuration with OAS 10.1.3

    Hi,
    I am trying to using OAS 10.1.3 and with Tibco JMS Provider. I have deployed the MDB that gets messages from Tibco JMS Provider. Now here is the issue I am getting the following errors any ideas on what might be wrong:
    WARNING: Code-source C:\Oracle_Software\AS10g\1013\oc4j_extended_101320_sa\j2ee\
    home\lib\tibco\jms.jar (from <library> in /C:/Oracle_Software/AS10g/1013/oc4j_ex
    tended_101320_sa/j2ee/home/config/application.xml) has the same filename but is
    not identical to /C:/Oracle_Software/AS10g/1013/oc4j_extended_101320_sa/j2ee/hom
    e/lib/jms.jar (from <code-source> (ignore manifest Class-Path) in META-INF/boot.
    xml in C:\Oracle_Software\AS10g\1013\oc4j_extended_101320_sa\j2ee\home\oc4j.jar)
    . If it contains different versions of the same classes, it will be masked as th
    e latter is already visible in the search path of loader default.root:0.0.0.
    2007-05-07 22:36:01.055 WARNING J2EE JNDI-00002 Resource reference jms/myQueueCo
    nnectionFactory not found. Allowing J2EEContext creation to continue anyway.
    2007-05-07 22:36:01.087 WARNING J2EE JNDI-00004 No javax.jms.QueueConnectionFact
    ory found at java:comp/resource/TibcoJMSReference/QueueConnectionFactories/myQCF
    07/05/07 22:36:05 Oracle Containers for J2EE 10g (10.1.3.2.0) initialized
    2007-05-07 22:36:06.055 WARNING J2EE EJB-02009 [ejb1:ejb1:EnableMdb] Unexpected
    exception by JMS provider: javax.jms.InvalidDestinationException: Destination "Q
    ueue[enableQueue]" has invalid type "class com.tibco.tibjms.naming.TibjmsFederat
    edQueue" and cannot be used with OC4J JMS..
    2007-05-07 22:36:06.055 WARNING J2EE EJB-02009 [ejb1:ejb1:EnableMdb] Unexpected
    exception by JMS provider: javax.jms.InvalidDestinationException: Destination "Q
    ueue[enableQueue]" has invalid type "class com.tibco.tibjms.naming.TibjmsFederat
    edQueue" and cannot be used with OC4J JMS..
    2007-05-07 22:36:06.055 WARNING J2EE EJB-02009 [ejb1:ejb1:EnableMdb] Unexpected
    exception by JMS provider: javax.jms.InvalidDestinationException: Destination "Q
    ueue[enableQueue]" has invalid type "class com.tibco.tibjms.naming.TibjmsFederat
    edQueue" and cannot be used with OC4J JMS..
    2007-05-07 22:36:06.055 WARNING J2EE EJB-02009 [ejb1:ejb1:EnableMdb] Unexpected
    exception by JMS provider: javax.jms.InvalidDestinationException: Destination "Q
    ueue[enableQueue]" has invalid type "class com.tibco.tibjms.naming.TibjmsFederat
    edQueue" and cannot be used with OC4J JMS..
    2007-05-07 22:36:06.055 WARNING J2EE EJB-02009 [ejb1:ejb1:EnableMdb] Unexpected
    exception by JMS provider: javax.jms.InvalidDestinationException: Destination "Q
    ueue[enableQueue]" has invalid type "class com.tibco.tibjms.naming.TibjmsFederat
    edQueue" and cannot be used with OC4J JMS..
    2007-05-07 22:36:06.071 WARNING J2EE EJB-02014 [ejb1:ejb1:EnableMdb] All message
    consumer threads have terminated due to provider errors, stopping MDB.
    Any help is appreciated. Can someone please provide me the steps to configure OC4J with Tibco incase I am doing something wrong I know there is a document out there http://www.oracle.com/technology/tech/java/oc4j/1013/how_to/how-to-connect-to-tibco/doc/how-to-connect-to-tibco.html but somehow I tried following exactly what is listed in the document but it doesn't seems to work for me. Specially the following
    deploying the resource adapter module (e.g., using admin.jar's "-deployconnector" command),
    placing the <connector> element in the %ORACLE_HOME%/j2ee/home/config/oc4j-connectors.xml.xml file, and
    pointing to the %ORACLE_HOME%/j2ee/home/config/oc4j-connectors.xml.xml file by placing a <connectors> element in the %ORACLE_HOME%/j2ee/home/config/application.xml file
    Where do I make the changes in the sample for my needs if I have the following on Tibco side:
    Initial context factory:
    com.test.TestTibcoInitialContext
    Provider url
    ldap://someserver:389/ou=msg,dc=corp,dc=com
    Destination(Queue):
    testClientDestUD=D.TEST
    Connection Factory
    testClientUD=S.VV
    Thanks for any help as I am bit confused going thru the doc.

    Hi Alastair,
    Thank you so much for this really very very helpful document but still I am facing some issues:
    1.     The pdf file is specific to Linux environment while I have windows environment for:
    Oracle Application Server 10.1.3.x
    OBIEE Server 10.1.3.4
    2.     We are using MS Active Directory for the domain login authentication process. I have configured the OBIEE with that Active directory to allow users to use their domain credentials to login to OBIEE. I need to provide the SSO in this environment. But the document provides very good and elaborated information about SSO using OID. Is there any way we can do SSO using MS AD or we have to import the users in OID?
    3.     We are using a db table for the authorization process for users after authentication is passed in which we are storing the USER NAME and GROUP information. The Authorization block of rpd select the corresponding GROUP from this table using SQL query and authorizes the users for their access scope. I was trying to execute the function AD_Authorization using the sql supplied after creating it in db but it is showing the below error: (Oracle11gR2 DB Server)
    SELECT getldapgroups('domainname\username') FROM dual;
    ORA-31202: DBMS_LDAP: LDAP client/server error: Invalid DN syntax. 0000208F: LdapErr: DSID-0C090654, comment: Error processing name, data 0, vece
    ORA-06512: at "SYS.DBMS_SYS_ERROR", line 86
    ORA-06512: at "SYS.DBMS_LDAP", line 1487
    ORA-06512: at "SYS.DBMS_LDAP", line 234
    ORA-06512: at "SCHEMA.GETLDAPGROUPS", line 45
    4.     Can we install OIM on Windows machine having the Oracle DB server installed already on it?
    Your valuable response will be much awaited.
    Thanks,

  • Using WITH clause in PLSQL

    Hi all,
    I am getting ORA-00928 error [missing SELECT statement] when running below statement.
    Is 'WITH' clause allow in PLSQL?
    -- Created on 26/12/2007
    declare
      -- Local variables here
      i integer;
    begin
      -- Test statements here
       WITH x AS (
                   SELECT /*+materialize*/ *
          FROM ALL_OBJECTS
                   WHERE LAST_DDL_TIME > SYSDATE-1
        INSERT INTO tmp1
              SELECT *
        FROM x;
    end;

    wrong syntax, you need this....
    ME_XE?create table tmp1 as select * from all_objects where 1=0;
    Table created.
    Elapsed: 00:00:00.21
    ME_XE?create table x as select * from all_objects where rownum < 10;
    Table created.
    Elapsed: 00:00:00.51
    ME_XE?declare
    2 -- Local variables here
    3 i integer;
    4 begin
    5 INSERT INTO tmp1
    6 WITH x AS (
    7 SELECT /*+materialize*/ *
    8 FROM ALL_OBJECTS
    9 WHERE LAST_DDL_TIME > SYSDATE-1
    10 )
    11 SELECT *
    12 FROM x;
    13 end;
    14 /
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.15
    ME_XE?

  • Using WITH clause in Pro*Cobol

    Hi!
    I am trying to improve the performance of a query by introducing WITH clause.
    The query is in Pro*Cobol Release 9.2.0.6.0 - Production.
    I got compilation error
    WITH DPTCOST AS (
    ...............1
    PCB-S-00400, Encountered the symbol "DPTCOST" when expecting one of the following:
    END-EXEC
    ....continued
    So I wonder if we could use that clause at all with Pro*Cobol
    Here is the excerp of the code
    EXEC SQL
    DECLARE INPUT_ACTUAL CURSOR FOR
    WITH DPTCOST AS (
    SELECT /*+ rule */
    A.CODE_COMBINATION_ID,
    A.SEGMENT1, A.SEGMENT2, A.SEGMENT3,
    A.SEGMENT6,
    D.COSTING, D.PROCESS,
    D.MTL_CODE, D.FACTOR
    FROM
    GL_CODE_COMBINATION A,
    ALCGL_DEPARTMENT_COSTINGS D
    WHERE
    A.TEMPLATE_ID IS NULL
    AND A.SUMMARY_FLAG <> 'Y'
    AND A.SEGMENT1 = D.PLANT_NUMBER
    AND A.SEGMENT3 <> '6999001'
    AND A.SEGMENT3 <> '6999002'
    AND SUBSTR(A.SEGMENT2,4,3) = D.DEPARTMENT
    AND D.ACTUAL_FLAG = 'A'
    ) ... continued

    Materialized views are basically stored query results. They offer advanced functionality like query rewrite, refresh on commit, and more;
    http://download-west.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_6002.htm
    Unlike a view, they actually store the results of the query - not just the query;
    SQL> create table t (cid number primary key)
    Table created.
    SQL> insert into t select object_id from dba_objects where object_id is not null
    12791 rows created.
    SQL> create materialized view mv
       as select * from t
    Snapshot created.
    SQL> select object_name, object_type from user_objects where object_name ='MV'
    OBJECT_NAME                    OBJECT_TYPE       
    MV                             TABLE             
    MV                             MATERIALIZED VIEW 
    2 rows selected.
    SQL> select segment_name, bytes from user_segments where segment_name in ('T', 'MV')
    SEGMENT_NAME                        BYTES
    T                                  196608
    MV                                 196608
    2 rows selected.Temporary tables are simply tables that are created then dropped. GLOBAL TEMPORARY TABLES have the advantage (or disadvantage) of only existing until commit or the end of the session. They results are visible to the user that inserted the data - but only temporarily;
    http://download-west.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_7002.htm#sthref7483

  • Using with clause

    I am using the sql with following construct , the explain plan doesn't show that index on col1 of tab1 (used in with clause) as used- it just shows a full table access of a view (system) - result set of query in with clause.
    1. Is it that oracle will not use that index or it doesn't show up
    2. If so then is it good to have that table in join of all the three sqls that i am doing union - atleast in that case the index on col1 gets used (per explain plan).
    with sql1 ( select * from tab1 where col1 = 'y')
    select col_gen
    from tab2 a, sql1 b
    where a.col3 = b.col3
    union
    select col_gen
    from tab3 a, sql1 b
    where a.col3 = b.col4
    Union
    select col_gen
    from tab4 a, sql1 b
    where a.col3 = b.col4

    WITH tab1 AS ( SELECT * FROM tab12 WHERE SESSION_ID = '12')
    SELECT DISTINCT b.unit_key unit_key ,NULL colabc1_KEY ,NULL colabc3_KEY,a.col3_ID
    FROM tab1_col31_MAP a, tab1 b
    WHERE a.unit_id = b.unit_id
    UNION
    SELECT DISTINCT NULL unit_key ,b.colabc1_KEY colabc1_KEY,NULL colabc3_KEY,a.col3_ID
    FROM tab2_col32_MAP a,tab1 b
    WHERE a.colabc1_id = b.colabc1_id
    UNION
    SELECT DISTINCT NULL unit_key,NULL colabc2_KEY,b.colabc3_KEY colabc3_KEY,a.col3_ID
    FROM tab1_col33 a, tab1 b
    WHERE a.colabc3_id = b.colabc3_id
    Operation     Object Name     Rows     Bytes     Cost     Object Node     In/Out     PStart     PStop
    SELECT STATEMENT Optimizer Mode=CHOOSE                                        
    RECURSIVE EXECUTION     SYS_LE_2_0                                   
    TEMP TABLE TRANSFORMATION                                        
    SORT UNIQUE                                        
    UNION-ALL                                        
    NESTED LOOPS                                        
    VIEW                                        
    TABLE ACCESS FULL     SYS_TEMP_0FD9D6603_53EE226                                   
    INDEX RANGE SCAN     SYS_C00133240                                   
    NESTED LOOPS                                        
    VIEW                                        
    TABLE ACCESS FULL     SYS_TEMP_0FD9D6603_53EE226                                   
    INDEX RANGE SCAN     SYS_C00133205                                   
    NESTED LOOPS                                        
    VIEW                                        
    TABLE ACCESS FULL     SYS_TEMP_0FD9D6603_53EE226                                   
    INDEX RANGE SCAN     SYS_C00133202                                   
    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    SELECT * FROM tab12 WHERE SESSION_ID = '12'
    Operation     Object Name     Rows     Bytes     Cost     Object Node     In/Out     PStart     PStop
    SELECT STATEMENT Optimizer Mode=CHOOSE                                        
    TABLE ACCESS BY INDEX ROWID     tab12                                   
    INDEX RANGE SCAN     IDX     
    Will the temp table transformation use the index used in the query above (ie. IDX)

  • Using full outer join of subqueries named using with clause

    Hi,
    I am trying to create a view which is having 2 subqueries vol1 & vol2 with WITH clause. I am joining those 2 subqueries in the main query with FULL OUTER JOIN.
    When i compile that view in a tool like pl/sql developer, It has been compiled successfully.
    But when i call the view creation script from SQL command prompt, It is throwing error as
    from vol1 FULL JOIN vol2 o ON (vol1.ct_reference = vol2.ct_reference and vol1.table_name = vol2.table_name
    ERROR at line 29:
    ORA-00942: table or view does not exist
    Kindly advise whats going wrong.

    that's line 29. Maybe you get a better idea if you strip your operation of all the unneccessary elements until it works.
    There are some known bugs with subquery factoring (aka with clause) and also with ANSI join syntax, but it is hard to tell what happens here based on your description. But one thing is strange - if it is not a result of formatting (not formatting): I would expect the asterisk beneath the unknown table and not beneath the key word FULL.
    P.S.: my editor makes me think it's rather a proportional font thing. Have I already said that I don't like proportional font for SQL code examples?

  • Parallel Execution of  Sub Queries using WITH clause ?

    Hi ,
    For the below query is it that Oracle Optimizer executes "sum_data" and "avg_data" queries parallely ?
    WITH sum_data AS
    SELECT deptno, sum(sal) AS S FROM emp GROUP BY deptno ),
    avg_data AS
    SELECT deptno, avg(sal) AS A FROM emp GROUP BY deptno )
    SELECT sum_data.deptno, s, a, s / a FROM sum_data , avg_data
    WHERE sum_data.deptno = avg_data.deptno
    ORDER BY sum_data.deptno
    THANKS

    No, it doesn't.
    You can add the parallel hint to each query itsel to speed up the exuction of a given query. But the WITH clause has nothing to do with parallel, it only uses temp or memory to keep the data being processed and thus speeds up the performance.
    Edited by: DimaK on Feb 25, 2011 10:42 AM

  • Help me to update table with condition's

    this table is an alert table which will update when the sql server down , not pinging and drive space low.
    Every 15 mins the monitoring system run. if the any issue came then it will update the information in this table. if  the issue not solved by 15 mins the table will update again with the same details.. 
    I would like update tickeraised = Y  only on first time and  if i got same issue less then 30 min the it should not change to Y..  based on server name , type and message. 
    min >10 and <20 min if any value is there then the table should not update with same value. can any one help me with tsql query...

    In future please post DDL and DML. For now I have created a scenario which will help you understand solution to your own requirement.
    CREATE TABLE Tickets_Log(
    Ticked_ID SMALLINT IDENTITY(1,1) PRIMARY KEY,
    Ticket_Type VARCHAR(20) NOT NULL,
    Log_Date DATETIME2 NOT NULL DEFAULT DATEADD(MINUTE,-15,GETDATE()),
    Machine_Name VARCHAR(50) NOT NULL,
    Message VARCHAR(100) NOT NULL,
    Ticket_Status CHAR(2) NOT NULL DEFAULT 'N',
    Update_Status SMALLINT DEFAULT 0)
    INSERT Tickets_Log(Ticket_Type,Machine_Name,Message)
    SELECT 'Pinging','HOD-400-651','Server Not Pinging' UNION
    SELECT 'Low Drive Space','HOD-400-652','Drive Space Low' UNION
    SELECT 'Connection','HOD-400-653','Unable to Connect to Server'
    UPDATE TL
    SET Log_Date=NewTickets.Log_Date,
    Update_Status=1
    FROM( SELECT 'Pinging' Ticket_Type,'HOD-400-651' Machine_Name,'Server Not Pinging' Message,GETDATE() Log_Date UNION
    SELECT 'Pinging','HOD-400-653','Server Not Pinging',GETDATE() Log_Date) NewTickets
    LEFT JOIN Tickets_Log TL ON NewTickets.Machine_Name=TL.Machine_Name AND NewTickets.Ticket_Type=TL.Ticket_Type
    WHERE TL.Ticket_Type IS NOT NULL AND TL.Machine_Name IS NOT NULL AND DATEDIFF(MINUTE,TL.Log_Date,NewTickets.Log_Date)>=15 AND Update_Status=0
    INSERT Tickets_Log(Ticket_Type,Machine_Name,Message,Log_Date)
    SELECT NewTickets.*
    FROM( SELECT 'Pinging' Ticket_Type,'HOD-400-651' Machine_Name,'Server Not Pinging' Message,GETDATE() Log_Date UNION
    SELECT 'Pinging','HOD-400-653','Server Not Pinging',GETDATE() Log_Date) NewTickets
    LEFT JOIN Tickets_Log TL ON NewTickets.Machine_Name=TL.Machine_Name AND NewTickets.Ticket_Type=TL.Ticket_Type
    WHERE TL.Ticket_Type IS NULL AND TL.Machine_Name IS NULL
    Chaos isn’t a pit. Chaos is a ladder. Many who try to climb it fail and never get to try again. The fall breaks them. And some are given a chance to climb, but they refuse. They cling to the realm, or the gods, or love. Illusions. Only the ladder is real.
    The climb is all there is.

  • HELP on Amount of use with RSL's ?

    i want to develop product and want to use the RSL (Runtime
    Shared Library) of the Flex. i don't know the amount of use with
    this feature and i will be happy to get info on the amount of site
    that use this.
    it critical for the future of this project.
    we want that a lot of users that will come to our site will
    already have the RSL on their Flash Player.

    If you want to know how many people have framework caching
    enabled (or how many people have the flex framework RSL, refer to
    this
    flexcoders
    message thread.
    Instead if you wanted to know how many people use RSLs (not
    flex framework) in general, flexcoders would be the best place for
    such a poll.

  • Help needed to sync cache with the database using CacheStore

    Hi,
    I need to have my cache in sync with the database. I followed the tutorial to create a DBCacheStore class which will act as a CacheStore between Cache and my Oracle database. My Cache-Config file contains
    <backing-map-scheme>
                        <read-write-backing-map-scheme>
                             <internal-cache-scheme>
                                  <local-scheme></local-scheme>
                             </internal-cache-scheme>
                             <cachestore-scheme>
                                  <class-scheme>
                                       <class-name>com.coherence.cacheUtil.DBCacheStore</class-name>
                                       <init-params>
                                            <init-param>
                                                 <param-type>java.lang.String</param-type>
                                                 <param-value>{cache-name}</param-value>
                                            </init-param>
                                       </init-params>
                                  </class-scheme>
                             </cachestore-scheme>                         
                        </read-write-backing-map-scheme>                    
                   </backing-map-scheme>
    Now, what I am trying to achieve is,
    1. Load the cache with values when the cache server is up, without any need to run separate program
    2. Integrate all read/write cache operations with the database
    I am aware that CacheStore class implements store, storeAll, erase, eraseAll, load, loadAll methods from undelying interface and I need to write corresponding code to add/remove/update records in the database.
    But, I am really not sure how and when to include the logic to load the cache with the data from the database when the server is up.
    Thank for the help. Much appreciated!

    Could you try something like this to load the cache?
    HashSet buffer=new HashSet();
    s = conn.createStatement();
    rs = s.executeQuery("select key from table");
    while (rs.next())
    String key = rs.getString(1);
    buffer.add(key);
    // this loads 1000 items at a time into the cache
    if ((count++ % 1000) == 0)
    cache.getAll(buffer);
    buffer.clear();
    if (!buffer.isEmpty())
    cache.getAll(buffer);
    This web page also gives a good example:
    http://www.oracle.com/technology/pub/articles/vohra-coherence.html
    -Luk

Maybe you are looking for

  • Cannot delete reports, unless I close and open Eclipse/Tomcat

    Please can someone help me. I cannot delete reports. I have not worked out all the details yet but this is what I got so far... First I thought it was a problem with my tomcat setup, I would deploy my WAR and run the app. After viewing the report and

  • My trackpad is not working properly already. Is it eligible for replacement?

    My trackpad is not working properly sometimes and it takes too long for my macbook to open

  • Service Orders not displayed in Web Tools

    Hello everyone, We are creating Service Type Orders within B1 and they are syncing over to Web Tools just fine, however they are not displayed on the Order History page for the user.  Is that 'as designed'?  I know there is no traditional information

  • Mangled file downloads over http problem in 10g

    I have a web app running in an OC4J stand alone 10.1.3.3 and am having a problem with downloading files over http. Its a struts2 app whose file downloading impl is easy to use and standard code for writing to an http servlet response output stream. U

  • JTableHeader + columns

    Hello to all!!!!! I speak spanish I am working with a jTable in which the idea is to take information from a DB and to show it by this component. But it is that the columns of the table can be changed of position and be changed the size of them. So t