Query from User_Scheduler_Jobs returns no rows in version 2.1.0.63

Using version 2.1.0.63, "select * from user_scheduler_jobs;" returns no rows. It works ok in version 1.5.5.
Edited by: User65423 on Feb 8, 2010 9:24 AM

Refer to this thread, where the cause seems to be due to SQL Developer not handling null interval data types.
bug? F9 gives no output dba_scheduler_jobs, version: 2.1.0.63.73
As mentioned in that thread you can use to_char on the interval columns as a work-around...
SELECT source,
destination,
comments,
flags,
job_name,
job_creator,
client_id,
global_uid,
program_owner,
program_name,
job_type,
job_action,
number_of_arguments,
schedule_owner,
schedule_name,
start_date,
repeat_interval,
end_date,
job_class,
enabled,
auto_drop,
restartable,
state,
job_priority,
run_count,
max_runs,
failure_count,
max_failures,
retry_count,
last_start_date,
TO_CHAR(last_run_duration),
next_run_date,
TO_CHAR(schedule_limit),
TO_CHAR(max_run_duration),
logging_level,
stop_on_window_close,
instance_stickiness,
system,
job_weight,
nls_env
FROM user_scheduler_jobs a;

Similar Messages

  • SQL Query (PL/SQL Function Body returning SQL query) doesn't return any row

    I have a region with the following type:
    SQL Query (PL/SQL Function Body returning SQL query).
    In a search screen the users can enter different numbers, separated by an ENTER.
    I want to check these numbers by replacing the ENTER, which is CHR(13) || CHR(10) I believe, with commas. And then I can use it like this: POD IN (<<text>>).
    It's something like this:
    If (:P30_POD Is Not Null) Then
    v_where := v_where || v_condition || 'POD IN (''''''''||REPLACE(''' || :P30_POD || ''', CHR(13) || CHR(10), '','')||'''''''''')';
    v_condition := ' AND ';
    End If;
    But the query doesn't return any rows.
    I tried to reproduce it in Toad:
    select * from asx_worklistitem
    where
    POD IN (''''||REPLACE('541449200000171813'||CHR(13) || CHR(10)||'541449206006341366', CHR(13) || CHR(10), ''',''')||'''')
    ==> This is the query that does't return any rows
    select (''''||REPLACE('541449200000171813'||CHR(13) || CHR(10)||'541449206006341366', CHR(13) || CHR(10), ''',''')||'''')
    from dual;
    ==> This returns '541449200000171813','541449206006341366'
    select * from asx_worklistitem
    where pod in ('541449200000171813','541449206006341366');
    ==> and when I copy/paste this in the above query, it does return my rows.
    So why does my first query doesn't work?
    Doe anyone have any idea?
    Kind regards,
    Geert
    Message was edited by:
    Zorry

    Thanks for the help.
    I made it work, but via the following code:
    If (:P30_POD Is Not Null) Then
    v_pods := REPLACE(:P30_POD, CHR(13) || CHR(10));
    v_where := v_where || v_condition || 'POD IN (';
    v_counter := 1;
    WHILE (v_counter < LENGTH(v_pods)) LOOP
    v_pod := SUBSTR(v_pods, v_counter, 18);
    IF (v_counter <> 1) THEN
    v_where := v_where || ',';
    END IF;
    v_where := v_where || '''' || v_pod || '''';
    v_counter := v_counter + 18;
    END LOOP;
    v_where := v_where || ')';
    v_condition := ' AND ';
    End If;But now I want to make an update of all the records that correspond to this search criteria. I can give in a status via a dropdownlist and that I want to update all the records that correspond to one of these POD's with that status.
    For a region you can build an SQL query via PL/SQL, but for a process you only have a PL/SQL block. Is the only way to update all these records by making a loop and make an update for every POD that is specified.
    Because I think this will have a lot of overhead.
    I would like to make something like a multi row update in an updateable report, but I want to specify the status from somewhere else. Is this possible?

  • 'select count(*) from x' returns 5460 rows and 'Select * from x' returns 0 rows

    As you can see in the next lines something is wrong in my Oracle (8.0.6 on Win NT 4.0 sp 6a) :
    Oracle8 Enterprise Edition Release 8.0.6.0.0 - Production
    With the Partitioning option
    PL/SQL Release 8.0.6.0.0 - Production
    SQLWKS> SELECT * FROM V_TERRA_TE;
    PERIOD_DATE PERIOD_TIME TERRARCV TERRASND TERCV TESND
    0 rows selected.
    SQLWKS> SELECT COUNT(*) FROM V_TERRA_TE;
    COUNT(*)
    5460
    1 row selected.
    V_TERRA_TE is a complex join of 5 Tables :
    CREATE OR REPLACE VIEW "ACTUATE".V_TERRA_TE AS Select to_date(to_char(p1.period_date,'YYYYMMDD'),'YYYYMMDD') "PERIOD_DATE",
    to_date(to_char(p1.period_time,'HH24:MI'),'HH24:MI') "PERIOD_TIME",
    to_number(p1.caudalrcv + ((p3.caudalrcv + p4.caudalrcv)*(confterrate.conexadslterra/confterrate.conexadsltotal))) "TERRARCV",
    to_number(p1.caudalsnd + ((p3.caudalsnd + p4.caudalsnd)*(confterrate.conexadslterra/confterrate.conexadsltotal))) "TERRASND",
    to_number((p2.caudalrcv * confterrate.pctinfonegocio) + ((p3.caudalrcv + p4.caudalrcv)*(confterrate.conexadslte/confterrate.conexadsltotal)))"TERCV",
    to_number((p2.caudalsnd * confterrate.pctinfonegocio) + ((p3.caudalsnd + p4.caudalsnd)*(confterrate.conexadslte/confterrate.conexadsltotal)))"TESND"
    from p1,p2,p3,p4,confterrate
    where (p1.period_date=p2.period_date)and
    (p1.period_date=p3.period_date)and
    (p1.period_date=p4.period_date)and
    (p1.period_time=p3.period_time)and
    (p1.period_time=p4.period_time)and
    (p1.period_time=p2.period_time)and
    to_char(p1.period_date,'MMYYYY')=to_char(confterrate.period_datetime,'MMYYYY');
    I think that some not reported error happens in the select * with some temporary space or similar but only the message '0 rows selected' is displayed (instead the real error)
    Could somebody help me ?
    Thanks in advance
    Francisco

    Forcing the Join/sort to be made on Disk (not on memory) the problem not happens. This demostrate that ORACLE has a VERY IMPORTANT BUG : It returns 0 rows wich is false.
    To force it to work on disk i use this parameters :
    alter session set sort_area_size=0
    alter session set hash_join_enabled=false
    Note : probably is not the best combination or use of parameters, but using it the query works as espected.

  • Procedure from PowerBuilder returning multiple rows

    In want to call a procedure from PowerBuilder which return multiple rows. I would like to know how to write the procedure and also how to call it. I tried using REFCURSOR , but i heard that Powerbuilder doesnot support REFCURSOR . Please help
    Thanks in advance

    This is not a PL/SQL qustion, but a Powerbuilder question.
    Just what SQL constructs does Powerbuilder supports? And if there is no support for ref cursors, then the choice of using a client language that lacks basic core SQL support is questionable.

  • Query with XMLTABLE returns null rows

    Hello all,
    I'm trying a query with XMLTABLE, but even thought the number of returned rows is correct, the row content is (null).
    DB version is: 10.2.0.4.0
    Here is my query;
    SELECT s.DESCRIPTION
    FROM EXECUTIONPLAN p,
      XMLTABLE
      ('//executionPlan/executionPlanItems/summary'  
       PASSING p.DATA
       COLUMNS
         DESCRIPTION VARCHAR(250) PATH '/taskId'
      ) s
    WHERE
    trunc(extractValue(data, '/executionPlan/executionPlanHeader/statusChanged')) = to_date('2010-03-05','YYYY-MM-DD');Sorry the XML content is quite big -50k lines at average- so can't post the whole XML, but to give an idea;
    /executionPlan
       /executionPlan
          /executionPlanHeader
             /statusChanged
             /x
             /y
          /executionPlanItems
             /summary
                /taskId
             /summary
             /summary
             ...The result looks like;
    1 (null)
    2 (null)
    3 (null)
    4 (null)
    ...Suggestions are very much appreciated :)
    Cheers

    Hi guys,
    Cracked it at last. It seems the column definition part does not like the forward slash in front of it. The following works;
    SELECT s.DESCRIPTION
    FROM EXECUTIONPLAN p,
      XMLTABLE
      ( XmlNamespaces(DEFAULT 'http://www.staffware.com/frameworks/gen/valueobjects'),
       '/executionPlan/executionPlanItems/summary'  
       PASSING p.DATA
       COLUMNS
         DESCRIPTION VARCHAR(250) PATH 'taskId'
      ) s
    WHERE
    trunc(extractValue(p.data, '/executionPlan/executionPlanHeader/statusChanged'
                             , 'xmlns="http://www.staffware.com/frameworks/gen/valueobjects"')) = to_date('2010-03-05','YYYY-MM-DD');I'm not sure if this is the way it is intended since it seems a bit weird to me and is not in line with the docs - or at least my understanding of them.
    Thanks for taking the time to help out. Now on to coding :)

  • C# : Get Column name for an Insert Query from The Selected GridView Row.

    Hi Guys, I am trying to insert data in an SQL table by executing an Insert Query. 
    The problem is that I need to get the column name from a cell in the selected gridview Row.
    Here's the snippet:
    SqlCommand cmd30 = new SqlCommand("insert into mytable ( '"+GridView7.SelectedRow.Cells[0].Text+"' , r_id) values ('"+ GridView7.SelectedRow.Cells[1].Text +"', '"+TextBox1.Text+"')",con30);
            cmd30.ExecuteNonQuery();
    **r_id is not a Primary Key.
    The Error is get is:
    Incorrect syntax near 'r_id'.
    Any Help will be appreciated.
    Thanks,
    Shaleen
    TheHexLord

    Hi TheShaleen,
    Like your title mentioned.GridView control is a web class.This forum is to discuss problems of C# development.  Your question is not related to the topic of this forum.
    You'll need to post it in the dedicated ASP.Net Forum  for more efficient responses, where you can contact ASP.NET experts. Thanks for understanding.
    Best regards,
    Kristin
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Bug Report: ResultSet.isLast() returns false when queries return zero rows

    When calling the method isLast() on a resultset that contains zero (0) rows, false is returned. If a resultset contains no rows, isLast() should return true because returning false would indicate that there are more rows to be retrieved.
    Try the following Java source:
    import java.io.*;
    import java.sql.*;
    import java.util.*;
    import oracle.jdbc.driver.*;
    public class Test2 {
    public static void main (String [] args) throws Exception {
    Connection conn = null;
    String jdbcURL = "jdbc:oracle:thin:@" +
    "(DESCRIPTION=(ADDRESS=(HOST=<host computer>)"+
    "(PROTOCOL=tcp)(PORT=<DB port number>))"+
    "(CONNECT_DATA=(SID=<Oracle DB instance>)))";
    String userId = "userid";
    String password = "password";
    try{
    // Load the Oracle JDBC Driver and register it.
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    // *** The following statement creates a database connection object
    // using the DriverManager.getConnection method. The first parameter is
    // the database URL which is constructed based on the connection parameters
    // specified in ConnectionParams.java.
    // The URL syntax is as follows:
    // "jdbc:oracle:<driver>:@<db connection string>"
    // <driver>, can be 'thin' or 'oci8'
    // <db connect string>, is a Net8 name-value, denoting the TNSNAMES entry
    conn = DriverManager.getConnection(jdbcURL, userId, password);
    } catch(SQLException ex){ //Trap SQL errors
    // catch error
    //conn = new OracleDriver().defaultConnection(); // Connect to Oracle 8i (8.1.7), use Oracle thin client.
    PreparedStatement ps = conn.prepareStatement("select 'a' from dual where ? = ?", ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); // Use any query that will return zero rows.
    ps.setInt(1, 1); // Set the params so that the query returns 0 rows.
    ps.setInt(2, 2);
    ResultSet rs = ps.executeQuery();
    System.out.println("1. Last here? " + rs.isLast());
    while (rs.next()) {
    // do whatever
    System.out.println("2. Last here? " + rs.isLast());
    ps.close();
    rs.close();
    EXPECTED RESULT -
    1. Last here? true
    2. Last here? true
    ACTUAL RESULT -
    1. Last here? false
    2. Last here? false
    This happens to me on Oracle 9.2.0.1.0.

    387561,
    For your information, I discovered this problem from
    running a query that did access an actual DB table.
    Try it and let me know.I did say I was only guessing, and yes, I did try it (after I posted my reply, and before I read yours). And I did check the query plan for the queries I tried -- to verify that they were actually doing some database "gets".
    In any case, the usual way that I determine whether a "ResultSet" is empty is when the very first invocation of method "next()" returns 'false'. Is that not sufficient for you?
    Good Luck,
    Avi.

  • Query executed within a plug-in script returns 0 rows, although data exists

    I created a plug-in script for algorithm entity: Service Quantity Rule.
    The script calls a business service that I created using query zones. The query returns the values of the bill segment (ci.bseg.bseg_id and ci_bseg.closing_bseg_sw) that is created while running a bill manually. The zone receives the bseg_id as a parameter.
    The problem is that when I execute the business service within the plug-in script the business services returns 0 rows even though the data is actually being stored in the database.
    The script calculates some SQI values and saves it to the bill segment based on a response that is received from MDM (I'm using the usage request object).
    Steps:
    1.- Create Bill. The bill segment is created in error as it is waiting for the bill determinants to be sent from the MDM. If I test the zone with the bseg_id (as a parameter) of the newly created bill segment it works fine.
    2.- We send a message from the MDM to CC&B. The message is received and processed and it gets to a point when the usage updates the bill segment.
    3.- After the bill segment has been updated with the values from the usage request object it starts executing the plug-in script.
    4.- I obtain the bseg_id from the usage request and use the business service (passing the bseg_id as a parameter) and it returns no result.
    5.- The process finishes and if test the zone with the bseg_id (as a paramter) of the billing segment it works fine.
    So apparently during the execution of the script after the billing determinants are received from MDM I can't have access to the Bill segment that was created, even if the physically the record exists in the database (CI_BSEG).
    I also tried instantiating an object related with the bill segment and got the same result.
    Any idea or clue of what is happening?

    Could you be more explicit.
    What CC&B version?
    What MDM version?
    More details are required for:
    2.- We send a message from the MDM to CC&B. The message is received and processed and it gets to a point when the usage updates the bill segment.
    3.- After the bill segment has been updated with the values from the usage request object it starts executing the plug-in script.
    4.- I obtain the bseg_id from the usage request and use the business service (passing the bseg_id as a parameter) and it returns no result.

  • WITH clause query:- Returns No Rows

    Hi,
    I am using the following query with, WITH clause, but some how it give "0 rows" returned,
    The underlying query does returns row when run in stand alone mode,
    With v_score_his_old
    As
    SELECT schs_run_date,schs_loc_shortcut_source,schs_lot_number,schs_facility_new,schs_facility_old, schs_operation_new,
    schs_operation_old,schs_route_new,schs_route_old,schs_product_new,schs_product_old,schs_owner_old,schs_intransit,
    schs_date,schs_transaction,schs_quantity_1_new,schs_quantity_1_old,/*0,*/schs_if_count_new,schs_if_count_old,
    schs_preprocessed,schs_consumed_quantity,/*'Y',*/schs_if_id,schs_if_id_old,fif_fac_loc_id
    FROM scm_score_his,full_item_facilities,location_params
    WHERE schs_state = 0
    AND fif_if_id = schs_if_id_old
    AND lopo_param_value = to_char(fif_site_id_fm)
    AND lopo_param_name IN ('SITE_FAB', 'SITE_SORT')
    AND (schs_loc_shortcut_source = 'MP' OR schs_loc_shortcut_source = 'RE' OR schs_loc_shortcut_source = 'VI')
    UNION ALL
    SELECT schb_run_date,schb_loc_shortcut_source,schb_lot_number,schb_facility_new,schb_facility_old,schb_operation_new,
    schb_operation_old,schb_route_new,schb_route_old,schb_product_new,schb_product_old,schb_owner_old,schb_intransit,
    schb_date,schb_transaction,schb_quantity_1_new,schb_quantity_1_old,/*0,*/schb_if_count_new,schb_if_count_old,schb_preprocessed,
    schb_consumed_quantity,/*'Y',*/schb_if_id,schb_if_id_old,fif_fac_loc_id
    FROM scm_score_his_backups,full_item_facilities,location_params
    WHERE schb_state = 0
    AND fif_if_id = schb_if_id_old
    AND lopo_param_value = to_char(fif_site_id_fm)
    AND lopo_param_name IN ('SITE_FAB', 'SITE_SORT')
    AND schb_date >= trunc(sysdate - 84)
    AND (schb_loc_shortcut_source = 'MP' OR schb_loc_shortcut_source = 'RE' OR schb_loc_shortcut_source = 'VI')
    Select schs_run_date,schs_loc_shortcut_source,schs_lot_number
    From v_score_his_old
    Where schs_loc_shortcut_source = 'MP';
    Oracle version is Oracle9i Enterprise Edition Release 9.2.0.6.0
    I am not able to get where I can going wrong.
    Please help me to understand this issue,
    Regards
    Umesh..

    With v_score_his_old
    As
    SELECT
    schs_run_date,schs_loc_shortcut_source,schs_lot_numbe
    ,schs_facility_new,schs_facility_old,
    schs_operation_new,
    chs_operation_old,schs_route_new,schs_route_old,schs_p
    roduct_new,schs_product_old,schs_owner_old,schs_intran
    sit,
    chs_date,schs_transaction,schs_quantity_1_new,schs_qua
    ntity_1_old,/*0,*/schs_if_count_new,schs_if_count_old,
    chs_preprocessed,schs_consumed_quantity,/*'Y',*/schs_i
    f_id,schs_if_id_old,fif_fac_loc_id
    FROM
    cm_score_his,full_item_facilities,location_params
    WHERE schs_state = 0
    AND fif_if_id = schs_if_id_old
    AND lopo_param_value =
    to_char(fif_site_id_fm)
    AND lopo_param_name IN ('SITE_FAB',
    'SITE_SORT')
    AND (schs_loc_shortcut_source = 'MP' OR
    schs_loc_shortcut_source = 'RE' OR
    schs_loc_shortcut_source = 'VI')
    UNION ALL
    SELECT
    schb_run_date,schb_loc_shortcut_source,schb_lot_number
    ,schb_facility_new,schb_facility_old,schb_operation_ne
    w,
    chb_operation_old,schb_route_new,schb_route_old,schb_p
    roduct_new,schb_product_old,schb_owner_old,schb_intran
    sit,
    chb_date,schb_transaction,schb_quantity_1_new,schb_qua
    ntity_1_old,/*0,*/schb_if_count_new,schb_if_count_old,
    schb_preprocessed,
    chb_consumed_quantity,/*'Y',*/schb_if_id,schb_if_id_ol
    d,fif_fac_loc_id
    FROM
    cm_score_his_backups,full_item_facilities,location_par
    ams
    WHERE schb_state = 0
    AND fif_if_id = schb_if_id_old
    AND lopo_param_value =
    to_char(fif_site_id_fm)
    AND lopo_param_name IN ('SITE_FAB',
    'SITE_SORT')
    AND schb_date >= trunc(sysdate - 84)
    AND (schb_loc_shortcut_source = 'MP' OR
    schb_loc_shortcut_source = 'RE' OR
    schb_loc_shortcut_source = 'VI')
    ect
    schs_run_date,schs_loc_shortcut_source,schs_lot_number
    From v_score_his_old
    Where schs_loc_shortcut_source = 'MP';
    Hi!
    I've a doubt. If u finally picking all the values which matched with field schs_loc_shortcut_source and which is 'MP' - then why r u using multiple condition in the WITH part? So, in that case, u don't have to write that additional filtering of the following lines in the outer query -
    Where schs_loc_shortcut_source = 'MP';Regards.
    Satyaki De.

  • Query to return separate rows for date range including NULLs

    I'm trying to write a query that will return all customers from table 1. Table 1 also provides a start date and an end date that may be different for different customers. Left join with Table 2  provides all matches and NULL if NO matches.
    If there is any match at all, I do not get the NULLs for other dates. There should be a match for each date from start to end. How can I write the code so that my return will loop thru each date and provide the match or NULL?

    Sorry. I am somewhat new to this and am not sure what you are requesting. I receive a return of all customers with the code below but if customer 1 has a start date of 1/1/15 and a stop date of 1/5/15 and a document exists for 1/1/15 and 1/3/15
    I do not receive the rows with NUL for 1/2/15, 1/4/15, and 1/5/15 which is what I'm trying to accomplish. If there is no match at all, I only receive the one row with NULL and I would like to see a row for each date from start to stop.
    SELECT  T1.IDNumber,T1.StartDate,T1.StopDate,T3.SignDateTime
    FROM
    Table1 T1
    INNER
    JOIN Table2
    T2
    ON
    T1.CustID
    = T2.CustID
    LEFT
    JOIN Table3
    T3
    ON
    T1.CustID
    = T3.CustID
    WHERE
    T1.StartDate
    > '2015-01-20 00:00:00.000'
    AND
    (T3.ReportID
    IN ('DOC1',
    'DOC2',
    'DOC3') OR
    T3.ReportID
    IS NULL)
    AND
    T2.YesNo
    = 'Y'

  • Query to return ALL rows even those with zero counts

    Hi,
    The following query will return only those rows that have a non zero count value:
    select c.id, a.name, count(*) as XYZ from CON c, CUST a
    where c.help !='1' and (c.id = a.id) group by c.id, a.name order by c.id;
    The results are:
    1 ME 3
    3 YOU 4
    What i want is to return all rows in CUST and the count, XYZ, that correspond to each row in CUST that matches the whare condition above, even if the count is zero.
    ie
    1 ME 3
    2 WE 0
    3 YOU 4
    Can this be done?

    You may want to get the counts then do the outer join. If you simply count with an outer join you will get 1 for 'WE' because there is a row in the cust table with 'WE'. This may work for you;
    with
      cust as (
       select 1 id, 'ME' name from dual union all
       select 2 id, 'YOU' name from dual union all
       select 3 id, 'WE' name from dual),
      con as (
       select 1 id, '2' help from dual union all
       select 1 id, '2' help from dual union all
       select 1 id, '2' help from dual union all
       select 2 id, '2' help from dual union all
       select 2 id, '2' help from dual union all
       select 2 id, '2' help from dual union all
       select 2 id, '2' help from dual)
    -- end of test data 
    select a.id, a.name, nvl(c.cnt,0) xyz
    from cust a, 
       (select id, help, count(*) cnt
       from con
       where help !='1'
       group by id, help) c
    where a.id = c.id(+)

  • Silly old fogey (me) cannot figure out why this query returns 1 row

    Hi all,
    In reference to {thread:id=2456973}, why does
    select sum(count(decode(job, 'CLERK', 1, null))) CLERKS
    , sum(count(decode(job, 'SALESMAN', 1, null))) SALESMANS
    from emp group by job;only return 1 row and not 1 for each job? I actually had to test it myself to believe it.
    It returns data as if the query were
    select sum(CLERKS), sum(SALESMANS)
    from (select count(decode(job, 'CLERK', 1, null)) CLERKS, count(decode(job, 'SALESMAN', 1, null)) SALESMANS
             from emp group by job)Using only a single aggregate (either count or sum) returns 1 row per job, as expected

    John Stegeman wrote:
    It returns data as if the query were
    select sum(CLERKS), sum(SALESMANS)
    from (select count(decode(job, 'CLERK', 1, null)) CLERKS, count(decode(job, 'SALESMAN', 1, null)) SALESMANS
    from emp group by job)
    Exactly the point ;-)
    Seems like Oracle actually can do a "double group by" in the same operation.
    Witness the explain plans in this example:
    SQL> select count(decode(job, 'CLERK', 1, null)) CLERKS
      2       , count(decode(job, 'SALESMAN', 1, null)) SALESMANS
      3  from scott.emp group by job;
        CLERKS  SALESMANS
             0          0
             0          0
             0          0
             0          4
             4          0
    Execution Plan
    Plan hash value: 1697595674
    | Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT   |      |     5 |    40 |     4  (25)| 00:00:01 |
    |   1 |  HASH GROUP BY     |      |     5 |    40 |     4  (25)| 00:00:01 |
    |   2 |   TABLE ACCESS FULL| EMP  |    14 |   112 |     3   (0)| 00:00:01 |
    ---------------------------------------------------------------------------And compare it to this one with the double aggregates:
    SQL> select sum(count(decode(job, 'CLERK', 1, null))) CLERKS
      2       , sum(count(decode(job, 'SALESMAN', 1, null))) SALESMANS
      3  from scott.emp group by job;
        CLERKS  SALESMANS
             4          4
    Execution Plan
    Plan hash value: 417468012
    | Id  | Operation           | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT    |      |     1 |     8 |     4  (25)| 00:00:01 |
    |   1 |  SORT AGGREGATE     |      |     1 |     8 |     4  (25)| 00:00:01 |
    |   2 |   HASH GROUP BY     |      |     1 |     8 |     4  (25)| 00:00:01 |
    |   3 |    TABLE ACCESS FULL| EMP  |    14 |   112 |     3   (0)| 00:00:01 |
    ----------------------------------------------------------------------------There is both HASH GROUP BY and SORT AGGREGATE.
    It does not really make sense to do an aggregate on an aggregate - if both aggregates are used "on the same group-by level".
    The sum() aggregates are used upon an already aggregated value, so it does look like Oracle actually treats that as "first do the inner aggregate using the specified group by and then do the outer aggregate on the result with no group by."
    Look at this example where I combine "double" aggregates with "single" aggregates:
    SQL> select sum(count(decode(job, 'CLERK', 1, null))) CLERKS
      2       , sum(count(decode(job, 'SALESMAN', 1, null))) SALESMANS
      3       , count(decode(job, 'SALESMAN', 1, null)) SALESMANS2
      4       , count(*) COUNTS
      5  from scott.emp group by job;
        CLERKS  SALESMANS SALESMANS2     COUNTS
             4          4          1          5
    Execution Plan
    Plan hash value: 417468012
    | Id  | Operation           | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT    |      |     1 |     8 |     4  (25)| 00:00:01 |
    |   1 |  SORT AGGREGATE     |      |     1 |     8 |     4  (25)| 00:00:01 |
    |   2 |   HASH GROUP BY     |      |     1 |     8 |     4  (25)| 00:00:01 |
    |   3 |    TABLE ACCESS FULL| EMP  |    14 |   112 |     3   (0)| 00:00:01 |
    ----------------------------------------------------------------------------When mixing "double" and "single" aggregates, Oracle decides that single aggregates belong in the "outer" aggregation.
    SALESMAN2 is doing a count on the aggregated job column that is the result of the "inner" group by - therefore only 1.
    The count(*) also counts the result of the "inner" aggregation.
    I am not sure if this is documented or if it is a "sideeffect" of either the internal code used for GROUPING SETS or the internal code used for allowing analytic functions like this:
    SQL> select count(decode(job, 'CLERK', 1, null)) CLERKS
      2       , count(decode(job, 'SALESMAN', 1, null)) SALESMANS
      3       , sum(count(decode(job, 'CLERK', 1, null))) over () CLERKS2
      4       , sum(count(decode(job, 'SALESMAN', 1, null))) over () SALESMANS2
      5  from scott.emp group by job;
        CLERKS  SALESMANS    CLERKS2 SALESMANS2
             0          0          4          4
             4          0          4          4
             0          0          4          4
             0          0          4          4
             0          4          4          4
    Execution Plan
    Plan hash value: 4115955660
    | Id  | Operation           | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT    |      |     5 |    40 |     4  (25)| 00:00:01 |
    |   1 |  WINDOW BUFFER      |      |     5 |    40 |     4  (25)| 00:00:01 |
    |   2 |   SORT GROUP BY     |      |     5 |    40 |     4  (25)| 00:00:01 |
    |   3 |    TABLE ACCESS FULL| EMP  |    14 |   112 |     3   (0)| 00:00:01 |
    ----------------------------------------------------------------------------Personally I think I would have preferred if Oracle raised an error on this "double aggregation" and thus require me to write it this way (if that is the result I desired):
    select sum(CLERKS), sum(SALESMANS)
    from (select count(decode(job, 'CLERK', 1, null)) CLERKS, count(decode(job, 'SALESMAN', 1, null)) SALESMANS
             from emp group by job)I can not really think of good use-cases for the "double aggregation" - but rather that it could give you unnoticed bugs in your code if you happen to do double aggregation without noticing it.
    Interesting thing to know ;-)

  • ExecuteWithParams is not returning the rows from cache

    Hi,
    We have two VO's based on same entity ,whenever new row is inserted in one VO and we do executeWithParams on another VO ,It is not returning the rows which are uncommitted.
    I replaced the executeWithParams with a custom method in AM in which I am executing the query after applying the view criteria and setting query mode.Its returning rows which are uncommitted.
    Jdev Version which I am using is 11.1.1.7.0
    ExecuteWithParams used to work with uncommitted data in 11.1.1.6.0 .
    Do we need to raise a bug on framework or Am I missing something?
    Edited by: sharavnkumar_malla on Oct 18, 2012 1:02 AM

    Still the same answer, even after you updated the question. We (the public) don't have 11.1.1.7, know nothing about 11.1.1.7, and cannot help you with 11.1.1.7. Questions about internal builds belong on internal forums.

  • XML attributes makes my query return no rows

    Hello everyone,
    I've an odd problem.
    I'm querying some XML, but the attributes in one of the tags make my query return no rows; if I remove the attributes, then the query works as expected.
    The XML is below; it's the attributes in the Report tag that cause the issues:
    <result errorCode="0">
         <return>
              <Report
                   xsi:schemaLocation="Items_x0020_status_x0020_information http://******-****/ReportServer?%2FReports%2FContent%20Producer%20Reports%2FItems%20status%20information&amp;rs%3AFormat=xml&amp;rc%3ASchema=True"
                   Name="Items status information" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                   xmlns="Items_x0020_status_x0020_information">
                   <Tablix1>
                        <Details_Collection>
                             <Details ItemId="914P7" Username="test" user_role="IT"
                                  first_name="Barry" last_name="Donovan" organisation=""
                                  content_format="On_Screen" modified_date="26/05/2011 13:16:49"
                                  item_status="Draft" status_date="" component_name="" demand="" />
                        </Details_Collection>
                   </Tablix1>
              </Report>
         </return>
    </result>My query is:
         select
                a.item_id
               ,a.username
               ,a.user_role
               ,a.first_name
               ,a.last_name
               ,a.supplier_id
               ,a.format
               ,a.modified_date
               ,a.item_status
               ,a.completion_date
               ,a.component_code
             from   dual
                   ,xmltable
                    ('/result/return/Report/Tablix1/Details_Collection/Details'
                       passing p_xml
                       columns
                          item_id         varchar2(1000) path '@ItemId'
                         ,username        varchar2(1000) path '@Username'
                         ,user_role       varchar2(1000) path '@user_role'
                         ,first_name      varchar2(1000) path '@first_name'
                         ,last_name       varchar2(1000) path '@last_name'
                         ,supplier_id     varchar2(1000) path '@organisation'
                         ,format          varchar2(1000) path '@content_format'
                         ,modified_date   varchar2(1000) path '@modified_date'
                         ,item_status     varchar2(1000) path '@item_status'
                         ,completion_date varchar2(1000) path '@status_date'
                         ,component_code  varchar2(1000) path '@demand'
                    ) a;I've tried stripping out the attributes in the tag, which does work, but some of the XML I'm expecting back may be quite large (many records), so that caused issues in itself. I'd rather deal with it and not mess with the XML itself if possible.
    Any help would be hugely appreciated!
    Thank you very much in advance.
    Robin
    Edited by: User_resU on Apr 12, 2012 2:50 PM

    Example:
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select xmltype('<result errorCode="0">
      2     <return>
      3             <Report
      4                     xsi:schemaLocation="Items_x0020_status_x0020_information http://******-****/ReportServer?%2FReports%2FContent%20Producer%20Reports%2FItems%20status%20information&amp;rs%3AFormat=xml&amp;rc%3ASchema=True"
      5                     Name="Items status information" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      6                     xmlns="Items_x0020_status_x0020_information">
      7                     <Tablix1>
      8                             <Details_Collection>
      9                                     <Details ItemId="914P7" Username="test" user_role="IT"
    10                                             first_name="Barry" last_name="Donovan" organisation=""
    11                                             content_format="On_Screen" modified_date="26/05/2011 13:16:49"
    12                                             item_status="Draft" status_date="" component_name="" demand="" />
    13                             </Details_Collection>
    14                     </Tablix1>
    15             </Report>
    16     </return>
    17  </result>') as xml from dual)
    18  --
    19  -- end of test data
    20  --
    21       select
    22              a.item_id
    23             ,a.username
    24             ,a.user_role
    25             ,a.first_name
    26             ,a.last_name
    27             ,a.supplier_id
    28             ,a.format
    29             ,a.modified_date
    30             ,a.item_status
    31             ,a.completion_date
    32             ,a.component_code
    33           from   t
    34                 ,xmltable
    35                  (xmlnamespaces('Items_x0020_status_x0020_information' as "x0"),
    36                   '//x0:Report/x0:Tablix1/x0:Details_Collection/x0:Details'
    37                     passing xml
    38                     columns
    39                        item_id         varchar2(1000) path '@ItemId'
    40                       ,username        varchar2(1000) path '@Username'
    41                       ,user_role       varchar2(1000) path '@user_role'
    42                       ,first_name      varchar2(1000) path '@first_name'
    43                       ,last_name       varchar2(1000) path '@last_name'
    44                       ,supplier_id     varchar2(1000) path '@organisation'
    45                       ,format          varchar2(1000) path '@content_format'
    46                       ,modified_date   varchar2(1000) path '@modified_date'
    47                       ,item_status     varchar2(1000) path '@item_status'
    48                       ,completion_date varchar2(1000) path '@status_date'
    49                       ,component_code  varchar2(1000) path '@demand'
    50*                 ) a
    SQL> /
    ITEM_ID
    USERNAME
    USER_ROLE
    FIRST_NAME
    LAST_NAME
    SUPPLIER_ID
    FORMAT
    MODIFIED_DATE
    ITEM_STATUS
    COMPLETION_DATE
    COMPONENT_CODE
    914P7
    test
    IT
    Barry
    Donovan
    On_Screen
    26/05/2011 13:16:49
    Draft

  • Query from OCI-11.2.0.3 library to 10g Express DB not returning results

    Hi,
    I am trying to fetch column data using the following query run on 10g Express DB running on Windows 7.
    select a.column_name, a.data_type, a.data_length, a.NULLABLE, nvl(c.CONSTRAINT_TYPE, 0), nvl(e.index_type, 0) from
    dba_tab_cols a left join dba_cons_columns b on ( a.OWNER=b.owner and a.TABLE_NAME=b.TABLE_NAME and a.column_name=b.column_name)
    left join dba_constraints c on (b.CONSTRAINT_NAME=c.CONSTRAINT_NAME and b.OWNER=c.owner and b.TABLE_NAME=c.TABLE_NAME)
    left join dba_ind_columns d on ( a.OWNER=d.table_owner and a.TABLE_NAME=d.TABLE_NAME and a.column_name=d.column_name)
    left join dba_indexes e on (d.index_name=e.index_name and a.OWNER=e.owner and a.TABLE_NAME=e.TABLE_NAME)
    where a.table_name=:TBLNAME
    My VC++ application is linked against "instantclient-sdk-nt-11-2-0-3-0\lib\msvc\oci.lib".
    Calls to OCIStmtPrepare2 and following OCIBindByName are succeeding.
    text inputval[32] = {'\0'};
    ub2 inputvallen = 32;
    OCIBind *pbnd = 0;
    ret = OCIBindByName(stmthp, &pbnd, errhp, (text*)":TBLNAME",
    strlen(":TBLNAME"), (dvoid*)inputval,
    (sword)inputvallen, SQLT_STR, (dvoid*)0,
    (ub2*)0,(ub2*)0, (ub4)0, (ub4*)0, OCI_DEFAULT);
    I am setting the TBLNAME in single quotes in inputval variable before the call to OCIStmtExecute, which is also passing.
    But, OCIStmtFetch2 always returns 0 rows (OCI_NO_DATA).
    If I change this query to use the tablename explicitly in the above select statement, it works fine and I get rows > 0.
    What could be wrong in this call to OCIBindByName? Or is there a compatibility issue between OCI-11.2.0.3 library and 10g Express database?
    Please guide.
    Thanks and Regards,
    - ganesh

    What could be wrongDunno, if you can get the SQL working outside the OCI setup must be something else where the code isn't handling the :TBLNAME as expected.
    This forum {forum:id=168} may get better help there or one of the other programming forums.

Maybe you are looking for