Oracle 11g SUM function on the result of inner Select

The inner Select returns rows with the values. The outer select running on tthe result of inner select SUM the result of the inner select.
Although there are valid rows of the inner select the SUM in the outer SELECT return NVL. As a comment any aggregate function on the outer select returns NVL.
The query is below.
select a.yil,
a.ay,
sum(brut_prim),
sum(kom),
from (SELECT oid_pol_kesilen_acente,
to_char(pp.zeyil_tanzim_tar, 'yyyy') yil,
to_char(pp.zeyil_tanzim_tar, 'mm') ay,
sum(decode(substr(pp.no, 1, 1),
'T',
pp.zeyil_brut_prim_fark / 2,
pp.zeyil_brut_prim_fark)) -
sum(pp.zeyil_gv_fark) brut_prim,
sum(pp.zeyil_acente_kom_fark) kom
from pol_police pp, org_acente oa
WHERE SUBSTR(PP.NO, 1, 1) != 'D')
group by oid_pol_kesilen_acente,
to_char(pp.zeyil_tanzim_tar, 'yyyy'),
to_char(pp.zeyil_tanzim_tar, 'mm')) a
group by a.yil, a.ay, oid_pol_kesilen_acente
Edited by: [email protected] on May 7, 2010 2:09 AM
Edited by: [email protected] on May 7, 2010 2:31 AM

Hi,
please try the below sql:
select a.yil, a.ay, sum(brut_prim), sum(kom),
from (SELECT oid_pol_kesilen_acente,to_char(pp.zeyil_tanzim_tar, 'yyyy') yil, to_char(pp.zeyil_tanzim_tar, 'mm') ay,
sum(decode(substr(pp.no, 1, 1), 'T',nvl(pp.zeyil_brut_prim_fark,0) / 2,nvl(pp.zeyil_brut_prim_fark,0))) - sum(nvl(pp.zeyil_gv_fark,0)) brut_prim,
sum(nvl(pp.zeyil_acente_kom_fark,0)) kom
from pol_police pp, org_acente oa
WHERE SUBSTR(PP.NO, 1, 1) != 'D'
group by oid_pol_kesilen_acente,
to_char(pp.zeyil_tanzim_tar, 'yyyy'),
to_char(pp.zeyil_tanzim_tar, 'mm')
) a
group by a.yil, a.ay, oid_pol_kesilen_acente ;
Thanks,
Siva

