Posted on 2007-07-20
Last Modified: 2013-12-19
Would you please help me out with WITH CLAUSE use in Oracle 9i?
I need to insert the result set from the query which uses WITH CLAUSE.

    Credit as
        select      sum( Amount )           as Credit_Amount
        from        tmpTransactionMaster
        where       ACCOUNT_TYPE = 'CREDIT'
    Debit as
        select      sum( Amount )           as Debit_Amount
        from        tmpTransactionMaster
        where       ACCOUNT_TYPE = 'DEBIT'
    insert into tmpReconciliationLog ----------- ?????????????????????
    select  'Total Credit - Total Debit)'       as Formula,
            Credit_Amount - Debit_Amount    as Balance
    from Credit, Debit;
I have tried to use the same logic as in SQL Server 2005 but Oracle generated an error:
15:43:04  [WITH - 0 row(s), 0.031 secs]  [Error Code: 928, SQL State: 42000]  ORA-00928: missing SELECT keyword
Thank you for any help.

Question by:GoodName
    1 Comment
    LVL 142

    Accepted Solution

    in oracle indeed, you cannot using INSERT when using the WITH statement.
    you will need to create a view with the WITH statement, and insert from that...

    Featured Post

    PRTG Network Monitor: Intuitive Network Monitoring

    Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

    Join & Write a Comment

    This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
    Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
    This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
    Video by: Steve
    Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…

    730 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now