Building xml in oracle without unnecessary tags using sql

I wanted to build XML in oracle using sql, I found a way to construction using sql functions after a little research, I am completely unaware of any XML. My query is


SELECT XMLELEMENT("orderwave",
  XMLAGG
(XMLELEMENT("order_header",
  
-- XMLATTRIBUTES(t2.l_name AS "order_number"),
  XMLFOREST
(
  nvl
(t2.l_name,' ') as "order_number",
  
(
  SELECT XMLAGG
(XMLELEMENT("order_line",
  XMLFOREST
( nvl(t1.l_name,' ') AS "label_type",
  nvl
(t1.l_num,0) AS "lpn",
  nvl
(t1.l_num,0) AS "sku"
  
)
  
)
  
) 
  FROM test_table t1
  WHERE UPPER
(t1.record_type)='D'  
  
) AS sap
  
)
  
)
  
)
  
) AS HEADER
  FROM test_table t2
  WHERE UPPER
(t2.record_type) ='H';


My problem is for using xmlforest, I had to use alias name 'sap' in my query to work and to get xml output. If i am using that, I am getting an unwanted tag 'SAP' around my data which I have to later cut it, which is unacceptable. Is there a way I can get rid of this extra 'SAP' tag without having to cut. The output data is


<orderwave>
  
<order_header>
  
<order_number>order1</order_number>
  
<SAP>
  
<order_line>
  
<label_type>test1</label_type>
  
<lpn>1</lpn>
  
<sku>1</sku>
  
</order_line>
  
<order_line>
  
<label_type>test2</label_type>
  
<lpn>2</lpn>
  
<sku>2</sku>
  
</order_line>
  
<order_line>
  
<label_type />
  
<lpn>0</lpn>
  
<sku>0</sku>
  
</order_line>
  
</SAP>
  
</order_header>
  
<order_header>
  
<order_number>order2</order_number>
  
<SAP>
  
<order_line>
  
<label_type>test1</label_type>
  
<lpn>1</lpn>
  
<sku>1</sku>
  
</order_line>
  
<order_line>
  
<label_type>test2</label_type>
  
<lpn>2</lpn>
  
<sku>2</sku>
  
</order_line>
  
<order_line>
  
<label_type />
  
<lpn>0</lpn>
  
<sku>0</sku>
  
</order_line>
  
</SAP>
  
</order_header>
</orderwave>


  Any help is really appreciated and thanks in advance.

-- sample data
with test_table
as
(
    select 'H' record_type, 'order1' l_name, 0 l_num from dual
    union all
    select 'H' record_type, 'order2' l_name, 0 l_num from dual
    union all
    select 'D' record_type, 'test1'  l_name, 1 l_num from dual
    union all
    select 'D' record_type, 'test2'  l_name, 2 l_num from dual
)
-- end of sample data
select xmlelement
       (
          "order_wave"
        , xmlagg
          (
            xmlelement
            (
                "order_header"
              , xmlelement("order_number", t1.l_name)
              , xmlagg
                (
                  xmlelement
                  (
                     "order_line"
                   , xmlelement("label_type", t2.l_name)
                   , xmlelement("lpn", t2.l_num)
                   , xmlelement("sku", t2.l_num)
                  )
                )
            )
          )
       ) xml_data
  from test_table t1
 cross
  join test_table t2
 where t1.record_type = 'H'
   and t2.record_type = 'D'
 group
    by t1.l_name;

-- output
/*

        
                order1
                
                        test1
                        1
                        1
                
                
                        test2
                        2
                        2
                
        
        
                order2
                
                        test1
                        1
                        1
                
                
                        test2
                        2
                        2
                
        

*/

Tags: Database

