With the help of THE application of the Clause

Hi, I use a FROM clause query to display the records from a temporary table. I have this query below and works very well:

{
MYQUERY: = ' (SELECT DISTINCT SUBSTR (R.CIRCUIT_CODE, 1, 5) CIRCUIT_CODE, MAX (R.CONNECTED_LOAD) CONNECTED_LOAD, R.SUBSTATION_CODE, R.CLASSIFICATION
SPM_CIRCUITS r
WHERE substr (r.SUBSTATION_CODE, 6, 4) = "|" ' || : SPM_CIRCUITS. V_SCODE | " ' ||'
AND DATE_COMMISSION < = TO_DATE (TO_CHAR (TO_DATE ('|))) '''|| : SPM_CIRCUITS. DATE_TO | " (((' |', "DD-MON-RRRR"), "DD-MON-RRRR"), "DD-MON-RRRR")
AND (DATE_DECOMMISSION > TO_DATE (TO_CHAR (TO_DATE ('|)))) '''|| : SPM_CIRCUITS. DATE_FROM | " (((' |', "DD-MON-RRRR"), "DD-MON-RRRR"), "DD-MON-RRRR")
OR R.DATE_DECOMMISSION IS NULL)
GROUP OF SUBSTR (R.CIRCUIT_CODE, 1, 5), R.SUBSTATION_CODE, R.CLASSIFICATION
ORDER BY CIRCUIT_CODE)';
}

However, recently I had to modify the query to use the the with... As command, which makes my query looks like this:

{
' (WITH months LIKE)
SELECT ADD_MONTHS ('|) '''|| : SPM_CIRCUITS. DATE_FROM | " (' |', LEVEL-1) m_first
, (ADD_MONTHS ('|)) '''|| : SPM_CIRCUITS. DATE_FROM | " ((' |', LEVEL 0)-1) m_last
OF the double
CONNECT BY LEVEL < MONTHS_BETWEEN ('|) '''|| : SPM_CIRCUITS. DATE_TO | " ' ||', ' ||'' ' || : SPM_CIRCUITS. DATE_FROM | " ' ||') + 1
)
load_per_month AS)
SELECT conn_load, SUM (conn_load) max_conn_load, m_LASt, CIRCUIT_code, substation_code, classification
Of
(SELECT SUBSTR(R.CIRCUIT_CODE,1,5) CIRCUIT_CODE, MAX (R.CONNECTED_LOAD) CONN_LOAD, R.SUBSTATION_CODE, R.CLASSIFICATION, m_last
SINCE SPM_CIRCUITS R CROSS JOIN
WHERE substr (r.SUBSTATION_CODE, 6, 4) = "|" ' || : SPM_CIRCUITS. V_SCODE | " ' ||'
AND DATE_COMMISSION < = M_LAST
AND (DATE_DECOMMISSION > M_FIRST OR R.DATE_DECOMMISSION IS NULL)
GROUP BY SUBSTR(R.CIRCUIT_CODE,1,5), R.SUBSTATION_CODE, R.CLASSIFICATION, m_last)
Conn_load, m_last, CIRCUIT_code, substation_code, classification GROUP)
SELECT NVL (SUM (NVL(conn_load,0)), 0) load, m_last, CIRCUIT_code, substation_code, classification
OF load_per_month
WHERE conn_load = max_conn_load
GROUP OF m_last, CIRCUIT_code, substation_code, classification
ORDER BY m_last)';
}

However, I encounter a FRM-40505 error: ORACLE error: unable to execute the query. But I do not see the error. Can anyone help me please with my problem. Thank you very much in advance.

I fixed the problem by using a different alias:

SELECT NVL (SUM (NVL(conn_load,0)), 0) load, m_last, CIRCUIT_code, substation_code, classification
OF load_per_month
WHERE conn_load = max_conn_load
GROUP OF m_last, CIRCUIT_code, substation_code, classification
ORDER BY m_last)

I changed to this:
SELECT NVL (SUM (NVL(conn_load,0)), 0), connected_load, m_last, CIRCUIT_code, substation_code, classification
OF load_per_month
WHERE conn_load = max_conn_load
GROUP OF m_last, CIRCUIT_code, substation_code, classification
ORDER BY m_last)

Apparently, the alias was wrong, but I don't really know why there is a cause of error it's just an alias. But thanks for your help.

Tags: Oracle Development

Similar Questions

  • With the clause of DML (DEC/insert/insert-all)

    Hello


    I have tables t1, t2, t3, t4

    with w
    (
    Select t1.* from t1, t2
    where t1.c1 = t2.c1
    and t1.c2 = t2.c2
    )


    I need to create or insert data in new tables n1 and n2
    Like this..

    Insert into n1
    Select * from w, t3
    where w.c1 = t3.c1

    Insert into n2
    Select * from w, t4
    where w.c2 = t4.c2
    ----

    I will make references the object 'w' several times.
    My concern is because the inserts above are run independently in the same session, the oracle executes the
    with the clause for each reference or runs one time?

    Essentially of iam looking for an insert-all statement
    where it inserts data into multiple tables from target
    something like that...


    Insert into n1
    When
    Select * from w, t3
    where w.c1 = t3.c1
    Insert into n2
    When
    Select * from w, t4
    where w.c1 = t4.c1
    with w
    (
    Select t1.* from t1, t2
    where t1.c1 = t2.c1
    and t1.c2 = t2.c2
    )

    ----
    Usually, I'm doing my basic work before posting on oracle forums, currently iam unable to connect to one
    Oracle sessions. Can someone help me?


    Thanks in advance.

    If your application will have the same number and type of columns, then you can do something like that.

    SQL> create table t1
      2  as
      3  select level no, 'karthick' name
      4    from dual
      5  connect by level <= 5
      6  /
    
    Table created.
    
    SQL> create table t2
      2  as
      3  select no, 'vimal' name
      4    from t1
      5  /
    
    Table created.
    
    SQL> create table t3
      2  as
      3  select no, 'vijay' name
      4    from t1
      5  /
    
    Table created.
    
    SQL> create table t4
      2  as
      3  select no, 'subha' name
      4    from t1
      5  /
    
    Table created.
    
    SQL> create table n1
      2  as
      3  select * from t1 where 1=2
      4  /
    
    Table created.
    
    SQL> create table n2
      2  as
      3  select * from t1 where 1=2
      4  /
    
    Table created.
    
    SQL> insert when view_name = 'v1' then
      2             into n1 values (no, name)
      3         when view_name = 'v2' then
      4                     into n2 values (no, name)
      5  with v
      6  as
      7  (
      8     select t1.*
      9       from t1, t2
     10      where t1.no = t2.no
     11  ),
     12  v1
     13  as
     14  (  select t3.*, 'v1' view_name
     15       from v, t3
     16      where v.no = t3.no
     17  ),
     18  v2
     19  as
     20  (  select t4.*, 'v2' view_name
     21       from v, t4
     22      where v.no = t4.no
     23  )
     24  select * from v1
     25  union all
     26  select * from v2
     27  /
    
    10 rows created.
    
    SQL> select * from n1
      2  /
    
            NO NAME
    ---------- --------
             1 vijay
             2 vijay
             3 vijay
             4 vijay
             5 vijay
    
    SQL> select * from n2
      2  /
    
            NO NAME
    ---------- --------
             1 subha
             2 subha
             3 subha
             4 subha
             5 subha
    
  • WITH the clause as inline view

    I m using oracle DB 11.2.0.2.0
    I have a question about usage WITH the clause which made a temporary transformation (Materializing) automatically.
    I want the query to operate as a point of view WITH clause online because the transactions table materailizing would kill performance.
    I m able to see the transformation of the temporary table in the explain output plan.
    Have we not all suspicion to stop the transformation of Temp table?

    Here is an example of the sample
    I have the query union multi (2 requests), couple of table is common to all the union queries. the request should not be materialized. It must operate as a point of view common inline.

    WITH ORDERS AS
    (SELECT h.order_number,
    l.line_number,
    l.line_id
    order_headers h, order_lines l)
    SELECT...
    COMMANDS, X, Y
    WHERE THE...
    UNION ALL
    SELECT...
    ORDERS, A, B, C
    WHERE THE...

    Try this...

    WITH ORDERS AS
    (SELECT /*+ inline */ h.order_number,
    l.line_number,
    l.line_id
    from order_headers h, order_lines l)
    ...
    

    To achieve the opposite effect, you can use SELECT / * + materialize * /.

    However, keep in mind that these tips are undocumented, so use them at your own risk. If you think that Oracle is to choose a bad execution plan, you must sign a deal with Oracle Support to see if this is a bug.

    Kind regards
    Bob

  • Can we use type multiset and with the clause the two

    Please let me know how to use the multiset type and with the clause.

    You need more inlining, as for example in:

    SQL> select *
    from table (cast (multiset (select *
                                from (with t as (select deptno from dept)
                                      select * from t)) as sys.dbms_debug_vc2coll))
    /
    COLUMN_VALUE
    ----------------------------------------
    10
    20
    30
    40
    50                                      
    
    5 rows selected.
    
  • WITH THE CLAUSE DOES NOT WORK

    Hello everyone,
    I have the suite Oracle version:

    SQL & gt; selection of version of $ v; *

    BANNER
    ----------------------------------------------------------------
    Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64 bit Production
    PL/SQL Release 9.2.0.8.0 - Production
    CORE Production 9.2.0.8.0
    AMT for Solaris: 9.2.0.8.0 - Production Version
    NLSRTL Version 9.2.0.8.0 - Production

    But when I try to run a query with * 'with the clause"* it gives following error:

    SQL & gt; with sam as (select from asap.triangular_reco_aug) *.
    SP2-0734: beginning of unknown command «with sam a...» "- rest of line is ignored.
    SQL & gt;

    Could someone please why this is happening?

    What is your version of SQL * more? If you are using a version earlier than 9.2 then it is probably intercept the syntax error before it happens even to the database that supports.

  • Help with the clause of "default".

    Hi all

    I have a scenario where there is a table with 75 columns. out of the 75 columns, 30 are varchar and 30 are digital. The remaining columns are other types of data when creating the table, that I forgot to mention the default values to varchar and numeric columns.

    Now, approximately 20,000 records are inserted into the table where some records contain NULL varchar and numeric. Now, I want to replace the null with varchar values and digital default values respectively.

    I can change the columns by adding the clause by default now and update the lines of NULL for the default values accordingly. But this process could be very heavy.

    Is there a better way to do this. Please help me.

    Thanks in advance,
    Rambeau

    I want to know that is it possible to set the default values for all columns of type varchar, both using a single SQL statement. Then you can update all the values NULL with default values.

    You are looking for something like this?

    SQL> create table t (empno default 1, ename default 'x') as select cast(null as integer) empno, cast(null as varchar2(10)) ename  from emp where rownum <= 4
    /
    Table created.
    
    SQL> select * from  t
    /
         EMPNO ENAME
    ---------- ----------
    
    4 rows selected.
    
    SQL> update t set empno = default, ename=default
    /
    4 rows updated.
    
    SQL> select * from  t
    /
         EMPNO ENAME
    ---------- ----------
             1 x
             1 x
             1 x
             1 x         
    
    4 rows selected.
    
  • Get ORA-00942 error with the clause, but not when the user sys.

    Hello

    About 3 weeks ago we increased our memary to PGA_aggregate_target = 60 GB, SGA_target = 58 GB Oracle instance. About 1 week ago our cognos user started having errors ORA-00942 for these queries generated with clause, with the same authorization. i.e.

    with 'aBmtQuerySubject4' as
    (select "BANK_NOTE_ADI_INFO_T". ' ' PRINT_BATCH_ID ' 'PRINT_BATCH_ID '.
    'BANK_NOTE_ADI_INFO_T '. ' ' PROCESS_RUN_DT ' 'PROCESS_RUN_DT '.
    'BANK_NOTE_ADI_INFO_T '. ' ' RDP_ID ' 'RDP_ID '.
    'BANK_NOTE_ADI_INFO_T '. ' ' FI_ID ' 'FI_ID '.
    'BANK_NOTE_ADI_INFO_T '. ' ' DEPOSIT_NB ' 'DEPOSIT_NB '.
    'BANK_NOTE_ADI_INFO_T '. ' ' PROCESS_MACHINE_ID ' 'PROCESS_MACHINE_ID '.
    'BANK_NOTE_ADI_INFO_T '. ' ' OUTPUT_STACKER_TYPE_CE ' 'OUTPUT_STACKER_TYPE_CE '.
    'BANK_NOTE_ADI_INFO_T '. ' ' PARTITION_KEY ' 'PARTITION_KEY '.
    'BANK_NOTE_ADI_INFO_T '. ' ' LOAD_ID ' 'LOAD_ID '.
    'BANK_NOTE_ADI_INFO_T '. ' ' SERIAL_NUMBER_ID ' 'SERIAL_NUMBER_ID '.
    'BANK_NOTE_ADI_INFO_T '. ' ' SHIFT_NB ' 'SHIFT_NB '.
    'BANK_NOTE_ADI_INFO_T '. ' ' BANK_NOTE_COUNT_NB ' 'BANK_NOTE_COUNT_NB '.
    of "BOISI '." BANK_NOTE_ADI_INFO_T' 'BANK_NOTE_ADI_INFO_T '.
    )
    'CountResultQuery5' as
    (select count ("aBmtQuerySubject4". "BANK_NOTE_COUNT_NB") 'C_1' "
    , count (1) 'C_2' of 'aBmtQuerySubject4 '.
    After having count (*) > 0)
    Select 'CountResultQuery5 '. "' C_2 ' 'Count1.
    of 'CountResultQuery5 '.
    ;


    with 'aBmtQuerySubject4' as
    (select "BANK_NOTE_ADI_INFO_T". ' ' LOAD_ID ' 'LOAD_ID '.
    of "BOISI '." BANK_NOTE_ADI_INFO_T' 'BANK_NOTE_ADI_INFO_T '.
    )
    'CountResultQuery5' as
    (select count ("aBmtQuerySubject4". "LOAD_ID") 'C_1' "
    , count (1) 'C_2 '.
    of 'aBmtQuerySubject4' having count (*) > 0
    )
    Select 'CountResultQuery5 '. "' C_2 ' 'Count1' of 'CountResultQuery5 '.
    ;

    -output like:

    'BANK_NOTE_ADI_INFO_T '. ' ' PROCESS_RUN_DT ' 'PROCESS_RUN_DT '.
    *
    ERROR at line 3:
    ORA-00942: table or view does not exist


    of "BOISI '." BANK_NOTE_ADI_INFO_T' 'BANK_NOTE_ADI_INFO_T '.
    *
    ERROR at line 3:
    ORA-00942: table or view does not exist

    Since 2 days ago, we get ORA-0403.

    One thing I noticed that the coguser can run above queries correctly after they are run by a user sys...

    Could you please help me on how I can resolve ORA-00942 error?

    Thank you very much, much in advance for all your help and your advice! :-)

    Jihong.

    "One thing I've noticed the coguser can run over queries correctly after they are run by a user sys... »

    Jihong,

    Do you mean that queries can be run successfully as a sys user, or as long as once a sys cognos user user has run the query at least once?

    Gerard

  • WITH THE CLAUSE

    Hi all

    I'm using oracle 11.2.0.4

    I m using this for the purpose of learning

    Below is my table and insert statement

    CREATE TABLE COMPANY (NUMBER EMPLOYEE_ID, EMPLOYEE_NAME VARCHAR2 (30), NUMBER OF MANAGER_ID)

    INSERT INTO THE COMPANY'S VALUES (1, 'FRED', ");

    SOCIETY VALUES (2, 'BARNEY', '1');

    SOCIETY VALUES (3, 'WILMA', '1');

    SOCIETY VALUES (4, 'BETTY', '3');

    INSERT IN THE VALUES(5,'PEBBLES','3') SOCIETY;

    INSERT IN THE VALUES(6,'BAM-BAM','4') SOCIETY;

    INSERT IN THE VALUES(7,'DINO','4') SOCIETY;

    INSERT IN THE VALUES(8,'HOPPY','4') SOCIETY;

    WITH RSFC(CK,PK,LVL,HIER) AS

    (SELECT EMPLOYE_ID, MANAGER_ID, 0 AS LVL, EMPLOYEE_NAME LIKE YESTERDAY)

    SOCIETY

    WHERE MANAGER_ID IS NULL

    UNION ALL

    SELECT EMPLOYE_ID, MANAGER_ID, LVL + 1, YESTERDAY. '/' || EMPLOYEE_NAME

    OF THE RSFC R INNER JOIN COMPANY F

    ON R.CK = F.MANAGER_ID

    )

    WIDTH OF SEARCH FIRST BY CK ORDR SET

    SELECT A.LVL, A.CK, A.PK, A.HIER, ORDR

    THE RSFC HAS

    ORDER BY ORDR

    01FRED1
    121FRED/BARNEY2
    131FRED/WILMA3
    243FRED/WILMA/BETTY4
    253FRED/WILMA/PEBBLES5
    364FRED/WILMA/BETTY/BAM-BAM6
    374FRED, WILMA, BETTY, DINO7
    384FRED, WILMA, BETTY, HOPPY8

    First part, I believe, as well, explains Frank

    hierarchical queries

    next part in bold, I need to understand

    Thanks and respect.

    Guylaine

    Hi, lyly,

    You said that you did not understand the part highlighted in your query.  It looks like the 2 lines are highlighted:

    WIDTH OF SEARCH FIRST BY CK ORDR SET

    SELECT A.LVL, A.CK, A.PK, A.HIER, ORDR

    I guess that it's a typo.  The 2nd day of these lines is just the main SELECT clause; This is the 1st line, the clause of the SEARCH, who really needs an explanation.

    As far as I know, the SEARCH clause is only for the sorting of the results.  In other words, the a WITH recursive clause results will be the same, no matter what you put in the SEARCH clause, or if you omit the clause of RESEARCH.  The only purpose of the clause of RESEARCH is to generate the column command (ORDR in your example), which reflects where each row fits in the graph defined by your recursive query.  (Maybe, if you use non-deterministic user-defined functions, it can be a difference in the results.  Chances are, you never have to worry about this).

    If you do not use a clause in RESEARCH at all, it seems like by default

    WIDTH OF SEARCH FIRST BY NULL...

    In other words, the lines appear in order by level and in no particular order after that.  In your case, that would mean 'FRED' would come first, then "BARNEY" and "WILMA" (not necessarily in that order), followed by all the children of 'BARNEY' or 'WILMA' and so on.  No column order would be generated, so you could not guarantee order in the ORDER BY clause.

    I'm not sure that there is nothing you can do with a clause of RESEARCH that you can not do without a.  In other words, the SEARCH clause automatically generates a command column.  I believe you can still create an equivalent ordering column in the recursive query itself.  In your example, you could say

    ORDER BY lvl, ck

    to get the results sorted the same way.  Sometimes, using a SEARCH clause is much more convenient, and I bet that sometimes it is therefore more effective, too.

    2937991 wrote:

    Hi all

    I'm using oracle 11.2.0.4

    I m using this for the purpose of learning

    Below is my table and insert statement

    CREATE TABLE COMPANY (NUMBER EMPLOYEE_ID, EMPLOYEE_NAME VARCHAR2 (30), NUMBER OF MANAGER_ID)

    INSERT INTO THE COMPANY'S VALUES (1, 'FRED', ");

    SOCIETY VALUES (2, 'BARNEY', '1');

    ...

    As always, thank you for posting this information: it really helps!

    Manager_id is a NUMBER, it would be better if you don't quote it.  In other words, it would be more clear, more effective and less prone to say:

    INSERT INTO COMPANY (EMPLOYE_ID, EMPLOYEE_NAME, MANAGER_ID) VALUES (1, 'FRED', NULL);

    INSERT INTO COMPANY (EMPLOYE_ID, EMPLOYEE_NAME, MANAGER_ID) VALUES (2, 'BARNEY', 1);

    ...

    In this example, the unnecessary quotation marks do not hurt a lot, but they do not help all.

  • with the Clause in a function

    Hi all

    I use oracle 10 g 2.

    I have a sql query that begins with a "WITH Clause"... Can of use this directly in a function?

    I tried copy paste in the new feature after the BEGIN... but it errors saying CLAUSE provided for in select... when I try including IN the clause... it gives different error...

    Enjoy your sugessions

    Thanks in advance
    H

    You can, perhaps you could post your code so we can take a look?

    See you soon

    Ben

  • With the clause does not work in SqlPlus for DataBase 11 GR 8 1 material

    I have 11 GR 1 database material, when I connect to my database through SqlPlus (version 8.0.6.0.0) this query
    with x as (select * from areas) select * from x;
    does not work. But when you use SqlPlus provided by 11g, this query works well. This query can run on an older version of SqlPlus?

    user12222356 wrote:
    This client software is installed with Oracle developer 6i form. should I remove all the form developer? Latest version of the form developer is available for 11 GR 1 matter?

    Well, you have problems with the developer of forms?

    I wouldn't recommend delete because you have problems with the SQL more customer that goes with it. I recommend to download the instant client and using them for your needs of sqlplus and leaving the rest products installed on your machine only.

  • How to use an index with the clause 'in '.

    Hi all

    I have a sql statement with "" * in the clause * "."

    for example:
    select emp_id from emp where ename in ("vikas", "krishna", "John", "scott");
    When I check the plan explain he uses the index here even if the statistics was entered. He always goes for the full table scan.
    There is an index created for the ename column.

    Please tell me a technique on how to make use of the index here.


    Thank you and best regards,
    Vikas Krishna

    Vikas,

    What version of Oracle you are running.
    CLAUSE IN will use the index as appropriate.
    In your example Optimizer may decide to use FTS (Full Tablle Scan) for various reasons. May be that the table is very small.
    SE for example below where he uses an index on the CLAUSE IN...
    The essential point being that I made "wide enough" table (in this case including a column of type CHAR) makes use of INDEX more effective than a FTS.

    select * from v$version where rownum < 2;
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    
    create table bigt (c int, s char(100));
    
    insert into bigt select level, 'X' from dual connect by level < 501;
    
    create index bigt_in1 on bigt (c );
    
    exec dbms_stats.GATHER_TABLE_STATS('SUDHAKAR', 'BIGT');
    
    explain plan for select c,s from bigt
    where c in (1,2,3,43,5);
    
    select * from table(dbms_xplan.display);
    
    PLAN_TABLE_OUTPUT
    
    Plan hash value: 238667275
    
    -----------------------------------------------------------------------------------------
    | Id  | Operation                    | Name     | Rows  | Bytes | Cost (%CPU)| Time     |
    -----------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT             |          |     5 |   520 |     3   (0)| 00:00:01 |
    |   1 |  INLIST ITERATOR             |          |       |       |            |          |
    |   2 |   TABLE ACCESS BY INDEX ROWID| BIGT     |     5 |   520 |     3   (0)| 00:00:01 |
    |*  3 |    INDEX RANGE SCAN          | BIGT_IN1 |     5 |       |     2   (0)| 00:00:01 |
    -----------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       3 - access("C"=1 OR "C"=2 OR "C"=3 OR "C"=5 OR "C"=43)
    

    VR,
    Sudhakar B.

  • With the clause in a procedure stored with update

    create table TEMP_STAGE as
    (select ' 111111' student_id, ' don't TMP_TEST FROM DUAL ")
    UNION
    Select '111111' student_id, ' don't TMP_TEST FROM DUAL
    UNION
    Select ' 222222' student_id, ' don't TMP_TEST FROM DUAL;
    )

    CREATE OR REPLACE PROCEDURE TEMP_SEC_TEST
    AS
    BEGIN
    UPDATE TEMP_STAGE S
    SET S.TMP_TEST = 'Y '.
    WHERE STUDENT_ID IN
    (
    WITH MARK AS
    (
    SELECT '111111' DOUBLE STUDENT_ID
    )
    Select STUDENT_ID in BRAND
    );
    END;

    I have a huge SQL statement with several "with" of tables in the statement. It works if I run it as a script but it doesn't work when I put it in a stored procedure.
    When I run the above, it gives me an error...
    Syntax error (8:9) check
    Found 'BOOKMARK' waiting...

    It gives me an error the TSF online brand...

    I have to do it in the stored procedure that the statement is very complicated...

    Help, please.

    Which tool you use to create the procedure? Error syntax Check (8:9) is not a mistake, Oracle, or what I know from any Oracle product.

    It works very well in sqlplus.

    SQL> CREATE procedure my_p AS
      2  BEGIN
      3     UPDATE t
      4     SET descr = 'Un'
      5     WHERE id IN (WITH tmp AS (
      6                     SELECT 1 x FROM dual)
      7                  SELECT x FROM tmp);
      8  END;
      9  /
    
    Procedure created.
    
    SQL> SELECT * FROM t;
    
            ID DESCR
    ---------- ----------
             1 One
    
    SQL> exec my_p;
    
    PL/SQL procedure successfully completed.
    
    SQL> SELECT * FROM t;
    
            ID DESCR
    ---------- ----------
             1 Un
    

    John

  • with the clause against table inline

    Dear Experts,

    With clause or inline table are identical from the point of view of performance.

    What query is better?

    query with clause

    with table_getbuckets as
    (
    SELECT * FROM TABLE(pack_activitymonitoring.f_getmatbuckets (start_settle_date,end_settle_date))
    )
    SELECT
          nvl(baludhar.pct,0) AS pctudhar
    FROM t_option opt
    LEFT OUTER JOIN table_getbuckets balinv ON
                opt.a_id = balinv.collateral_a_id AND
                opt.s_id = balinv.s_id
    WHERE opt.for_principal=1
    
    

    query without a clause

    SELECT
          nvl(baludhar.pct,0) AS pctudhar
    FROM t_option opt
    LEFT OUTER JOIN (
                     TABLE(pack_activitymonitoring.f_getmatbuckets
                                                        (start_settle_date,end_settle_date))
      ) balinv ON
                opt.a_id = balinv.collateral_a_id AND
                opt.s_id = balinv.s_id
    WHERE opt.for_principal=1
    
    

    In this case, since you are using only the view inline once, I expect to exercise the same.

    For purposes of readability, I prefer the one that uses the WITH clause.

  • Developer SQL 4.1.0.19 and WITH the clause. Impossible to execute queries

    Hi all, I have trouble executing a statement in the SQL in SQL Developer worksheet window:

    WITH COST_CENTERS (COST_CENTER_LEVEL,

    COST_CENTER_ID,

    COST_CENTER_CODE,

    COST_CENTER_NAME,

    PARENT_COST_CENTER_ID) AS)

    SELECT 1 AS COST_CENTER_LEVEL,

    PCC. COST_CENTER_ID,

    PCC. COST_CENTER_CODE,

    PCC. COST_CENTER_NAME,

    PCC. PARENT_COST_CENTER_ID

    OF XXPN. CCP XXPN_COST_CENTERS

    WHERE PARENT_COST_CENTER_ID IS NULL

    UNION ALL

    SELECT COST_CENTERS. COST_CENTER_LEVEL + 1 AS COST_CENTER_LEVEL,

    CCC. COST_CENTER_ID,

    CCC. COST_CENTER_CODE,

    CCC. COST_CENTER_NAME,

    CCC. PARENT_COST_CENTER_ID

    OF COST_CENTERS.

    XXPN. CCC XXPN_COST_CENTERS

    WHERE THE CCC. PARENT_COST_CENTER_ID = COST_CENTERS. COST_CENTER_ID)

    SELECT COST_CENTER_LEVEL,

    COST_CENTER_ID,

    COST_CENTER_CODE,

    COST_CENTER_NAME,

    PARENT_COST_CENTER_ID

    OF COST_CENTERS

    ORDER OF COST_CENTER_LEVEL,

    COST_CENTER_CODE;

    The same code will run without any problem in SQL * more or TOAD. (I tried to execute the statement at a time by clicking on "Run the statement" and 'Run Script buttons', they return with an error both...)

    The SQL Developer cannot parse WITH statements?

    Thanks in advance and best regards,

    Loris.

    Hi all

    I solved the problem by using the information provided in the blog entry from Jeff:

    http://www.thatjeffsmith.com/archive/2014/07/Oracle-SQL-Developer-around-the-world/

    I added the

    AddVMOption - Duser.language = in

    line in my sqldeveloper.conf file and now do business conversions upper-lower case correctly and executes my statement if it is written in upper case or lower case.

    Best regards

    Loris.

  • WITH the Clause does not work in 11g

    Hi all

    I run this query via PL/SQL developer in 11g, but it shows no data to me.

    with aquery as (c1, c2 from t1 select where c2 = 20130101) select * from aquery.

    However, when I run only the SELECT, and then it retrieves the output.

    Select c1, c2 from t1 where c2 = 20130101

    The db user privileges both CREATE MV and CREATE Table in this database.

    Thank you.

    I have no developer PL/SQL, but I do not have 11.2.0.4, and your query works for me in sqlplus and SQL Developer, the problem is with PL/SQL Developer, or maybe a transient network issue any.  You simply get an error any or all not the lines selected?

    John

  • WITH the clause can be used with an insert statement?

    Hello

    Can I use a SQL with a clause of an insert

    Something like
    create table tem (l number)
    
    insert into tem
    (l)
    (with 
      t0  as 
      (Select exp_amt as t0 from exp_main)
    select t0 from t0)
    The declaration itself works fine, but it throws the following error with insert
    Error at Command Line:8 Column:17
    Error report:
    SQL Error: ORA-32034: unsupported use of WITH clause
    32034. 00000 -  "unsupported use of WITH clause"
    *Cause:    Inproper use of WITH clause because one of the following two reasons
               1. nesting of WITH clause within WITH clause not supported yet
               2. For a set query, WITH clause can't be specified for a branch.
               3. WITH clause can't sepecified within parentheses.
    *Action:   correct query and retry
    The reason why I use this format is because we strive to produce sqls to Analytics and queries are generally formed like this. So instead of change requests in bulk, I was hoping that we were able to insert it.

    Please notify

    Thank you
    Sun

    Published by: ryansun on August 14, 2012 01:59

    >
    create table tem (general number);
    table created TEM.

    insert into tem (l)
    with t0
    as
    (Select 1 as double t0)
    Select t0 t0;

    1 inserted rows.

Maybe you are looking for