Scope of violation in the subquery

I created a sql in the database to Oracle 11 g Enterprise Edition Release 11.2.0.2.0 to purchase Oracle query tables. The user wants to know an estimate of the number of days it takes to approve a release as soon as it is created. I created a subquery, as follows:

Select Papf.Full_Name as the approver
Pah.Action_Date as Approved_Date
Por.Creation_Date
, Trunc (Pah.Action_Date) - Trunc (Por.Creation_Date) days
(Select Count (*)
From (select level, (Pah.Action_Date + 1) - level double My_Date)
Connect by level < Trunc(Pah.Action_Date+1) - Trunc (por.creation_Date)
() Where To_Char (My_Date, 'DY') ('MON', 'Mar', 'SEA', 'Game', 'Ven')) As Days2Approve

OF Apps.Po_Headers_All Poh
Apps.Po_Releases_All Por
Apps.Po_Lines_All Pol

Apps.Po_Action_History Pah
... etc.

When I run the application, I get the following error message:

ORA-00904: "POR". "' CREATION_DATE ': invalid identifier
00904, 00000 - '% s: invalid identifier '.
* Cause:
* Action:
Error on line: 193 column: 54

I know that the subquery conceptually strong because if I run the sql below with fake dates I get 17 which is correct.

Select Count (*)
From (SELECT level, (to_date (January 24, 2013 ') + 1)-level my_date From Dual)
Connect by level < Trunc (To_Date('24-JAN-2013') + 1) - Trunc (To_Date('01-JAN-2013'))
) Where To_Char (My_Date, 'DY') ('MON', 'Mar', 'SEA', 'Game', 'Ven')

How do Pah.Action_Date & por.creation_Date the subquery without getting what appears to be brought for violation?

Hello

You can avoid the problem by not using is not a nested subquery:

(
    SELECT  COUNT (*)
    FROM    dual
    CONNECT BY   LEVEL  < TRUNC (pah.action_date + 1)
               - TRUNC (por.creation_date)
    WHERE   TO_CHAR ( pah.action_date + 1 - LEVEL
                      , 'DY'
              ) NOT IN ('SAT', 'SUN')
) AS days2approve

I hope that answers your question.
If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and also publish outcomes from these data.
Explain, using specific examples, how you get these results from these data.
See the FAQ forum {message identifier: = 9360002}

Tags: Database

Similar Questions

  • It is a violation of the EULA to downgrade using IPSW?

    I heard people 9.3 iOS downgrade to iOS 9.2.1 before the signature is no longer. And sometimes I wanted to even really downgrade my iPhone 4 IOS 7.1.2 to iOS 4 because it can be much faster, and we get the older UI. Is this a violation using blobs SHSH? I'm a little curious.

    If you get the ipsw file from anywhere but Apple, it is a violation of the EULA and could even be, in certain circumstances, flight.

  • Card data scope of device to the TDMS file buffer

    How transfer brought data card device buffer to TDMS file directly bye passing buffers LabVIEW and Windows. In the same way as DAQmx configure logging (VI) do we have any function scope?

    The API OR-SCOPE doesn't have the ability to record data acquired directly on the disc like the DAQmx API offers.  All data must be retrieved from the on-board memory, which makes data transfer OR-SCOPE kernel driver via DMA, and a copy must then happen to transfer data from the space of the kernel in user space (LabVIEW), how it can be manipulated.

    The main reason for this flow is because the calibration scale occurs in the NOR-SCOPE driver and not the material.  So if you were to save data directly to the disk as DAQmx, he stock raw ADC codes, without correction calibrated.  The API OR-SCOPE allows to recover the coefficients of scale if you want to apply them at a later date after extraction of the data from the hardware.  To optimize flow of data applications, it is recommended.

    The only exception to the logging directly on the disk would be the Oscilloscope Reconfigurable SMU-5171R.  It is being implemented with LabVIEW FPGA firmware using the design of Instrument libraries, code is open for editing.  With the open nature of this software stack, it is possible to implement "direct to TDMS" functionality with LabVIEW FPGA Read region node.

    I hope this helps!

    -Nathan

  • violation to the 500B 6430 address in the access module "rtl150.bpl". Read address 00000004

    At the start, after entering my password, Windows 7 displays a window of Spybot-Search & Destroy2 plate with a

    message from:

    violation to the 500B 6430 address in the access module "rtl150.bpl". Read address 00000004

    Is there a solution to this problem?

    Thks and Rgds

    TS

    Try to uninstall Spybot and then reinstall the latest version and see if that fixes the problem.

    Just in case, it may make sense to run a full virus / malware scan as well.
    If you have access to another computer, you can download Windows Defender off line which you will scan in a secure environment and are more likely to remove the intrusive malware.
  • Oracle PL/SQL using decode/case in the subquery

    SELECT DISTINCT E.ACC_ID,
    P.EFFECTIVE_DATE,
    P.UPDATE_DATE
    (CHOOSE abc.def table in case RECON_ACC.partition_id is 1 for this acc_id
    abc100.def if RECON_ACC.partition_id 2 table for this acc_id
    ) p
    JOIN IN-HOUSE
    (select * from RECON_ACC where id_partition is NOT NULL) e
    ON P.ACC_ID = E.ACC_ID
    AND TRUNC (P.UPDATE_DATE) > = December 31, 13 '
    AND TRUNC (P.UPDATE_DATE) < = 2 January 14 ';

    Can someone help me to do a SQL query to do this?

    Hello

    If you had only a table of def, then it would be easy

    .  You need only a simple join, like this:

    SELECT ud.acc_id, ud.effective_date, ud.update_date

    Of unified_def ud

    JOIN recon_acc r ON ra.partition_id = ud.partition_id

    AND ra.acc_id = ud.acc_id - can - be

    ;

    The only problem here is that you have 2 separate tables def.  Assistance from the UNION, you can create a result set that makes these 2 tables appear as 1; for example:

    WITH date_range AS

    (

    SELECT TO_DATE (November 1, 2013 00:00:00 ', 'HH24:MI:SS of Mon-DD-YYYY') AS first_date

    , TO_DATE (November 20, 2013 23:59:59 ', 'HH24:MI:SS of Mon-DD-YYYY') AS last_date

    OF the double

    )

    unified_def AS

    (

    SELECT d1.effective_date, d1.update_date, d1.acc_id

    1 AS id_partition

    To abc_def d1

    JOIN date_range r1 WE d1.update_date BETWEEN r1.first_date

    AND r1.last_date

    UNION ALL

    SELECT d2.effective_date, d2.update_date, d2.acc_id

    2 AS id_partition,

    Abc100_def D2

    JOIN date_range r2 WE d2.update_date BETWEEN r2.first_date

    AND r2.last_date

    )

    SELECT ud.acc_id, ud.effective_date, ud.update_date

    Of unified_def ud

    JOIN recon_acc r ON ra.partition_id = ud.partition_id

    AND ra.acc_id = ud.acc_id - can - be

    ;

    I called def small tables abc_def and abc100_def, just so I wouldn't have to create new patterns.  Replace your real names when you run this.

    I added the subquery date_range as a means of conveying the date settings.  You can do something else, bind variable may be.

    I guess just in between the recon_acc and other tables join conditions.  Do you still need recon_acc at all with this problem?

    Once more, this problem only occurs because you have 2 separate tables def.  Why you store your data in a way that creates problems?  Is there a reason why you can't use only 1 table unified_def?

  • WHT is the downside of the scope with respect to the operation?

    WHT is the downside of the scope with respect to the operation?

    not 100% sure I understand your question well, but scope is available for the duration of your request - which means that if you insert data in the scope it remains around the life of your application - which can be a drain on resources.

  • The subquery support

    Hello

    I have a question that makes some joined and has a subquery in there as well. My problem is that sometimes the subquery returns more than 1 row (max 2) and it will make the request fails. I know that fixing data should be the right thing to do, but how it would be possible to overcome this problem? The criterion is that when it returns 2 rows, he should choose the second so, using ROWNUM = 1 will not work.

    Any advice?

    Thank you!

    Example:
    SELECT A.TEST, B.CASE,(SELECT C.SOMETHING FROM TABLE C WHERE A.TEST=C.TEST) AS TEST
    FROM TABLE A, TABLE B
    WHERE A.ID=B.ID
    Published by: n on 2013-mar-06 09:29

    Hello

    In Oracle, you cannot use the AS keyword when you assign a table alias.
    Change

    ...
    FROM    (
                SELECT  ...
            )  AS w
    ...
    

    TO

    ...
    FROM    (
                SELECT  ...
            )   w    -- Can't use AS here
    ...
    

    This is different from SQL Server. If you think that Oracle is confused and incoherent, you have company.

    N wrote:
    ... The tables are huge, even given.

    This is why you must create small test tables and fill them with a few lines of sample data, with the results you can find manually. Given that you should do this anyway, just for your own testing and debugging, it is easy to post if you want other people to help.

  • creating table using joins in the subquery

    can we create a table using joins in the subquery?
    Like this
    create table emp in select * from employee e, Department d
    where d.department_id = e.department_id
    ??
    We can?

    987018 wrote:
    We can?

    Yes, as long as you column alias names common to both tables to make them unique.

    SY.

  • Any form of session scope Manager out of the box atg commerce

    Is there any form of session scope Manager out of the box atg commerce. I would like to know if someone is aware of this form Manager.

    Thank you
    David

    DCS/config/atg/commerce/gifts/GiftlistFormHandler.properties

    http://docs.Oracle.com/CD/E23507_01/platform.20073/ATGCommProgGuide/HTML/s0602giftlistformhandlers01.html

    -RMishra

    Edited by: RMishra 4 December 2012 16:59

  • Need more info on the violation of the "AlertShow".

    Hello

    First of all thanks for the great tool! It was really something that we all missed.

    I have a question related to the violation of the "AlertShow". I've had several of these violations and the description says

    'Do not directly call Alert.show... '. You shouldn't Alert.show () directly. If an error has occurred in the system, you should probably use an ErrorManager to have a consistent way to manage these errors.

    What, exactly, is this violation? Could you please provide more detail, why this violation appears and how it should be fixed.

    Thank you!

    Hello

    Glad you liked the project.

    So that we often people using Alert.show whithout having a central ErrorManager class. Having such a class allows you to have a consistent way to deal with errors in your application.

    Alert.Show can be called from anywhere (view, model, orders,...), while is nothing else than a wrapped view.

    I hope this helps.

    Xavier

  • How to define a WHERE clause of the subquery in a bean managed?

    Hi people,

    is it possible to define the place where clause of a subquery in a bean managed?
    For example, it is more SQL charly:

    SELECT * FROM
    (SELECT Person.Name
    OF the person)

    To change or add a WHERE clause, I use following code for the 'viewObject: view

    String whereClause = "ROWNUM < =: numberOfRows;
    viewObject.setWhereClause (whereClause);

    viewObject.defineNamedWhereClauseParam ("numberOfRows", null, null);
    viewObject.setNamedWhereClauseParam ("numberOfRows", new Number (100));

    AttributeList myattr = this.getNamedWhereClauseParams ();
    viewObject.setNamedWhereClauseParams (myattr);

    For example, this code works well for the first SELECT statement limit the output to the first 100 results. But how do I add a WHERE clause of the subquery in a managed bean? For example, when I want to limit the names of people that begin with the letter "A"?
    The query should look like this:

    SELECT * FROM
    (SELECT Person.Name
    OF the person
    WHERE Person.Name LIKE 'A %')

    Anyone know more?

    Thank you!

    Put a variable binding in your query, something like:

    where (: bv is null) or (xxx love: bv)

    John

  • Using the value of the column in the subquery?

    Hello friends. Because I didn't realize anything today, although focusing on the problem for hours, I would like to ask you a question.

    I have a report based on a query. The following statement is the minimum to avoid confusion between you:
    select cnt_gebiet, null work, 1 cs from tbl_gebiet
    
    union
    
    select 
    a.lng_gebiet,
    case when (select max(a.lng_arbeitsschritt) from 
    tbl_arbeit_zu_gebiet a, tbl_arbeitsschritte_neu b
    where 
    a.lng_arbeitsschritt = b.cnt_arbeitsschritt and b.lng_typ_arbeitsschritt = 3) = 1 then 0 else (select max(a.lng_arbeitsschritt) from 
    tbl_arbeit_zu_gebiet a, tbl_arbeitsschritte_neu b
    where 
    a.lng_arbeitsschritt = b.cnt_arbeitsschritt and b.lng_typ_arbeitsschritt = 3) end as lng_arbeitsschritt,
    2 cs
    from tbl_arbeit_crit_date a inner join tbl_arbeitsschritte_neu b on a.lng_arbeitsschritt = b.cnt_arbeitsschritt 
    where a.lng_arbeitsschritt = 1
    order by  cnt_gebiet asc, cs asc 
    My problem:

    I need to add the cnt_gebiet criteria to the query
    select max(a.lng_arbeitsschritt) from 
    tbl_arbeit_zu_gebiet a, tbl_arbeitsschritte_neu b
    where 
    a.lng_arbeitsschritt = b.cnt_arbeitsschritt and b.lng_typ_arbeitsschritt = 3 
    Do you have any idea how I can the union row, using the value of line (cnt_gebiet) of the above query as a criterion in the subquery resp. lower?

    skahlert,

    Something like this might work:


    WITH upper_query 

         AS ()SELECTcnt_gebiet   

                    NULL WORK , 

                    1 cs    

             DE tbl_gebiet   

             UNION

             SELECT a . lng_gebiet , 

                    CASE

                      WHEN (SELECTMax(a. lng_arbeitsschritt )  

                            DE tbl_arbeit_zu_gebiet a ,    

                                   tbl_arbeitsschritte_neu b 

                             a . lng_arbeitsschritt = b . cnt_arbeitsschritt    

                                   ET b . lng_typ_arbeitsschritt = 3 )=1     

                      THEN 0 

                      Else (SELECTMax(a. lng_arbeitsschritt )  

                            DE tbl_arbeit_zu_gebiet a ,    

                                   tbl_arbeitsschritte_neu b 

                             a . lng_arbeitsschritt = b . cnt_arbeitsschritt    

                                   ET b . lng_typ_arbeitsschritt = 3 )   

                    END AS lng_arbeitsschritt ,  

                    2 cs   

             DE tbl_arbeit_crit_date a    

                    INTERIOR JOIN them tbl_arbeitsschritte_neu b   

                      ON a . lng_arbeitsschritt = b . cnt_arbeitsschritt   

              a . lng_arbeitsschritt = 1    

             ORDER BY cnt_gebiet CSA ,   

                      cs CSA ) 

    SELECT Max (a. lng_arbeitsschritt ) 

    DE tbl_arbeit_zu_gebiet a ,    

           tbl_arbeitsschritte_neu b , 

           upper_query

    a . lng_arbeitsschritt = b . cnt_arbeitsschritt    

           ET b . lng_typ_arbeitsschritt = 3   

           ET upper_query . cnt_gebiet = : variable   

    Jeff

  • Passing parameters to the subquery

    I have a model data, as shown below. I need to use a subquery to exclude a certain subset of folder, but the subquery depends on user, in this example, parameters: months and: year, but it doesn't seem to work, I get an error saying: invalid parameter index: 2

    With recognition would appreciate any help in this regard.


    < name of dataTemplate = 'WMS' description = 'WMS Detail' than one dataSourceRef = "Oracle BI EE" >
    < dataQuery >
    < sqlStatement = 'RP' name > <! [CDATA [select F1721. WARRANTY8
    of JDE. F1721 F1721
    where F1721. CNDJ = null
    and F1721. CDTE > =: Refdate
    and F1721. Warranty8 not in (select F551720A. WARRANTY8
    of JDE. F551720A F551720A
    where F551720A. MATH01 =: months
    and F551720A. MATH02 =: year)
    Order of F1721. Warranty8]] >
    < / sqlStatement >
    < / dataQuery >
    < dataStructure >
    < name of group = 'RP' source = 'RP' >
    < element name = "Warranty8" value = "f1721.an8" / >
    < / Group >
    < / dataStructure >
    < / dataTemplate >

    HI Dominic

    Add the parameter section

    
    
    
    
    
    
    
  • Problem with update of table (using the subquery to retrieve value)

    Hello
    I update a table based on the value of the subquery.
    Here's the update statement.

    UPDATING temp xm
    SET xm.col1 = (SELECT DISTINCT col1
    Of
    (SELECT col1, col2 COUNT (col2)
    FROM table2
    WHERE col1 = xm.col1
    AND col2 = xm.col2
    GROUP BY col1)
    where col2 in (select... in the table3)
    )
    WHERE xm.col5 = < value >
    AND xm.col6 = < value >

    When I run this statement I get following error.
    ORA-00904: "XM". "" Col1 ": invalid identifier.

    Can someone help me why I get this error?
    Why doesn't the main table alias in the subquery?

    Is it possible to avoid this / re - write the query in a different way?

    Thank you

    Published by: user552703 on November 2, 2009 20:42

    You can nest only 1 level deep (referring to the table to be updated).

    Have you looked at using the MERGE command? It is "easier" perform updates of this nature, assuming you are using a recent version of Oracle (9 or MORE).

  • Oracle db bad result on the subquery error

    Hello

    I work with Oracle databases up to 10 g and I found an error and could not find any documentation on this subject yet. Maybe you can help me.

    The error is fairly easy to reproduce. If you run the following query in adapting the parameters that you should get a result, the problem is that you should get only an error!

    Select * from user_tab_columns
    where table_name in
    (
    Select table_name from < TABLE_B >
    );

    Parameter: TABLE_B
    Description: This must be an existing table in the schema that is not any field from the table table_name.

    As I said, the subquery is false, so if you try to run separately it fails. The problem is when you run the two together because, if the link field has the same name, it returns all the values in the table in the outer query.

    Do you know if this is solved a specific patch of 10g or 11g?

    Thanks in advance for your interest.

    Best regards
    Leo ([email protected])

    This isn't a mistake, given that table_name is a valid column in the external table name. If you start using table alias names in front of the column names, you will get the error.

    example of

    SQL> select * from user_tab_columns u
      2  where u.table_name in
      3  (select d.table_name from dual d
      4  );
    (select d.table_name from dual d
            *
    ERROR at line 3:
    ORA-00904: "D"."TABLE_NAME": invalid identifier
    

    What oracle is without any alias table corresponds to this selection:

    SQL> select count(*) from user_tab_columns u
      2  where u.table_name in
      3  (select u.table_name from dual d
      4  );
    
      COUNT(*)
    ----------
          3553
    
    SQL> 
    

    including.

    Published by: Sven w. on July 24, 2009 17:27

Maybe you are looking for