Similar Messages

  • Oracle 11g Table function returns no records on first call

    Hello,
    On a Oracle 11g R2 I've a table function ( PIPELINED ) returning rows selected from a table.
    The first time the function is selected, in a session ( I've tried to disconnect and log in again ), it returns no rows.
    I've tried to log the call using DBMS_OUTPUT and from what I see the select on the table function returns no rows and no output is printed. So I presume Oracle is not calling the function.
    The same function on a similar environment ( same db versions, patches and database structure ) works fine. The second environment is a production environment so it has more memory and some other settings enabled.
    Does anyone know of settings that can relate to this behaviour ?
    Thanks in advance for the help.
    Regards,
    Stefano Muret

    Thank you for answering so fast.
    Here's the function code:
    FUNCTION template_parameters (iTemplate IN TEMPLATE_RAW_DATA.TMPL_ID%TYPE := NULL)
    RETURN table_type_tmpl_parameters PIPELINED
    IS
    li_exception INTEGER DEFAULT -20025;
    POUT_PARM TABLE_TYPE_TMPL_PARAMETERS;
    lt_parms table_type_tmpl_parms_raw;
    sParmCheck VARCHAR2(4000);
    iOccurrence INTEGER;
    BEGIN
    pOut_Parm := table_type_tmpl_parameters();
    pOut_Parm.EXTEND;
    select
    tmpl_id
    *,tmpl_name*
    *,replace(upper(trim(sql_out)),'[SCHEMA].')*
    *,UPPER(TRIM(out_tmpl_parms))*
    bulk collect into lt_parms
    from ref_templates
    where tmpl_id = NVL(iTemplate,tmpl_id)
    order by tmpl_id;
    FOR k IN 1..lt_parms.COUNT
    LOOP
    pOut_Parm(1).tmpl_id := lt_parms(k).tmpl_id;
    pOut_Parm(1).tmpl_name := lt_parms(k).tmpl_name;
    FOR i IN 1..2
    LOOP
    IF i = 1 THEN
    sParmCheck := lt_parms(k).sql_out;
    ELSE
    sParmCheck := lt_parms(k).sql_parms;
    END IF;
    iOccurrence := 1;
    *pOut_Parm(1).parameter_name := regexp_substr(sParmCheck,'\[[^\[]+\]',1,iOccurrence);*
    WHILE pOut_Parm(1).parameter_name IS NOT NULL
    LOOP
    PIPE ROW (pOut_Parm(1));
    iOccurrence := iOccurrence + 1;
    *pOut_Parm(1).parameter_name := regexp_substr(sParmCheck,'\[[^\[]+\]',1,iOccurrence);*
    END LOOP;
    END LOOP;
    END LOOP;
    RETURN;
    EXCEPTION
    WHEN OTHERS THEN
    RAISE_APPLICATION_ERROR(li_exception,SUBSTR(SQLERRM,1,1000));
    RETURN;
    END template_parameters;
    This function is part of a package.
    The data on both environments is the same.

  • Function that return the results of a select

    Hi,
    I would like to create a function on the famous HR oracle Departments table to select * from it. I don't know how to do it.
    Does anybody can help me?.
    Thank you

    Oracle stored functions cannot directly return result sets but can return REF CURSOR. Please read [Optimize Result Set Retrieval Using ODP.NET and Ref Cursors |http://www.oracle.com/technology/pub/articles/mastering_dotnet_oracle/williams_refcursors.html] which gives full examples in PL/SQL for server side and in VB. Net for client side.

  • XMLELEMENT/ XMLAGG functions - Fetching the result into a variable

    Hi, I have a query to generate an XML output. I have the following questions:
    1) I am typecasting the result from this query to a VARCHAR2 and I want to assign the output to a VARCHAR2 variable. Can you please help me with that. When I try to get this into a varchar variable, i get the following error:
    declare
    x varchar2(6000);
    begin
    SELECT CAST(xmlelement("itemMaster",
    xmlelement("itemNumber",lpad(d.dept_i,3,0)||lpad(d.class_i,2,0)||lpad(d.item_i,4,0)),
    xmlelement("itemDesc",NVL(d.ITEM_DESC_T,lpad(d.dept_i,3,0)||lpad(d.class_i,2,0)||lpad(d.item_i,4,0))),
    xmlelement("paltSize",p1_test),
    xmlelement("stdUOM",p1_test),
    xmlelement("sellByDayQty",d.sell_by_day_q),
    xmlelement("shflfUOM",p1_test),
    xmlelement("minShflfDayQty",d.min_shflf_day_q),
    xmlelement("itemCatgCode",NVL(d.dc_item_catg_c,'GM')),
    xmlelement("strgTempZoneCode",NVL(d.strg_tmpr_zone_c,'01')),
    xmlelement("retailAmt",retl_a),
    xmlelement("expireDateFlag",NVL(d.expire_date_f,'N')),
    xmlelement("randomWtFlag",NVL(d.rndm_wt_f,'N')),
    xmlelement("wetFlag",NVL(d.wet_f,'N')),
    xmlelement("areaCode",d.area_c),
    xmlelement("vcpQty",d.vcp_q),
    xmlelement("sspQty",d.ssp_q),
    xmlelement("hndlTypeCode",d.hndl_type_c),
    xmlelement("mstrPackTypeCode",d.mstr_pk_type_c),
    xmlelement("mstrItemTypeCode",NVL(d.mstr_item_type_c,'00')),
    xmlelement("sszCode",d.reg_ssz_excpt_c),
    xmlelement("agriFlag",NVL(d.agrl_f,'N')),
    xmlelement("itemRankCode",d.item_rank_c),
    xmlelement("hazardFlag",NVL(d.hazd_mtrl_f,'N')),
    xmlelement("createDate",to_char(d.create_d,'MM-DD-YYYY HH24:MI:SS')),
    xmlelement("updateDate",to_char(d.modf_ts,'MM-DD-YYYY HH24:MI:SS')),
    xmlelement("actvnDate",to_char(d.actvn_d,'MM-DD-YYYY HH24:MI:SS')),
    xmlelement("organicCode",d.ognc_c),
    xmlelement("lotCntlFlag",NVL(d.lot_cntl_f,'N')),
    xmlelement("flammableFlag",NVL(d.flam_c,'N')),
    xmlelement("recordMode",c.action_c),
    xmlelement("areaType",p1_test),
    xmlelement("uoms",
    xmlelement("uom",
    xmlelement("prodUOM",p1_test),
    xmlelement("ratioDen",p1_test),
    xmlelement("consldtRule",p1_test),
    xmlelement("unitWtQty",NVL(d.unit_wt_q,1)),
    xmlelement("vcpHeightQty",NVL(d.vcp_ht_q,1)),
    xmlelement("vcpWidthQty",NVL(d.vcp_wth_q,1)),
    xmlelement("vcpLengthQty",NVL(d.vcp_lgth_q,1)),
    xmlelement("layerQty",p1_test)
    (SELECT xmlelement("aliases",
    xmlagg(xmlelement("upcCode",trunc(b.bar_code_i))
    ORDER BY b.dept_i,b.class_i,b.item_i
    FROM dc_item_bar_code b,
    dc_item a
    WHERE a.dept_i = b.dept_i
    AND a.class_i = b.class_i
    AND a.item_i = b.item_i
    AND a.dept_i = c.dept_i
    AND a.class_i = c.class_i
    AND a.item_i = c.item_i
    AS VARCHAR2(4000)
    ) INTO x
    FROM dc_item d, item_wm_trigger_w c
    WHERE d.dept_i = c.dept_i
    AND d.class_i = c.class_i
    AND d.item_i = c.item_i;
    end;
    ERROR at line 1:
    ORA-06550: line 49, column 33:
    PLS-00306: wrong number or types of arguments in call to 'XMLAGG'
    ORA-06550: line 49, column 33:
    PL/SQL: ORA-00904: "XMLAGG": invalid identifier
    ORA-06550: line 4, column 1:
    PL/SQL: SQL Statement ignored
    When I run this query without the
    declare
    begin
    select....
    into...
    end
    construct, it's working perfectly fine.
    Any help would be greatly appreciated.
    Thanks,
    Nitin

    I think I confused you. The 'pre' tags are for this Oracle Forum ( not your code). If your code was formatted we can look at it better .
    For example, I have put your code in those tags(you won't see them), they are for the forum software to process.
    See, how I didn't lose the formatting?
    DECLARE
      x VARCHAR2(6000);
    BEGIN
      SELECT CAST(xmlelement("itemMaster",
                             xmlelement("itemNumber",
                                        lpad(d.dept_i, 3, 0) || lpad(d.class_i, 2, 0) ||
                                        lpad(d.item_i, 4, 0)),
                             xmlelement("itemDesc",
                                        NVL(d.ITEM_DESC_T,
                                            lpad(d.dept_i, 3, 0) ||
                                            lpad(d.class_i, 2, 0) ||
                                            lpad(d.item_i, 4, 0))),
                             xmlelement("paltSize", p1_test),
                             xmlelement("stdUOM", p1_test),
                             xmlelement("sellByDayQty", d.sell_by_day_q),
                             xmlelement("shflfUOM", p1_test),
                             xmlelement("minShflfDayQty", d.min_shflf_day_q),
                             xmlelement("itemCatgCode", NVL(d.dc_item_catg_c, 'GM')),
                             xmlelement("strgTempZoneCode",
                                        NVL(d.strg_tmpr_zone_c, '01')),
                             xmlelement("retailAmt", retl_a),
                             xmlelement("expireDateFlag", NVL(d.expire_date_f, 'N')),
                             xmlelement("randomWtFlag", NVL(d.rndm_wt_f, 'N')),
                             xmlelement("wetFlag", NVL(d.wet_f, 'N')),
                             xmlelement("areaCode", d.area_c),
                             xmlelement("vcpQty", d.vcp_q),
                             xmlelement("sspQty", d.ssp_q),
                             xmlelement("hndlTypeCode", d.hndl_type_c),
                             xmlelement("mstrPackTypeCode", d.mstr_pk_type_c),
                             xmlelement("mstrItemTypeCode",
                                        NVL(d.mstr_item_type_c, '00')),
                             xmlelement("sszCode", d.reg_ssz_excpt_c),
                             xmlelement("agriFlag", NVL(d.agrl_f, 'N')),
                             xmlelement("itemRankCode", d.item_rank_c),
                             xmlelement("hazardFlag", NVL(d.hazd_mtrl_f, 'N')),
                             xmlelement("createDate",
                                        to_char(d.create_d, 'MM-DD-YYYY HH24:MI:SS')),
                             xmlelement("updateDate",
                                        to_char(d.modf_ts, 'MM-DD-YYYY HH24:MI:SS')),
                             xmlelement("actvnDate",
                                        to_char(d.actvn_d, 'MM-DD-YYYY HH24:MI:SS')),
                             xmlelement("organicCode", d.ognc_c),
                             xmlelement("lotCntlFlag", NVL(d.lot_cntl_f, 'N')),
                             xmlelement("flammableFlag", NVL(d.flam_c, 'N')),
                             xmlelement("recordMode", c.action_c),
                             xmlelement("areaType", p1_test),
                             xmlelement("uoms",
                                        xmlelement("uom",
                                                   xmlelement("prodUOM", p1_test),
                                                   xmlelement("ratioDen", p1_test),
                                                   xmlelement("consldtRule", p1_test),
                                                   xmlelement("unitWtQty",
                                                              NVL(d.unit_wt_q, 1)),
                                                   xmlelement("vcpHeightQty",
                                                              NVL(d.vcp_ht_q, 1)),
                                                   xmlelement("vcpWidthQty",
                                                              NVL(d.vcp_wth_q, 1)),
                                                   xmlelement("vcpLengthQty",
                                                              NVL(d.vcp_lgth_q, 1)),
                                                   xmlelement("layerQty", p1_test))),
                             (SELECT xmlelement("aliases",
                                                xmlagg(xmlelement("upcCode",
                                                                  trunc(b.bar_code_i))
                                                       ORDER BY b.dept_i,
                                                       b.class_i,
                                                       b.item_i))
                                FROM dc_item_bar_code b, dc_item a
                               WHERE a.dept_i = b.dept_i
                                 AND a.class_i = b.class_i
                                 AND a.item_i = b.item_i
                                 AND a.dept_i = c.dept_i
                                 AND a.class_i = c.class_i
                                 AND a.item_i = c.item_i)) AS VARCHAR2(4000))
        INTO x
        FROM dc_item d, item_wm_trigger_w c
       WHERE d.dept_i = c.dept_i
         AND d.class_i = c.class_i
         AND d.item_i = c.item_i;
    END;
    /

  • TimeStampDiff function ROUNDing the result. How can we avoid this?

    Hi,
    I am using the following timestamp function:
    TIMESTAMPDIFF(SQL_TSI_HOUR, "SF_CS_CS_Fact"."Crtddt_Dt", "SF_Emlmssg_Sum_CS"."Initl Resp Tm")
    I notice that the result set is rounded off to the whole no.
    This is happening because OBIEE autimatically ROUNDS the difference of the timestamps whe using TIMESTAMPDIFF:
    select distinct D1.c1 as c1,
    D1.c2 as c2,
    D1.c3 as c3,
    D1.c4 as c4,
    D1.c5 as c5,
    D1.c6 as c6,
    D1.c7 as c7,
    D1.c8 as c8,
    D1.c9 as c9,
    D1.c10 as c10
    from
    (select D1.c1 as c1,
    D1.c2 as c2,
    D1.c3 as c3,
    D1.c4 as c4,
    D1.c5 as c5,
    D1.c6 as c6,
    D1.c7 as c7,
    D1.c8 as c8,
    D1.c9 as c9,
    D1.c10 as c10
    from
    (select 0 as c1,
    D1.c4 as c2,
    D1.c5 as c3,
    D1.c3 as c4,
    D1.c2 as c5,
    D1.c6 as c6,
    D1.c7 as c7,
    D1.c8 as c8,
    D1.c9 as c9,
    D1.c1 as c10,
    ROW_NUMBER() OVER (PARTITION BY D1.c2, D1.c3, D1.c4, D1.c5, D1.c6, D1.c7, D1.c8, D1.c9 ORDER BY D1.c2 ASC, D1.c3 ASC, D1.c4 ASC, D1.c5 ASC, D1.c6 ASC, D1.c7 ASC, D1.c8 ASC, D1.c9 ASC) as c11
    from
    (select distinct ROUND ( ( CAST(T14421.INITIAL_RESPONSE_TIME as DATE)  - CAST(T14963.CRTDDT_DT as DATE)  ) 24 ) as c1*,
    T14963.CRTDDT_DT as c2,
    T14963.CSNMBR as c3,
    T4813.FISCAL_YEAR_NAME as c4,
    T4813.FISCAL_QUARTER_NAME as c5,
    T14421.INITIAL_RESPONSE_TIME as c6,
    T14468.GRP as c7,
    T4813.FISCAL_YEAR_ID as c8,
    T4813.FISCAL_QUARTER_ID as c9
    from
    DW_SF_EMLMSSG_SUM_CS T14421,
    DW_SF_EMLMSSG_CS T14400,
    SF_ORGN_CS_DIM T14468,
    CIN_CALENDARS_DIM T4813,
    DW_SF_CS_CS T14963 /* SF_CS_CS_Fact */
    where ( T14400.PRNTID = T14963.ID and T4813.CALENDAR_KEY = T14963.CRDT_KEY and T14421.PRNTID = T14963.ID and T14400.STTS = '3' and T14468.ORGN_KEY = T14963.ORGN_KEY and T14963.TYP = 'CIN' and (T14963.CSNMBR in ('1103676964', '1103677035', '1103677076', '1103677285', '1103677303', '1103677369', '1103677389')) )
    ) D1
    ) D1
    where ( D1.c11 = 1 )
    ) D1
    order by c1, c8, c9, c7, c4, c5, c6, c10
    Please see the line in Bold in the query.
    I want to get the results in the actual decimal point and not the whole no. Is there a way that I can enable the TIMESTAMPDIFF not to ROUND by default.
    Any answers will be helpful.
    Thanks,

    When you specify in the interval in the first argument of TIMESTAMPDIFF you are implicitly telling OBIEE the level of precision that you want. For SQL_TSI_YEAR you are going to get integer values of whole years. if yo uneed to get more granular than that you need to use SQL_TSI_MONTH or WEEK.
    Also note, than when performing mathematical operations like divide an multiply, all elements of the calculation need to be a data type that can represent decimal values, or the result of the entire calc will always get converted to an integer.

  • Using Oracle 11g How to change the Log mode from NoArchieve to Archieve Log

    Hi,
    I currently using oracle 11g How can I change database from NoArchivelog node to Archivelog node using spfile.
    And where exactly the spfile will be located?
    My instance is EPM11 in my local oracle is present in D folder where can i found the pfile?
    In this path i found 1 pfile in my Local Machine
    "D:/Oracle/Product/11g/admin/epm11/pfile" .I have added the following commands in this pfile
    # Archive Log Destinations -benr(10/15/04)
    log_archive_dest_1='location=/u02/oradata/cuddle/archive'
    log_archive_start=TRUE
    Then i have ran the shutdown command.
    Database instance is showtdown.
    After that i am not able to perform startup.
    So please suggest me how to change the mode using SPfile and tell me the path where spfile and pfile should be located?
    And also do i need to set the "Oracle_Home" path in my environment variables"
    Thanks In Advance,
    Chandana

    user11225122 wrote:
    Hi,
    I currently using oracle 11g How can I change database from NoArchivelog node to Archivelog node using spfile.
    And where exactly the spfile will be located?
    My instance is EPM11 in my local oracle is present in D folder where can i found the pfile?
    In this path i found 1 pfile in my Local Machine
    "D:/Oracle/Product/11g/admin/epm11/pfile" .I have added the following commands in this pfile
    # Archive Log Destinations -benr(10/15/04)
    log_archive_dest_1='location=/u02/oradata/cuddle/archive'
    log_archive_start=TRUE
    Then i have ran the shutdown command.
    Database instance is showtdown.
    After that i am not able to perform startup.
    So please suggest me how to change the mode using SPfile and tell me the path where spfile and pfile should be located?
    And also do i need to set the "Oracle_Home" path in my environment variables"
    Thanks In Advance,
    Chandanaremove log_archive_start=TRUE from pfile (it is depricated from 10g onwards)
    SQL>startup nomount pfile="D:/Oracle/Product/11g/admin/epm11/pfile/initYOUR_SID_NAME.ora"
    SQL>Create spfile from pfile="D:/Oracle/Product/11g/admin/epm11/pfile/initYOUR_SID_NAME.ora"
    SQL>SHUT IMMEDIATE;
    SQL>STARTUP MOUNT
    SQL>ALTER DATABASE ARCHIVELOG;
    SQL>ALTER DATABASE OPEN;
    SQL>ARCHIVE LOG LIST;
    SQL>SHOW PARAMATER SPFILE;
    YOU WILL FIND THE LOCATION OF SPFILE
    SQL>

  • Migrating from Red Brick database to Oracle 11g -Need help with the process

    Hi,
    I am on this new project were we are migrating from IBM Red Brick Data Warehouse to Oracle 11g. We have a very tight time line. I was hoping if any of you have done this migration before and are willing to share their experience. Any help would be greatly appreciated. I would like to get a brief idea about how to go about the process.
    Thanks in advance!

    Hello,
    that is a matter of supply and demand, and as the demand to migrate Red Brick to Oracle RDBMS is very low, Oracle never included Red Brick into the migration tools.
    If you search in the forums for Red Brick, you will not find much more than this one from the year 2006:
    Re: Migration from rebrick 6.0.3 to Oracle 9i
    Options:
    In general we have the following options:
    1. Oracle Migration Workbench
    2. SQL Developer Migration Workbench
    3. Generic Connectivity
    4. SQL*Loader
    Regarding your dedicated foreign database, option 1 and 2 fail as those tools
    do not work against Red Brick DB.
    Generic Connectivity would be an option if you have an ODBC driver to this database.
    In this dedicated case, you can then set up generic connectivity (= a database
    link to the foreign database using odbc).
    The Oracle database we support generic connectivity can reside on Windows,
    Solaris, HP-UX, AIX and Linux.
    If the Oracle database is on any other platform, you might migrate to a
    database on this platform, then export the migrated DB and then load it into
    the real target db.
    Generic Connectivity will allow you to perform a SQL*Plus copy of tables; this
    means you can create tables like they are defined in your source and transfer
    the data to the Oracle db; but no procedures, triggers or anything coded can be
    transferred.
    Last option (4) is that you generate "flat files". This means ASCII-SPOOL
    Files and then import them using SQL*Loader. As far as I know there is no
    existing SQL*Loader sample file for Red Brick databases exports and you need to
    write them on your own.
    I recommend to read also the following note in My Oracle Support:
    Note 233876.1: Options for Connecting to Foreign Data Stores and Non-Oracle Databases
    Best regards
    Wolfgang

  • How to access oracle in javabeans and display the result in jsp

    In my project ,i use the javabean to access the database and do the calculations and i display the result in the jsp page,,,
    any body can help me with your precious codes
    kodi...

    any body can help me with your precious codesStepped in the wrong place, try reading something on JDBC.

  • Pass the results from a selection formula to the default values for a parameter field

    Post Author: kevans
    CA Forum: General
    Crystal 10 u2013 SQL 2000
    I want to create a parameter field that will display all of our IT Departments so the end user can select the one they want to run the report against, such as IT-Security, IT-Network, etc. about 40 in all.  BUT I donu2019t want this to be a static list where I type in all 40 depts in the default list, I was hoping I could do something more dynamic such a formula field that says u201C if {group.name startswith u2018ITu2019 then {group.name}u201D and then have the parameter field pull from this source.
    Iu2019m sure this has been answered in a previous post but Iu2019m not finding it.  I see stuff on creating a record selection formula such as u2018if {?group} like u2018IT-Secur*u2019 thenu2026u201D  but this leaves too much room for error if people donu2019t type the name correctly.  Maybe Iu2019m not using the record selection formula correctly?  Sorry if I offend anyone but I just upgraded from 8 to 10 and thought for sure this option would be in 10, perhaps built right into the parameter default value page where you can place in select criteria but NOTHING has changed.

    Post Author: sharonmtowler
    CA Forum: General
    if you are creating the parameters in the rpt file, it will only pull values you enter, or directly from the database
    in the record selection you can do something like this, so if they only enter the first 2 characters it should pick up only the IT etc.
    (if eft(,2)={?parameter} then true else ={?parameter})

  • Oracle 11g - how to disable the Static Type-Checking of XQuery Expressions

    Hi,
    I loaded XML files using pl/sql in Oracle 10 suggesfully and now after upgrading to 11g the thing doesn't work anymore.
    I believe the problem has to do with the DTD, the xml files structure is not as specified in the DTD. I did get away in Oracle 10 issuing the alter session set events ='31156 trace name context forever, level 2' in the code. Now this doesn't seem to have any effect. When loading the xml file I get the following error message
    "ORA-19276 XPST0005 - Xpath step specifies an invalid element/attribute name"
    How can I skip the checking as I can't change the DTD's.
    TIA,
    Kari

    DTD Support in Oracle XML DB
    A DTD is a set of rules that define the allowable structure of an XML document. DTDs are text files that derive their format from SGML and
    can be associated with an XML document either by using the <code>DOCTYPE</code> element or by using an external file through a DOCTYPE
    reference. In addition to supporting XML Schema, which provides a structured mapping to object-relational storage or binary XML storage,
    Oracle XML DB also supports DTD specifications in XML instance documents. Though DTDs are not used to derive the mapping, XML
    processors can still access and interpret the DTDs.
    Inline DTD Definitions
    When an XML instance document has an inline DTD definition, it isused during document parsing. Any DTD validations and entity
    declaration handling is done at this point. However, once parsed, theentity references are replaced with actual values and the original
    entity reference is lost.
    External DTD Definitions
    Oracle XML DB also supports external DTD definitions if they are stored in Oracle XML DB Repository. Applications needing to process an
    XML document containing an external DTD definition such as /public/flights.dtd, must first ensure that the DTD document is stored in Oracle XML DB at path /public/flights.xsd.
    .... thats all I could find...
    http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28369/xdb05sto.htm#sthref540
    Edited by: Marco Gralike on Feb 26, 2009 11:19 AM

  • Oracle 11g: How to ensure the same transaction across several BPEL calls?

    How to ensure transaction semantics across invocations of several BPEL services with a Database operations (Insert, update)? We are using transaction REQUIRED property in all of our BPELs. We are using webserive and JCA to access and modify the same row. Our code uses a combination of JCA, Spring bean, enity services, EJBs in these BPELs. The code can be more efficient, but, at this point, we have no option but to fix the transaction issue in this code. So, our question is how to ensure the same transaction context is used in all these BPELs to inser/update the same row? We have tried to set the GetUnitOfWork in the JCA Adapter but it did not provide any solution. Apaert from setting transaction in BPEL to REQUIRED and the JCA Adapter to use Unit of work, we are out of ideas. Any help is much apprecited. We are using Oracle SOA Suite 11g 11.1.1.5 version. --chary

    Hi,
    I can help you if you can describe the processes.
    There can be some difficulties when you try to use the same transaction especially when you use many DB transactions & BPEL processes.
    Using unit of work only ,might not be enough.
    Thanks
    Arik

  • How to JOIN the results of multiple SELECT statements

    Hello,
    I currently have a table where each row represents a single census date for a given tag number, where each tag number can have multiple census dates and data which are represented by their own row in the table.
    I currently have 2 SELECT statements that select all tag numbers given a census date, and would like to combine those 2 queries so that the data is presented in a manner such that for each tag number, instead of obtaining 2 rows for each tag number, I would be presented with 1 row for each tag number consisting of three columns: tag_number, data1, and data2.
    Both of the requested dates are not necessarily present for all tag numbers, and in the event that only one date is present, the other column should contain null, but if both dates are not present for a given tag number, the tag number is omitted.
    The two queries I would like to JOIN are:
    SELECT a.tag_number, a.data AS data1
    FROM tab1 a
    WHERE
    a.census_date='11/21/2009'and
    SELECT b.tag_number, b.data AS data2
    FROM tab2 b
    WHERE
    b.census_date='11/24/2009'The table from which I am selecting the data looks like such:
    tag_number  census_date     data
        1       11/21/2009      10
        1       11/23/2009      11
        1       11/24/2009      12
        2       11/19/2009      13
        2       11/21/2009      14And the data that I would like to result looks like:
    tag_number  data1           data2
        1       10              12
        2       14              nullAny help would be greatly appreciated.
    Thank you in advance,
    -Justin
    Edited by: m8r-qbkka9 on Nov 24, 2009 4:17 PM

    Hi,
    This looks like a job for pivot
    SELECT       a.tag_number
    ,       MAX (CASE  WHEN a.census_date = TO_DATE ('11/21/2009'
                                                       'MM/DD/YYYY'
                   THEN a.data
                END
               )          AS data1
    ,       MAX (CASE  WHEN a.census_date = TO_DATE ('11/24/2009'
                                                       'MM/DD/YYYY'
                   THEN a.data
                END
               )          AS data2
    FROM      tab1    a
    WHERE       a.census_date  IN ( TO_DATE ( '11/21/2009'
                                      , 'MM/DD/YYYY'
                       , TO_DATE ( '11/21/2009'
                                      , 'MM/DD/YYYY'
    GROUP BY  a.tag_number
    ;Comparing DATEs to stirngs, like '11/24/2009', is simply asking for trouble.
    Always use a conversion function (like TO_DATE) or DATE literals instead.

  • How do I return the results of two SELECT statements in to one result?

    I want to do this without using UNION.
    Here's an example of what I'm trying to do:
    I have a table called COUNTRY with the following columns:
    COUNTRY
    COUNTRY_CODE
    DATE_VISITED_LAST
    POPULATIONI have another table called STATE_COUNTY with the following columns:
    STATE_COUNTY
    COUNTRY_CODE
    STATE_COUNTY_CODE
    DATE_LAST_VISITED
    POPULATIONI have a third table called TOWN with the following columns:
    TOWN
    COUNTRY_CODE
    STATE_COUNTY_CODE
    TOWN_CODE
    DATE_LAST_VISITED
    POPULATIONNow through the interface I have, a user will supply a country code. I need a SELECT statement that will return a table with the following result set:
    The COUNTRY_CODE entered including the DATE_LAST_VISITED and POPULATION for this country
    ------> All the associated STATE_COUNTY's belonging to this country along with the DATE_LAST_VISITED and POPULATION for each STATE_COUNTY_CODE.
    -------------> All the associated TOWN_CODE's belonging to this state_county and country along with the DATE_LAST_VISITED and population for each TOWN.
    So the table will have 9 columns:
    COUNTRY
    DATE_LAST_VISITED_COUNTRY
    POPULATION_COUNTRY
    STATE_COUNTY
    DATE_LAST_VISITED_STATE_COUNTY
    POPULATION_COUNTY
    TOWN
    DATE_LAST_VISITED_TOWN
    POPULATION_TOWNAny ideas how this can be done?
    Thanks.

    Hi guys,
    Would it be ok to do it like this (with a join):
    SELECT      
         c.country_code,
         c.date_last_visited AS DATE_LAST_VISITED_COUNTRY,
         c.population AS POPULATION_COUNTRY,
         s.state_county_code,
         s.date_last_visited AS DATE_LAST_VISITED_STATE_COUNTY,
         s.population AS POPULATION_COUNTY,
         t.town_code,
         t.date_last_visited AS DATE_LAST_VISITED_TOWN,
         t.population POPULATION_TOWN,
    FROM
         country c
         LEFT OUTER JOIN state_county s ON s.country_code = c.country_code
         LEFT OUTER JOIN town       t ON t.country_code = s.country_code
    AND                                       t.state_county_code = s.state_county_codeThe results required would be something like:
    Country_Code     DATE_LAST_VISITED_COUNTRY     POPULATION_COUNTRY     STATE_COUNTY_CODE         DATE_LAST_VISITED_STATE_COUNTY         POPULATION_COUNTY     TOWN_CODE     DATE_LAST_VISITED_TOWN     POPULATION_TOWN
    UK               14-JAN-09                     56,00000               London                    18-JUL-99                              23,0000               Ascot         30-JUN-89                  12,000
                                                                                                                                                                 Brixton       28-JAN-92                  4,684
                                                                          Birmingham                12-SEP-09                              55,678                Solihull      12-OCT-81                  6.768 Does this make sense?
    Thanks!
    Edited by: Sastry on Nov 2, 2009 2:04 AM

  • Oracle 9i Sum() Rounding Error?

    Has anyone encountered problems with the Sum() function rounding the results?
    Here is the situation and results that I'm observing:
    We are Priming a new accounting system in preparation for beta testing. This data priming involves importing a number of bank transactions into the database. To verify that the import was 100% successful, after each batch I query the table to see what the total amount and number of transactions that were imported.
    For one bank account, the total amount that should have been imported was: $65,954,194.99 spread over 2771 transactions. After running the following query, Oracle reported the total as being $65,954,195.00".
    SELECT BANK_ACCOUNT_ID, SUM(TOTAL_AMOUNT), COUNT(BANK_TRANS_ID)
    FROM BANK_TRANSACTIONS
    GROUP BY BANK_ACCOUNT_ID;
    The field TOTAL_AMOUNT is NUMBER(28,2).
    After importing all of the bank accounts, I ran another overall sum of the total_amount field for the entire table. The result of that sum were rounded off to the nearest whole dollar as well.
    I also went back and performed several small sum actions by filtering the result set to roughly groups of 500 transactions and then manually adding those results together and did come up with the correct total amount.
    Running the summing sql statement on smaller accounts with fewer transactions (less than 1000) returned accurate data. However all of the larger accounts had this rounding problem.
    Any help or suggestions on how to correct this?
    Thanks.

    Ignore this message. I feel like a total idiot now. :-(
    The problem wasn't with the sum() function, but instead with SQL*Plus.

  • Oracle 11g/R2 Query Result Cache - Incremental Update

    Hi,
    In Oracle 11g/R2, I created replica of HR.Employees table & executed the following statement (+Although using SUM() function is non-logical in this case, but just testifying the result+)
    STEP - 1
    SELECT      /+ RESULT_CACHE */ employee_id, first_name, last_name, SUM(salary)*
    FROM           HR.Employees_copy
    WHERE      department_id = 20
    GROUP BY      employee_id, first_name, last_name;
    EMPLOYEE_ID      FIRST_NAME LAST_NAME     SUM(SALARY)
    202           Pat           Fay          6000
    201           Michael           Hartstein     13000
    Elapsed: 00:00:00.01
    Execution Plan
    Plan hash value: 3837552314
    | Id | Operation           | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT      | | 2 | 130 | 4 (25)| 00:00:01 |
    | 1 | RESULT CACHE      | 3acbj133x8qkq8f8m7zm0br3mu | | | | |
    | 2 | HASH GROUP BY      | | 2 | 130 | 4 (25)| 00:00:01 |
    |* 3 | TABLE ACCESS FULL     | EMPLOYEES_COPY | 2 | 130 | 3 (0)| 00:00:01 |
    --------------------------------------------------------------------------------------------------     Statistics
    0 recursive calls
    0 db block gets
    0 consistent gets
    0 physical reads
    0 redo size
    *690* bytes sent via SQL*Net to client
    416 bytes received via SQL*Net from client
    2 SQL*Net roundtrips to/from client
    0 sorts (memory)
    0 sorts (disk)
    2 rows processed
    STEP - 2
    INSERT INTO HR.employees_copy
    VALUES(200, 'Dummy', 'User','[email protected]',NULL, sysdate, 'MANAGER',5000, NULL,NULL,20);
    STEP - 3
    SELECT      /*+ RESULT_CACHE */ employee_id, first_name, last_name, SUM(salary)
    FROM           HR.Employees_copy
    WHERE      department_id = 20
    GROUP BY      employee_id, first_name, last_name;
    EMPLOYEE_ID      FIRST_NAME LAST_NAME SUM(SALARY)
    202      Pat      Fay      6000
    201      Michael      Hartstein      13000
    200      Dummy User      5000
    Elapsed: 00:00:00.03
    Execution Plan
    Plan hash value: 3837552314
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT |          | 3 | 195 | 4 (25)| 00:00:01 |
    | 1 | RESULT CACHE | 3acbj133x8qkq8f8m7zm0br3mu | | | | |
    | 2 | HASH GROUP BY | | 3 | 195 | 4 (25)| 00:00:01 |
    |* 3 | TABLE ACCESS FULL| EMPLOYEES_COPY | 3 | 195 | 3 (0)| 00:00:01 |
         Statistics
    0 recursive calls
    0 db block gets
    4 consistent gets
    0 physical reads
    0 redo size
    *714* bytes sent via SQL*Net to client
    416 bytes received via SQL*Net from client
    2 SQL*Net roundtrips to/from client
    0 sorts (memory)
    0 sorts (disk)
    3 rows processed
    In the execution plan of STEP-3, against ID-1 the operation RESULT CACHE is shown which shows the result has been retrieved directly from Result cache. Does this mean that Oracle Server has Incrementally Retrieved the resultset?
    Because, before the execution of STEP-2, the cache contained only 2 records. Then 1 record was inserted but after STEP-3, a total of 3 records was returned from cache. Does this mean that newly inserted row is retrieved from database and merged to the cached result of STEP-1?
    If Oracle server has incrementally retrieved and merged newly inserted record, what mechanism is being used by the Oracle to do so?
    Regards,
    Wasif
    Edited by: 965300 on Oct 15, 2012 12:25 AM

    965300 wrote:
    Hi,
    In Oracle 11g/R2, I created replica of HR.Employees table & executed the following statement (+Although using SUM() function is non-logical in this case, but just testifying the result+)
    STEP - 1
    SELECT      /+ RESULT_CACHE */ employee_id, first_name, last_name, SUM(salary)*
    FROM           HR.Employees_copy
    WHERE      department_id = 20
    GROUP BY      employee_id, first_name, last_name;
    EMPLOYEE_ID      FIRST_NAME LAST_NAME     SUM(SALARY)
    202           Pat           Fay          6000
    201           Michael           Hartstein     13000
    Elapsed: 00:00:00.01
    Execution Plan
    Plan hash value: 3837552314
    | Id | Operation           | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT      | | 2 | 130 | 4 (25)| 00:00:01 |
    | 1 | RESULT CACHE      | 3acbj133x8qkq8f8m7zm0br3mu | | | | |
    | 2 | HASH GROUP BY      | | 2 | 130 | 4 (25)| 00:00:01 |
    |* 3 | TABLE ACCESS FULL     | EMPLOYEES_COPY | 2 | 130 | 3 (0)| 00:00:01 |
    --------------------------------------------------------------------------------------------------     Statistics
    0 recursive calls
    0 db block gets
    0 consistent gets
    0 physical reads
    0 redo size
    *690* bytes sent via SQL*Net to client
    416 bytes received via SQL*Net from client
    2 SQL*Net roundtrips to/from client
    0 sorts (memory)
    0 sorts (disk)
    2 rows processed
    STEP - 2
    INSERT INTO HR.employees_copy
    VALUES(200, 'Dummy', 'User','[email protected]',NULL, sysdate, 'MANAGER',5000, NULL,NULL,20);
    STEP - 3
    SELECT      /*+ RESULT_CACHE */ employee_id, first_name, last_name, SUM(salary)
    FROM           HR.Employees_copy
    WHERE      department_id = 20
    GROUP BY      employee_id, first_name, last_name;
    EMPLOYEE_ID      FIRST_NAME LAST_NAME SUM(SALARY)
    202      Pat      Fay      6000
    201      Michael      Hartstein      13000
    200      Dummy User      5000
    Elapsed: 00:00:00.03
    Execution Plan
    Plan hash value: 3837552314
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT |          | 3 | 195 | 4 (25)| 00:00:01 |
    | 1 | RESULT CACHE | 3acbj133x8qkq8f8m7zm0br3mu | | | | |
    | 2 | HASH GROUP BY | | 3 | 195 | 4 (25)| 00:00:01 |
    |* 3 | TABLE ACCESS FULL| EMPLOYEES_COPY | 3 | 195 | 3 (0)| 00:00:01 |
         Statistics
    0 recursive calls
    0 db block gets
    4 consistent gets
    0 physical reads
    0 redo size
    *714* bytes sent via SQL*Net to client
    416 bytes received via SQL*Net from client
    2 SQL*Net roundtrips to/from client
    0 sorts (memory)
    0 sorts (disk)
    3 rows processed
    In the execution plan of STEP-3, against ID-1 the operation RESULT CACHE is shown which shows the result has been retrieved directly from Result cache. Does this mean that Oracle Server has Incrementally Retrieved the resultset?
    Because, before the execution of STEP-2, the cache contained only 2 records. Then 1 record was inserted but after STEP-3, a total of 3 records was returned from cache. Does this mean that newly inserted row is retrieved from database and merged to the cached result of STEP-1?
    If Oracle server has incrementally retrieved and merged newly inserted record, what mechanism is being used by the Oracle to do so?
    Regards,
    Wasif
    Edited by: 965300 on Oct 15, 2012 12:25 AMNo, the RESULT CACHE operation doesn't necessarily mean that the results are retrieved from there. It could be being
    written to there.
    Look at the number of consistent gets: it's zero in the first step (I assume you had already run this query before) and I would
    conclude that the data is being read from the result cache.
    In the third step there are 4 consistent gets. I would conclude that the data is being written to the result cache, a fourth step repeating
    the SQL should show zero consistent gets and that would be the results being read.

Maybe you are looking for

  • How can I create a DVD image that PC users can retrieve and burn...

    I need to create a DVD disc image that PC users can retrieve from a private network share and burn to a blank DVD. Once burned, it needs to auto-start at the Menu. The master works fine. Images burned using the Mac Disk Utility work fine. But I have

  • Printing from iphone/ipad does not work after ios5 upgrade

    have a Brother HL-2140 that would print and show up as the "printer" when printing from an iPhone/iPad thru an Airport Extreme. Everything worked fine till upgrading to ios5 ... now the option for printing is replaced with an "no airprint printer fou

  • SUN AI24PO 24" LCD Monitor C-Viedo / S-Video Problem... No Image

    We have few SUN AI24PO 24" LCD Monitors that are hooked up to Blade2000 and Blade2500 systems. These monitors have 1-Digital/DVI, 1-Analog/VGA, 1-S-Video, 1-C-Video inputs. The Digital and Analog inputs work fine but I cannot display anything that I

  • Using Standard Text Variables for FYPERIOD in Report Title ?

    Hi, We have a requirement where the user input the variable 0fiscper to the query (001.2010). How to get the text value of that variable in the query description in the bex query ? For example user input, 008.2010. We need to get "Aug 2010 Sales valu

  • Swap space becomes critically low in the system

    Hi, We are facing a situation where the swap space space  is critically low in the system, there is just 10 % available swap space in the system And we can't see the swap space being released to the OS . This is one of the  Application servers we hav