Similar Questions

  • Re-build the existing Oracle 6i chart reports using BI beans.

    Hi guys,.

    We have some reports of chart of 6i Oracle who are not against the 11g Server Application, so we plan to do it again and I don't understand where to start with, to get an estimate of the work to be done.

    First of all, can I use the data visualization components or ADF Oracle BI beans 10.1.2.x (ADF DVT - this seems to be available in JDeveloper 11 g) with Database 11g?

    Secondly, what part (such as applications) from the current reports 6i can I use in their development by using BI Bean, whereas the versions above of the BI beans.

    If someone has worked on the BI beans / ADF DVT before, please give me your suggestions.

    Thnx.

    Hello Sona,
    BI beans is built in in the report generator.

    1 - have a data model will the paper layout
    2 - See the graphic on the left icon
    3 - click on it and then draw a section in the page layout and the wizard appears
    4 - follow the steps in the wizard, and you will get a chart.

    Hope this helps, Roberto

  • Problem with migration SQL Server Oracle 11.2 2012 DB using SQL Developer Migration workbench

    Hello

    I have a problem when migrating SQL Server Oracle 11.2 2012 using SQL Developer Migration workbench, hope that someone had the same problem before and can give same advide...

    I use SQL Developer Version 4.0.1.14 and Oracle Database 11 g Enterprise Edition Release 11.2.0.1.0. and last jtds - 1.3.

    I created the schema migration_repo, privileges, connected to the third part of Db (SQL Server) and begin a trial with assistant. In the first step of the model to Capture, I get the message from the:

    "Company Capture Capture failed.  Refer to the table MIGRLOG in the repository for more details ".

    But MIGRLOG is empty.

    Here is my log:

    <? XML version = "1.0" encoding = "windows-1252" standalone = 'no '? >

    < Log >

    account <>

    < date > 2014-03-16T 20: 49:17 < / date >

    oracle.dbtools.migration.workbench.core.MigrationLogResourceBundle < recorder > < / recorder >

    < level > SEVERE < / level >

    oracle.dbtools.migration.workbench.core.logging.MigrationLogUtil < class > < / class >

    < message > Capture

    Capture Enterprise

    Capture failure.  Refer to the MIGRLOG table in the repository for more details < / message >

    oracle.dbtools.migration.workbench.core.ui.FullMigrateTask.doOnlineEnterpriseCapture(FullMigrateTask.java:758) < param > < / param >

    oracle.dbtools.migration.workbench.core.ui.FullMigrateTask.doCapture(FullMigrateTask.java:601) < param > < / param >

    oracle.dbtools.migration.workbench.core.ui.FullMigrateTask.doMaskBasedActions(FullMigrateTask.java:400) < param > < / param >

    oracle.dbtools.migration.workbench.core.ui.FullMigrateTask.doWork(FullMigrateTask.java:314) < param > < / param >

    oracle.dbtools.migration.workbench.core.ui.FullMigrateTask.doWork(FullMigrateTask.java:147) < param > < / param >

    oracle.dbtools.raptor.backgroundTask.RaptorTask.call(RaptorTask.java:193) < param > < / param >

    java.util.concurrent.FutureTask.run(FutureTask.java:262) < param > < / param >

    oracle.dbtools.raptor.backgroundTask.RaptorTaskManager$ (RaptorTaskManager.java:554) < param > RaptorFutureTask.run < / param >

    java.util.concurrent.Executors$ (Executors.java:471) < param > RunnableAdapter.call < / param >

    java.util.concurrent.FutureTask.run(FutureTask.java:262) < param > < / param >

    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) < param > < / param >

    java.util.concurrent.ThreadPoolExecutor$ Worker.run (ThreadPoolExecutor.java:615) < param > < / param >

    java.lang.Thread.run(Thread.java:744) < param > < / param >

    oracle.dbtools.migration.workbench.core.logging.LogInfo@68e69a < param > < / param >

    < exception >

    < message > oracle.dbtools.migration.workbench.core.ui.FullMigrateTask$ FullMigrateTaskException: Capture

    Capture Enterprise

    Capture failure.  Refer to the MIGRLOG table in the repository for more details < / message >

    < frame >

    oracle.dbtools.migration.workbench.core.ui.FullMigrateTask < class > < / class >

    < line > 758 < / line >

    < / framework >

    < frame >

    oracle.dbtools.migration.workbench.core.ui.FullMigrateTask < class > < / class >

    < line > 601 < / line >

    < / framework >

    < frame >

    oracle.dbtools.migration.workbench.core.ui.FullMigrateTask < class > < / class >

    line 400 > of < < / line >

    < / framework >

    < frame >

    oracle.dbtools.migration.workbench.core.ui.FullMigrateTask < class > < / class >

    < line > 314 < / line >

    < / framework >

    < frame >

    oracle.dbtools.migration.workbench.core.ui.FullMigrateTask < class > < / class >

    < line > 147 < / line >

    < / framework >

    < frame >

    oracle.dbtools.raptor.backgroundTask.RaptorTask < class > < / class >

    < line > 193 < / line >

    < / framework >

    < frame >

    java.util.concurrent.FutureTask < class > < / class >

    < line > 262 < / line >

    < / framework >

    < frame >

    oracle.dbtools.raptor.backgroundTask.RaptorTaskManager$ RaptorFutureTask < class > < / class >

    < line > 554 < / line >

    < / framework >

    < frame >

    java.util.concurrent.Executors$ RunnableAdapter < class > < / class >

    < line > 471 < / line >

    < / framework >

    < frame >

    java.util.concurrent.FutureTask < class > < / class >

    < line > 262 < / line >

    < / framework >

    < frame >

    java.util.concurrent.ThreadPoolExecutor < class > < / class >

    < line > 1145 < / line >

    < / framework >

    < frame >

    java.util.concurrent.ThreadPoolExecutor$ Worker < class > < / class >

    < line > 615 < / line >

    < / framework >

    < frame >

    java.lang.Thread < class > < / class >

    < line > 744 < / line >

    < / framework >

    < / exception >

    < / recording >

    account <>

    < date > 2014-03-16T 20: 49:17 < / date >

    oracle.dbtools.migration.workbench.core.MigrationLogResourceBundle < recorder > < / recorder >

    WARNING < level > < / level >

    oracle.dbtools.migration.workbench.core.ui.FullMigrateTask < class > < / class >

    <>error message: ORA-06550: line 1, column 14:

    PLS-00201: identifier ' SS2K5ALLPLATFORM. STAGECAPTURE' must be declared

    ORA-06550: line 1, column 7:

    PL/SQL: Statement ignored

    : FAILED: Database Migration: FAILURE < / message >

    oracle.dbtools.migration.workbench.core.logging.LogInfo@1e2c9b99 < param > < / param >

    < / recording >

    I try with model db (DB empty, just a single table), but the error is same. However, if I try to copy the acronym tabele from SQL Server to Oracle it works fine...

    I guess it's something with the configuration, but beacause I am new in Oracle still have no idea...

    Any help would be much appreciated

    I thank in advance

    Stefan

    Hello Stefan,

    did you create the repository Migration of your database to Oracle (Tools-> Migration-> repository management)?

    The SS2K5ALLPLATFORM package is usually created when you add the migration of the Oracle database repository and it contains the function StageCapture.

    So please make sure that you have created a repository of migration in an Oracle database and associate it with the first step of your migration.

    -Klaus

  • What is the use of SOA project build.xml

    Hi all

    I am new to this area of oracle SOA.
    could you please explain to me what is the purpose of build.xml and build.property in soa project files.

    Thanks in advance...

    Hi '.

    Helps these two files in the deployment of the project to the server, usually in the phase of development projects are deployed through JDeveloper.
    In Jdev we right-click and here also deploy these files are used to deploy the jar of project. These files do the same work as any other web project
    File Build.xml and property.xml.

    Yatan-

  • use of XML in Oracle

    Hi all

    I am new to programming with XML in Oracle.

    Please help me with this requirement.

    Please look at an example of data
    < BSGDocs > < Doc Id = Archive '562' = '1' > < / Doc > < Doc Id = Archive '563' = '0' > < / Doc > < / BSGDocs >
    from this clob data, I need to extract the annual values and archive and insert it into a new table

    Here, it should return

    Annual Archive
    - - - - - - - - - -
    1 562
    563 0

    Please let me know how I can achieve this.

    Thank you and best regards,
    Vikas

    Just add INSERT INTO your table:

    select  id,
            archive
      from  XMLTable(
                     '/BSGDocs/Doc'
                     passing XMLType(Q'[]')
                     columns
                       id varchar2(5) path '@Id',
                       archive varchar2(5) path '@Archive'
                    )
    /
    
    ID    ARCHIVE
    ----- -------
    562   1
    563   0
    
    SQL> 
    

    SY.

  • Eclipse Blackberry plug-in: "run as" problem with build.xml

    Hello

    I use windows 7 (32 bit), Eclipse 3.5 with the blackberry plugin.

    I created a very simple "helloworld" "TestBuild" blackberry project that uses build.xml to build. Here's buildRIM desciption I used in build.xml


      
    jdkhome = "C:\Program Files\Java\jdk1.6.0_20"
    DESTDIR = 'out '.
    output = "TestBuild.
    quiet = "false" >
       
       
    title = "TestBuild" vendor = 'abc '.
    version = "Version = 1.0" description = "My Test Build1"
    arguments = "" systemmodule = 'false' "
    runonstartup = "false" startuptier = "7".
    "RibbonPosition ="0"icon ="... /res/img/TestBuild.png ">
       
       
       
        
         
         
        

       

      
      
       
        
        
        
        
        
            
       

       
      
     

    By right click on build.xml, when I "Debug As"-> remote Java Application, everything works fine.

    However when I do "run as"--> Blackberry app man goes well and called the Simulator, but without the built application.

    In the end, I get this error:

    Packaging project TestBuild
    C:\eclipse\plugins\net.rim.ejde.componentpack5.0.0_5.0.0.25\components\bin\rapc.exe -quiet codename=deliverables\Standard\5.0.0\TestBuild deliverables\Standard\5.0.0\TestBuild.rapc -sourceroot=C:\Users\Shikha\workspace\TestBuild\src;C:\Users\Shikha\workspace\TestBuild\res -import=C:\eclipse\plugins\net.rim.ejde.componentpack5.0.0_5.0.0.25components\lib\net_rim_api.jar; C:\Users\Shikha\workspace\TestBuild\lib \bb-ant-tools.jar;C:\Users\Shikha\workspace\TestBuild\build.xml C:\Users\Shikha\workspace\TestBuild\bin
    
    I/O Error: error in opening zip file: C:\Users\Shikha\workspace\TestBuild\build.xml
    Packaging project TestBuild failed (took 1.327 seconds)
    

    Please help me!

    Hey thanks for your reply. Yes, indeed, I had added build.xml to build the access road. Thus, even when I have not used build.xml for building application, it still existed in the way of the construction and has caused the problem.

    works fine now.

    Thank you!

  • XML data in the table using sql/plsql

    Hi experts,

    Could you please help with the following requirement. I have the tags xml (.xml on a server file) below. I need to access this file and read the XML and insert into the db table using sql and plsql. Is it possible with the cdata below? And there is a nested this table.

    Could someone please guide me if you have a sample code file and xml.

    <? XML version = "1.0" encoding = "UTF-8"? >

    < generation_date > <! [CDATA [17/11/2015]] > < / generation_date >

    < generated_by > <! [CDATA [Admin Admin]] > < / generated_by >

    < year > <! [CDATA [2015]] > < / year >

    < month > <! [CDATA [01]] > < / month >

    < author >

    < author > <! [CDATA [user author]] > < / author > < author_initial > <! [CDATA [user]] > < / author_firstname > < author_country > <! [CDATA [author]] > < / author_lastname >

    < author_email > <! [CDATA [[email protected]]] > < / author_email >

    < author_data_01 > <! [CDATA []] > < / author_data_01 >

    < author_data_02 > <! [CDATA []] > < / author_data_02 >

    < items >

    < article_item >

    < article_id > <! [CDATA [123456]] > < / article_id >

    < publication > <! [CDATA [Al Bayan]] > < / publication >

    < section > <! [CDATA [Local]] > < / section >

    < issue_date > <! [CDATA [11/11/2015]] > < / issue_date >

    < page > <! [CDATA [2]] > < / print this page >

    < article_title > <! [CDATA [title.]] > < / article_title > < number_of_words > <! [CDATA [165]] > < / number_of_words >

    < original_price > <! [CDATA [200]] > < / original_price >

    < original_price_currency > <! [CDATA [DEA]] > < / original_price_currency >

    < price > <! [CDATA [250]] > < / price >

    < price_currency > <! [CDATA [DEA]] > < / price_currency >

    < / article_item >

    < / articles >

    < total_amount > <! [CDATA [250]] > < / total_amount >

    < total_amount_currency > <! [CDATA [DEA]] > < / total_amount_currency >

    < / author >

    < / xml >

    Thanks in advance,

    Suman

    XMLTABLE using...

    SQL > ed
    A written file afiedt.buf

    1 with t (xml) as (select xmltype ('))
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    [[12 [email protected]]] >
    13
    14
    15
    16
    17
    18
    19


    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33 ") of the double)"
    34-

    35 end of sample data
    36-
    37 - assumptions:
    (38 - a) XML may have several tags
    (39 - b) each may contain more
    40-
    41 select x.gen_by, x.gen_date, x.mn, x.yr
    42, y.author, y.auth_fn, y.auth_ln, y.auth_cnt, y.auth_em, y.auth_d1, y.auth_d2

    43, z.id, z.pub, z.sec, z.iss_dt, z.pg, z.art_ttl, z.num_wrds, z.oprice, z.ocurr, z.price, z.curr
    44 t
    45, xmltable ('/ authxml')
    from $ 46 t.xml
    path of 47 columns gen_date varchar2 (10) '. / generation_date'
    48, path of varchar2 (15) of gen_by '. / generated_by'
    49, path of varchar2 (4) year '. "/ year"
    50 varchar2 (2) mn road '. "/ month"
    51, path of xmltype authors '.'
    52                 ) x
    53, xmltable ('/ authxml/authors ')
    from $ 54 x.authors
    author of 55 path of varchar2 columns (15) '. / author'
    56, path of varchar2 (10) of auth_fn '. / author_firstname'
    57, path of varchar2 (10) of auth_ln '. / author_lastname'
    58 road of VARCHAR2 (3) auth_cnt '. / author_country'
    59 road of varchar2 (20) of auth_em '. / author_email'
    60 road of varchar2 (5) of auth_d1 '. / author_data_01'
    61, path of varchar2 (5) of auth_d2 '. / author_data_02'
    62, path of xmltype articles '. / Articles'
    63                 ) y
    64, xmltable ('/ Articles/article_item ')
    from $ 65 y.articles
    path id 66 number columns '. / article_id'
    67, path of varchar2 (10) pub '. ' / publication.
    68 road of varchar2 (10) dry '. / section'
    69, path of varchar2 (10) of iss_dt '. / issue_date'
    70 road of VARCHAR2 (3) pg '. "/ print this page"
    71, path of varchar2 (20) of art_ttl '. / article_title'
    72, path of varchar2 (5) of num_wrds '. / number_of_words'
    73, path of varchar2 (5) of oprice '. / original_price'
    74 road to VARCHAR2 (3) ocurr '. / original_price_currency'
    75, path of varchar2 (5) price '. "/ price"
    76, path of VARCHAR2 (3) curr '. / price_currency'
    77*                ) z
    SQL > /.

    GEN_DATE GEN_BY YEAR MN AUTHOR AUTH_FN AUTH_LN AUT AUTH_EM AUTH_ AUTH_ ID PUB DRY ISS_DT PG ART_TTL NUM_W OPRIC HEARTS PRICE OCU
    ---------- --------------- ---- -- --------------- ---------- ---------- --- -------------------- ----- ----- ---------- ---------- ---------- ---------- --- -------------------- ----- ----- --- ----- ---
    17/11/2015 Admin Admin 2015 01 user author user author [email protected] 123456 UAE Al Bayan Local 11/11/2015 2 is the title.   165 200 AED AED 250

    Of course, you'll want to change the types of data, etc. as needed.

    I assumed that the XML can contain several "" sections and that each section can contain several entries.

    Thus the XMLTABLE aliasing as 'x' gives information of XML, and supplies the data associated with the XMLTABLE with alias 'y' which gets the multiple authors, which itself section of the XMLTABLE with alias 'z' for each of the article_item.

    CDATA stuff are handled automatically by SQLX (XML functionality integrated into Oracle's SQL)

  • Reconstruction of .xml - do not keep my tags

    I love to sort the albums in my library by artist, and then the date, and to display this way on my iPod.  To do this, I wrote a Python script that is supposed to add tags "make Album" in the file of exported xml iTunes Library, with the format "artist-Album of the YEAR.

    It's a primitive script, but I can tell this should work at least.  But when I rebuild my iTunes library since the updated xml file, it rebuilt just as it was before, without my Album out new tags.

    Here is an example of the updated xml file the:

    < key > 1645 < / key >
    < dict >
    Track ID < key > < / key > < integer > 1645 < / integer >
    < key > name < / key > < String > Tombstone Shadow < / string >
    < key > artist < / key > < String > Creedence Clearwater Revival < / string >
    < key > Album artist < / key > < String > Creedence Clearwater Revival < / string >
    < key > composer < / key > < String > John Fogerty < / string >
    < key > Album < / key > < String > Green River < / string >
    < key > type < / key > < String > Rock < / string >
    < key > type < / key > < channel audio file > MPEG < / string >
    < key > size < / key > < integer > 7129216 < / integer >
    < key > total duration < / key > < integer > 218644 < / integer >
    < key > disc number < / key > < integer > 1 < / integer >
    < key > disk count < / key > < integer > 1 < / integer >
    < key > track number < / key > < integer > 3 < / integer >
    < key > track count < / key > < integer > 14 < / integer >
    < key > year < / key > < integer > 1969 < / integer >
    < key > update < / key > < date > 2014-03-05T 02: 43:58Z < / date >
    < key > Date added < / key > < date > 2016-06-11T 15: 35:16Z < / date >
    < key > bitrate < / key > < integer > 256 < / integer >
    < key > sampling rate < / key > < integer > 44100 < / integer >
    < key > standards < / key > < integer > 5690 < / integer >
    < key > County work < / key > < integer > 1 < / integer >
    < key > Album sort < / key > < String > Green River Creedence Clearwater Revival 1969 < / string > < key > Persistent ID < / key > < String > 3962D1A1CF08D178 < / string >
    < key > track Type < / key > < String > file < / string >
    < key > location < / key > < channel er%20Revival/Green%20River/03%20Tombstone%20Shadow.mp3 > file://localhost/E:/Music/iTunes/Creedence%20Clearwat < / string >
    < key > statement of case file < / key > < integer > 4 < / integer >
    < key > folder County Library < / key > < integer > 1 < / integer >
    < / dict >

    As you can see, the Album and Persistent ID sort keys share a line.  I don't know if this is important; I think I could solve this problem if that's the problem.  However, I tried manually add a line break after the tag Album fate and then rebuild the library again, and he didn't keep the custom tags.  Indeed, when I check "XML part" in preferences, it exports the xml without any of the tags New Album out (which makes sense, since they do not appear on the securities themselves).

    Can someone tell me what I am doing wrong?  I have found surprisingly little documentation in-depth on exactly how the iTunes library xml is parsed, so I really don't know how picky, it's command, line breaks, etc.

    Reconstruction from the XML does not update the tags in the songs. As soon as iTunes reads the tag of the file in question any external change you make is rejected. A better approach would be a modified version of my script KeywordsToAlbum wrote in SortAlbum instead, which interprets < SortAlbum > to mean the current value of the Album of the sort. The following input string would be set the values you want:

    -< SortAlbum > < artist > < year > < Album >

    You can fix it yourself if you want. I'm just on my way, but I'll post a new script later in the day.

    TT2

  • How oracle decide whetehr to use the index or full analysis (statistics)

    Hi guys,.

    Let's say I have an index on a column.
    Tables and index statistics were collected. (without the histograms).

    Let's say I have run a select * from table where a = 5;
    Oracle will perform a complete analysis.
    But what statistics, it will be able to know indeed the greater part of the column = 5? (histograms do not used)

    After analysis, we get the following:
    Statistical table:
    (NUM_ROWS)
    (BLOCKS)
    (EMPTY_BLOCKS)
    (AVG_SPACE)
    (CHAIN_COUNT)
    (AVG_ROW_LEN)

    Index statistics:
    (BLEVEL)
    (LEAF_BLOCKS)
    (DISTINCT_KEYS)
    (AVG_LEAF_BLOCKS_PER_KEY)
    (AVG_DATA_BLOCKS_PER_KEY)
    (CLUSTERING_FACTOR)

    Thank you





    Index of column (A)
    ======
    1
    1
    2
    2
    5
    5
    5
    5
    5
    5

    I have prepared a few explanations and did not notice that the topic has been marked as answer.

    My sentence is not quite true.

    A column "without histograms' means that the column has only a bucket.

    More correct: even without the histogram there are data in dba_tab_histograms which can be considered a bucket for the whole column. In fact, these data are extracted from hist_head$, not from $ histgrm as usual buckets.
    Technically there are no buckets without combined histograms.

    Let's create a table with the asymmetric data distribution.

    SQL> create table t as
      2  select least(rownum,3) as val, '*' as pad
      3    from dual
      4  connect by level <= 1000000;
    
    Table created
    
    SQL> create index idx on t(val);
    
    Index created
    
    SQL> select val, count(*)
      2    from t
      3   group by val;
    
           VAL   COUNT(*)
    ---------- ----------
             1          1
             2          1
             3     999998
    

    So, we have table with the very uneven distribution of the data.
    We collect statistics without histograms.

    SQL> exec dbms_stats.gather_table_stats( user, 'T', estimate_percent => 100, method_opt => 'for all columns size 1', cascade => true);
    
    PL/SQL procedure successfully completed
    
    SQL> select blocks, num_rows  from dba_tab_statistics
      2   where table_name = 'T';
    
        BLOCKS   NUM_ROWS
    ---------- ----------
          3106    1000000
    
    SQL> select blevel, leaf_blocks, clustering_factor
      2    from dba_ind_statistics t
      3   where table_name = 'T'
      4     and index_name = 'IDX';
    
        BLEVEL LEAF_BLOCKS CLUSTERING_FACTOR
    ---------- ----------- -----------------
             2        4017              3107
    
    SQL> select column_name,
      2         num_distinct,
      3         density,
      4         num_nulls,
      5         low_value,
      6         high_value
      7    from dba_tab_col_statistics
      8   where table_name = 'T'
      9     and column_name = 'VAL';
    
    COLUMN_NAME  NUM_DISTINCT    DENSITY  NUM_NULLS      LOW_VALUE      HIGH_VALUE
    ------------ ------------ ---------- ---------- -------------- ---------------
    VAL                     3 0,33333333          0           C102            C104
    

    Therefore, Oracle suggests that the values between 1 and 3 (raw C102 C104) are distributed uniform and the density of the distribution is 0.33.
    We will try to explain the plan

    SQL> explain plan for
      2  select --+ no_cpu_costing
      3         *
      4    from t
      5   where val = 1
      6  ;
    
    Explained
    
    SQL> @plan
    
    --------------------------------------------------
    | Id  | Operation         | Name | Rows  | Cost  |
    --------------------------------------------------
    |   0 | SELECT STATEMENT  |      |   333K|   300 |
    |*  1 |  TABLE ACCESS FULL| T    |   333K|   300 |
    --------------------------------------------------
    Predicate Information (identified by operation id):
    ---------------------------------------------------
       1 - filter("VAL"=1)
    Note
    -----
       - cpu costing is off (consider enabling it)
    

    An excerpt from trace 10053

    BASE STATISTICAL INFORMATION
    ***********************
    Table Stats::
      Table:  T  Alias:  T
        #Rows: 1000000  #Blks:  3106  AvgRowLen:  5.00
    Index Stats::
      Index: IDX  Col#: 1
        LVLS: 2  #LB: 4017  #DK: 3  LB/K: 1339.00  DB/K: 1035.00  CLUF: 3107.00
    ***************************************
    SINGLE TABLE ACCESS PATH
      -----------------------------------------
      BEGIN Single Table Cardinality Estimation
      -----------------------------------------
      Column (#1): VAL(NUMBER)
        AvgLen: 3.00 NDV: 3 Nulls: 0 Density: 0.33333 Min: 1 Max: 3
      Table:  T  Alias: T
        Card: Original: 1000000  Rounded: 333333  Computed: 333333.33  Non Adjusted: 333333.33
      -----------------------------------------
      END   Single Table Cardinality Estimation
      -----------------------------------------
      Access Path: TableScan
        Cost:  300.00  Resp: 300.00  Degree: 0
          Cost_io: 300.00  Cost_cpu: 0
          Resp_io: 300.00  Resp_cpu: 0
      Access Path: index (AllEqRange)
        Index: IDX
        resc_io: 2377.00  resc_cpu: 0
        ix_sel: 0.33333  ix_sel_with_filters: 0.33333
        Cost: 2377.00  Resp: 2377.00  Degree: 1
      Best:: AccessPath: TableScan
             Cost: 300.00  Degree: 1  Resp: 300.00  Card: 333333.33  Bytes: 0
    

    FTS here costs 300 and Index Range Scan here costs 2377.
    I disabled cpu cost, so the selectivity does not affect the cost of FTS.
    cost of the Index Range Scan is calculated as
    blevel + (leaf_blocks * selectivity + clustering_factor * selecivity) = 2 + (4017 * 0.33333 + 3107 * 0.33333) = 2377.
    Oracle believes that he must read 2 blocks root/branch index, 1339 the index leaf blocks and 1036 blocks in the table.
    Pay attention that the selectivity is the main component of the cost of the Index Range Scan.

    We will try to collect histograms:

    SQL> exec dbms_stats.gather_table_stats( user, 'T', estimate_percent => 100, method_opt => 'for columns val size 3', cascade => true);
    
    PL/SQL procedure successfully completed
    

    If you look at dba_tab_histograms you can see more

    SQL> select endpoint_value,
      2         endpoint_number
      3    from dba_tab_histograms
      4   where table_name = 'T'
      5     and column_name = 'VAL'
      6  ;
    
    ENDPOINT_VALUE ENDPOINT_NUMBER
    -------------- ---------------
                 1               1
                 2               2
                 3         1000000
    

    ENDPOINT_VALUE is the value of the column (in number for any type of data) and ENDPOINT_NUMBER is the cumulative number of lines.
    Number of lines for any ENDPOINT_VALUE = ENDPOINT_NUMBER for this ENDPOINT_VALUE - ENDPOINT_NUMBER to the previous ENDPOINT_VALUE.

    explain the plan and track 10053 the same query:

    ------------------------------------------------------------
    | Id  | Operation                   | Name | Rows  | Cost  |
    ------------------------------------------------------------
    |   0 | SELECT STATEMENT            |      |     1 |     4 |
    |   1 |  TABLE ACCESS BY INDEX ROWID| T    |     1 |     4 |
    |*  2 |   INDEX RANGE SCAN          | IDX  |     1 |     3 |
    ------------------------------------------------------------
    Predicate Information (identified by operation id):
    ---------------------------------------------------
       2 - access("VAL"=1)
    Note
    -----
       - cpu costing is off (consider enabling it)
    
    ***************************************
    BASE STATISTICAL INFORMATION
    ***********************
    Table Stats::
      Table:  T  Alias:  T
        #Rows: 1000000  #Blks:  3106  AvgRowLen:  5.00
    Index Stats::
      Index: IDX  Col#: 1
        LVLS: 2  #LB: 4017  #DK: 3  LB/K: 1339.00  DB/K: 1035.00  CLUF: 3107.00
    ***************************************
    SINGLE TABLE ACCESS PATH
      -----------------------------------------
      BEGIN Single Table Cardinality Estimation
      -----------------------------------------
      Column (#1): VAL(NUMBER)
        AvgLen: 3.00 NDV: 3 Nulls: 0 Density: 5.0000e-07 Min: 1 Max: 3
        Histogram: Freq  #Bkts: 3  UncompBkts: 1000000  EndPtVals: 3
      Table:  T  Alias: T
        Card: Original: 1000000  Rounded: 1  Computed: 1.00  Non Adjusted: 1.00
      -----------------------------------------
      END   Single Table Cardinality Estimation
      -----------------------------------------
      Access Path: TableScan
        Cost:  300.00  Resp: 300.00  Degree: 0
          Cost_io: 300.00  Cost_cpu: 0
          Resp_io: 300.00  Resp_cpu: 0
      Access Path: index (AllEqRange)
        Index: IDX
        resc_io: 4.00  resc_cpu: 0
        ix_sel: 1.0000e-06  ix_sel_with_filters: 1.0000e-06
        Cost: 4.00  Resp: 4.00  Degree: 1
      Best:: AccessPath: IndexRange  Index: IDX
             Cost: 4.00  Degree: 1  Resp: 4.00  Card: 1.00  Bytes: 0
    

    Be careful on selectivity, ix_sel: 1.0000e - 06
    Cost of the FTS is always the same = 300,
    but the cost of the Index Range Scan is now 4: 2 blocks from root/branch + block 1 sheet + 1 table blocks.

    So, conclusion: histograms to calculate more accurate selectivity. The goal is to have more efficient execution plans.

    Alexander Anokhin
    http://alexanderanokhin.WordPress.com/

  • problem to run build.xml

    I downloaded the Demo Application Fusion Store Front "FusionOrderDemo_R2.zip" of

    I am facing following problem.



    BUILD FAILED
    C:\JDeveloper\mywork\Sherman_FOD\Infrastructure\Ant\build.XML:51: The following error occurred during the execution of this line:
    C:\JDeveloper\mywork\Sherman_FOD\Infrastructure\DBSchema\build.XML:91: The following error occurred during the execution of this line:
    C:\JDeveloper\mywork\Sherman_FOD\Infrastructure\DBSchema\build.XML:56: The following error occurred during the execution of this line:
    C:\JDeveloper\mywork\Sherman_FOD\Infrastructure\DBSchema\build.XML:28: Class not found: oracle.jdbc.OracleDriver JDBC driver could not be loaded


    Thank you
    Prateek

    When you went to the page where you downloaded FOD, namely http://www.oracle.com/technetwork/developer-tools/jdev/index-095536.html

    Did you read at the top where it says «this will not work in earlier versions...» See the bottom of this page for older versions? »

    And when you went to the bottom of the page, you have found a link.

    And when you follow this link, you have found a page for the 11.1.1.5 version of the demo.

    And at the bottom of this page you find links to previous versions, so

    A Little reading goes a long way {noformat} :) {noformat}

    John

  • get utc time in oracle without restarting the session

    Hello world

    I need to get utc time in oracle without restarting the session. Now I get what type:

    Select double sessiontimezone;

    In the new session, I'm sessiontimezone exact value, for example, I live in Istanbul, Turkey and there + 02:00. But last Saturday, this value is passed to 03:00. If a session that was created only, when I call sessiontimezone, back + 03:00, this is true.

    But, if I call sessiontimezone, I see + 02:00 in a session that created it before last Saturday night.

    What should I do to get the value real sessiontimezone without restarting the session?

    do you want to time UTC, you can use...

    select systimestamp at time zone 'UTC' from dual
    

    This will give always the hour UTC

    Ravi Kumar

  • XML in Oracle registration issue

    Hi friends,

    First of all thank you in advance for reading my post. In addition, congratulate you to this forum updated the.

    My main goal to publish XML by oracle using an external dtd. I am new to this - this isn't a clear idea in this regard. I've prepared an xml file using a dtd. Here are the details-
    OE>>
    OE>>select * from v$version;
    
    BANNER
    ----------------------------------------------------------------
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
    PL/SQL Release 10.2.0.3.0 - Production
    CORE    10.2.0.3.0      Production
    TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
    NLSRTL Version 10.2.0.3.0 - Production
    
    Elapsed: 00:00:03.41
    OE>>
    And the script of the dtd is as follows:-

    Name of the dtd is StandardInterfaces.xsd
    <!DOCTYPE EmpSchedule_V2 [
    <!ELEMENT EmpSchedule_V2 (period+, EmployeeList+) >
    <!ELEMENT period (start,end) >
    <!ELEMENT start (#PCDATA) >
    <!ELEMENT end   (#PCDATA) >
    <!ELEMENT EmployeeList (emp)+ >
    <!ELEMENT emp (Employee_ID,First,Sal,HireDate) >
    <!ELEMENT Employee_ID (#PCDATA) >
    <!ELEMENT First (#PCDATA) >
    <!ELEMENT Sal (#PCDATA) >
    <!ELEMENT HireDate (#PCDATA) >
    ]>
    And XML is as follows:-

    Name of the xml file is - emp.xml
    <?xml version="1.0" encoding= "UTF-8" ?>
    <EmpSchedule_V2 xmlns= "http://localhost/satid/StandardInterfaces.xsd" >
    <period>
    <start>2006-03-12Z</start>
    <end>2006-03-15Z</end>
    </period>
    <EmployeeList>
    <emp>
    <Employee_ID>7369</Employee_ID>
    <First>Raja</First>
    <Sal>28000</Sal>
    <HireDate>2006-03-12Z</HireDate>
    </emp>
    </EmployeeList>
    </EmpSchedule_V2>
    I configured my IIS 7.0 server in my pc.

    And, when I execute as -
    http://localhost/satid/emp.xml
    Where satid is the virtual directory on the IIS server - it shows the xml code. The actual path is - E:\public\schemas.

    Now, if I want to register it from an oracle schema which has all necessary privs - is to launch an error message.
    GRANT dba, xdbadmin TO OE;
    And now, I tried almost all of the given technique, but unable to go any further.
    BEGIN
      DBMS_XMLSCHEMA.registerURI(
                                   'http://localhost/satid/StandardInterfaces.xsd',
                                   '/satid/StandardInterfaces.xsd',
                                   LOCAL=>TRUE, 
                                   GENTYPES=>TRUE, 
                                   GENBEAN=>FALSE, 
                                   GENTABLES=>TRUE
                                );
    END;
    or,
    DECLARE 
      v_return  BOOLEAN; 
    BEGIN 
      v_return := dbms_xdb.createFolder('/satid/');
      COMMIT;
    END;
    And,
    BEGIN 
      DBMS_XMLSchema.registerSchema(
                                     schemaurl=>'http://localhost/satid/StandardInterfaces.xsd', 
                                     schemadoc=>sys.UriFactory.getUri('/satid/StandardInterfaces.xsd')
                                   ); 
    END; 
    In both cases given, the server (IIS Server and OC4J) is running. I checked it with the following command-
    http://Sat-PC:5560/
    http://localhost/satid/
    And the error is.
    OE>BEGIN 
      2    DBMS_XMLSchema.registerSchema(
      3      schemaurl=>'http://localhost/satid/StandardInterfaces.xsd', 
      4      schemadoc=>sys.UriFactory.getUri('/satid/StandardInterfaces.xsd')); 
      5  END; 
      6  /
    BEGIN
    *
    ERROR at line 1:
    ORA-31001: Invalid resource handle or path name "/satid/StandardInterfaces.xsd"
    ORA-06512: at "SYS.XDBURITYPE", line 4
    ORA-06512: at "XDB.DBMS_XMLSCHEMA", line 167
    ORA-06512: at line 2
    
    
    Elapsed: 00:00:01.03
    OE>
    OE>
    OE>DECLARE 
      2    v_return  BOOLEAN; 
      3  BEGIN 
      4    v_return := dbms_xdb.createFolder('/satid/');
      5    COMMIT;
      6  END; 
      7  /
    
    PL/SQL procedure successfully completed.
    
    Elapsed: 00:00:08.42
    OE>
    OE>
    OE>BEGIN 
      2    DBMS_XMLSchema.registerSchema(
      3      schemaurl=>'http://localhost/satid/StandardInterfaces.xsd', 
      4      schemadoc=>sys.UriFactory.getUri('/satid/StandardInterfaces.xsd')); 
      5  END; 
      6  /
    BEGIN
    *
    ERROR at line 1:
    ORA-31001: Invalid resource handle or path name "/satid/StandardInterfaces.xsd"
    ORA-06512: at "SYS.XDBURITYPE", line 4
    ORA-06512: at "XDB.DBMS_XMLSCHEMA", line 167
    ORA-06512: at line 2
    
    
    Elapsed: 00:00:00.00
    OE>
    OE>
    Now, my question is - I have to configure OC4J? If so, can someone tell me the exact document. I tried to find on the internet. But so happy come with this topic - that makes me more confused.

    In other cases, can someone tell me how to use IIS Server 7.0 in this regard?

    Or, if you have any other good suggestions to want to share it with me.

    Thanks for being so patience to read my post. I'll be waiting for your response.

    Kind regards.

    OraNew2 wrote:
    Salvation be,.

    I tried this way to save a custom XML schema. But, unable to register.

    ... Name of the dtd is StandardInterfaces.xsd...

    You should be aware that there are two ways to describe an XML.
    The 'old' is a DTD (Data Type definition). A more modern way is a definition of XML (XSD) schema.
    DTD and XSD is completely different concepts. You can't take a dtd and say what an XSD.

    See also: http://en.wikipedia.org/wiki/XSD

  • can quicken 2007 run on El Capitan (i.e., os 10.11)? I have one currently using Yosemite and you want to update without losing the use of Quicken 2007. I don't like the new version of Quicken.

    Can quicken 2007 run on El Capitan (i.e., os 10.11)? I have one currently using Yosemite and you want to update without losing the use of Quicken 2007. I don't like the new version of Quicken.

    Join the club of those of us who don't like Quicken 2015 or 2016 Quicken; even if I bought it for a 40% discount offered by Intuit!  I was just disappointed by Q2016 compared to Quicken 2007!

    If you have upgraded to the 16.2.3, version it will work well in El Capitan!

  • Photo Gallery-tags used for photos of the Windows remain even if the photos have been removed

    Picture of Windows Gallery__

    Tags used for photos stay in the computer even if the photos have been removed.  The remaining tags in UNROLLING in the space where you can enter a tag are no longer relevant and are just a nuisance.

    Tags used for photos stay in the computer even if the photos have been removed.  The remaining tags in UNROLLING in the space where you can enter a tag are no longer relevant and are just a nuisance.

    =================================
    Rename the database library file will force
    Photo Gallery to create a new file the next time, he is
    launched.

    Anyway... the following article explains how to find
    Pictures.PD4:

    Stops Windows Live Photo Gallery (944221)
    answer or does not start
    http://support.Microsoft.com/kb/944221/en-us

    After Renaming Pictures.pd4 you will need to re-catalogue
    your photos and some tags may be lost. If the name change
    Pictures.PD4 does not solve the problem... you can delete
    the new Pictures.pd4 file and change the name of the
    origin to Pictures.pd4 and the catalog file should
    be restored.

    In later versions of Windows Live Photo Gallery...
    the name of the file is Pictures.pd5.

    Volunteer - MS - MVP - Digital Media Experience J - Notice_This is not tech support_I'm volunteer - Solutions that work for me may not work for you - * proceed at your own risk *.

  • By the way the Pls/Sql variable to build xml via XQuery code

    v_ID number (3): = 5;

    v_UserID nvarchar2 (5): = 'abc ';

    v_Password nvarchar2 (8): = "passw0rd"

    v_Panel nvarchar2 (20): = "AppPnl";

    v_loginFailReason nvarchar2 (200): = 'IUIP | Invalid user or password ID ';

    v_SpParam xmltype: = XMLTYPE ("< QueryParam / > '");

    SELECT Xmlquery (' for $el in /QueryParam)

    return < QueryParam > {Rec <>

    < EmpID > {$ID} < / EmpID >

    < user name > {$UserID} < / UserID >

    < password > {$Password} < / password >

    < sign > {$Panel} < / sign >

    < reason > {$loginFailReason} < / reason >

    AppLogin < callde > < / callde >

    {< / rec >}

    < / QueryParam > '

    Passage v_SpParam

    , v_ID AS "ID".

    , v_UserID AS "UserID".

    v_Password AS 'Password'

    , v_Panel AS 'Panel '.

    , v_loginFailReason AS 'loginFailReason '.

    RETURN CONTENT)

    in the double v_SpParam;

    OPEN rc to SELECT v_SpParam FROM dual;

    DBMS_SQL.return_result (RC);

    the result is:

    < QueryParam >

    < rec >

    < EmpID > 5 < / EmpID >

    < user name > < / UserID >

    <>password < / password >

    < sign > < / sign >

    < reason > < / reason >

    AppLogin < callde > < / callde >

    < / rec >

    < / QueryParam >

    Pls. Let me know how I move correctly variable to build xml code, I don't get values in the xml result.

    Should you variables defined as nvarchar2, for a particular reason?  Switching to simply varchar2 allows to operate as you (in 11.2.0.4).  Right now, I'm not sure of the solution correct nvarchar2.

Maybe you are looking for