Order items TABLE (XMLSEQUENCE (Extract (...)))

Hello

I inherited a piece of SQL, extract information from an XMLTYPE column and I have a problem with the order of the returned items.

My XML looks like this:

< recommendation > < row >... < / line > < row >... < / Line > etc. < / recommendation >

This is a comment and is divided into several lines (a limitation of the source system).

I want to read the contents of each line and save it in a VARCHAR2 field but I want to keep the original order of the < row > elements to have a message with a sense in the end, beside the text I want to store a "Line number" column

To make this work, I got something like this:

SELECT

a.ID,

Extract (value (Rec), 'Line') online.

ROW_NUMBER() over (PARTITION BY a.id ORDER BY null) as line_number

Loads of table_with_the_id_to_process,

table_with_my_XML has,

REC TABLE (XMLSEQUENCE (EXTRACT (a.xmltext, ' / / recommendation/Line ')))

WHERE a.id = loads.id

It worked fine with 2-3 rows during the tests, but when running on real data (250-300 lines with XML fields) "line_number" become a bit at random: always start at 1 and go up until the number of element < row >, the order is as randomly, so my comments doesn't have a logical sense if I retrieve ordered them to "line_number.

Any idea on how to get the <>the position of number or something else to calculate my column "line_number?

Maybe I missed in the doc and Google simply because using bad language of research, so I'm open to any suggestion or idea.

Thank you

Gianni,

What is your version of the database?

The construction of the TABLE/XMLSequence has been deprecated in 11.2 for the function XMLTABLE.

XMLTABLE is available from version 10.2 and has a clause for ORDINALITE to generate the sequence of required integer.

You can also rebuild the entire message in a single VARCHAR2 or CLOB (depending on the size) and get rid of these line numbers.

Tags: Database

Similar Questions

  • XDB. XMLIndex problem and table (XMLSEQUENCE (EXTRACT (xmltype, path))

    Hello
    I have a database of Oracle 11 g Release 11.1.0.6.0 - 64 bit Production With the Real Application Clusters option.

    I feel something strange with an XMLType column.
    I have a table configurator.t_vehicle_configuration (id_vehicle x_configuration NUMBER, XMLType).
    x_configuration is unstructured.

    I created an index on the field of xml in this way:

    CREATE INDEX idx_vehicle_configuration ON configurator.t_vehicle_configuration (x_configuration) INDEXTYPE IS XDB. XMLIndex;

    Then I have a package implementing a function that count nodes in the xml field and its return values

    This does not (return 0 instead of 1):
        SELECT count(*)
          INTO count_
          FROM configurator.v_vehicle_configuration vc,
               table(XMLSEQUENCE(EXTRACT(vc.x_configuration, '/vehicleconf/GeoFence/spaceTarget[@id="'||in_id_space_target||'"]/user[@id="'||in_id_user||'"]/alarmwhen'))) p
         WHERE vc.id_vehicle = in_id_vehicle;
        
        RETURN count_;
    This mode of operation (return 1):
        str_ := '/vehicleconf/GeoFence/spaceTarget[@id="'||in_id_space_target||'"]/user[@id="'||in_id_user||'"]/alarmwhen';
    
        SELECT count(*)
          INTO count_
          FROM configurator.v_vehicle_configuration vc,
               table(XMLSEQUENCE(EXTRACT(vc.x_configuration,str_))) p
         WHERE vc.id_vehicle = in_id_vehicle;
        
        RETURN count_;
    As this mode of operation:
        SELECT /*+ NO_XMLINDEX_REWRITE */ count(*)
          INTO count_
          FROM configurator.v_vehicle_configuration vc,
               table(XMLSEQUENCE(EXTRACT(vc.x_configuration, '/vehicleconf/GeoFence/spaceTarget[@id="'||in_id_space_target||'"]/user[@id="'||in_id_user||'"]/alarmwhen'))) p
         WHERE vc.id_vehicle = in_id_vehicle;
        
        RETURN count_;
    And also this way it works:
        SELECT count(*)
          INTO count_
          FROM configurator.v_vehicle_configuration vc,
               table(XMLSEQUENCE(EXTRACT(vc.x_configuration, '/vehicleconf/GeoFence/spaceTarget[@id="228"]/user[@id="49"]/alarmwhen'))) p
         WHERE vc.id_vehicle = in_id_vehicle;
        
        RETURN count_;
    I sailed a bit on the internet but I have found no help for my problem...
    I guess that's something concerning the substitution on the fly of the variables, which does not work with an index.
    Do you have any suggestions?
    Is there a way that will prevent the rewriting of all the functions?

    Thanks in advance

    First

    On 11.1.0.6.0 Please do not use table (xmlsequence (extract ())) Please use the SQL/XML standard XMLTAble operator...

    SELECT COUNT(*)
       INTO count_
      FROM configurator.v_vehicle_configuration vc,
               XMLTABLE
              (
                  '$XML/vehicleconf/GeoFence/spaceTarget[@id=$ID_SPACE_TARGET]/user[@id=$ID_USER]/alarmwhen'
                  passing vc.x_configuration as "XML",  in_id_space_target as "ID_SPACE_TARGET",  in_id_user as "ID_USER"
               )
         WHERE vc.id_vehicle = in_id_vehicle;
    
        RETURN count_;
    

    2. never generate XPATH strings dynamically (Note XMLTABLE simply will not allow it). It is almost impossible to optimize since in the case escalated, the query may be a function of the processing line, and it leaves the vulnerable application WHO the problems of injection. Earlier versions of XML DB supported the use of string concatenation technique to provide the value of predicate as a method of implementation of the bind variable, but from what I remember, this is only implemented and tested for storage relatiion object. Even when workng with storage relational object this technique should not be used in the development of new code n a 10.2.x post database. As far as I know this was not implemented for binary XML / XML INdex since the implementations of XMLQUERY, XMLTable and XMLEXists provided a much more robust implementation and standardized to link the underlying values at query runtime

    If you do not know the XPATH expression until run time please build the complete SQL statement dynamically and run it via EXECUTE IMMEDIATE or DBMS_SQL, then pay attention to injection vunerabilities in your application.

    The fact that you get different results seems to be the result of the previous method of binding of predicates works do not correctly with the XML Index. If the solution I gave above does not work, please fill out a bug and that we can continue the investigation

    Published by: mdrake on February 25, 2011 17:32

  • XMLTable performance vs TABLE (XMLSequence ())

    Hello world

    I encountered a problem which I hope I can find help with.

    He has a task to analyze a large XML text (~ 15 MB) and update a table based on it. So I created a procedure that takes a parameter of XMLType and does the job. Pretty simple. However, the thing is that if I use XMLTable, which is the preferred method to parse the XML, it runs for hours. Once I replace XMLTable with the method TABLE (XMLSequence ()), the procedure ends in less than two minutes on the same machine. Seems very strange to me.

    Any ideas what could be the cause of such a poor performance from XMLTable?
    Oracle version is 11.2.0.2.0

    H1. The table structure
    create table Points (
      member_id int not null,
      point_id int,
      country_numeric character(3),
      place national character varying(50),
      name national character varying(255),
      currencies national character varying(255),
      address national character varying(255),
      contact national character varying(40),
      contact_phone national character varying(40),
      details national character varying(255),
      enabled_date date,
      works national character varying(255),
      active character default 1 check (active in (0, 1)) not null,
      unique (member_id, point_id)
    );
    H1. XMLTable method
    runs for several hours, if the input parameter is long of ~ 15 MB
      create procedure update_Points (
        p_Points in xmltype
      ) as
      begin
        insert into Points (member_id, point_id, country_numeric, place, name, currencies, address, contact, contact_phone, details, enabled_date, works)
        select
          ap.member_id,
          ap.point_id,
          ap.country_numeric,
          ap.place,
          ap.name,
          ap.currencies,
          ap.address,
          ap.contact,
          ap.contact_phone,
          ap.details,
          to_date(ap.enabled_date, 'DD.MM.YYYY'),
          ap.works
        from
          xmltable('for $Point in /document/directory/reply[@type=''Points'']/data/row return element Point { attribute member_id { $Point/column[@col=''1'']/@value }, attribute point_id { $Point/column[@col=''2'']/@value }, attribute country_numeric { $Point/column[@col=''3'']/@value }, attribute place { $Point/column[@col=''4'']/@value }, attribute name { $Point/column[@col=''5'']/@value }, attribute currencies { $Point/column[@col=''6'']/@value }, attribute address { $Point/column[@col=''7'']/@value }, attribute contact { $Point/column[@col=''8'']/@value }, attribute contact_phone { $Point/column[@col=''9'']/@value }, attribute details { $Point/column[@col=''10'']/@value }, attribute enabled_date { $Point/column[@col=''11'']/@value }, attribute works { $Point/column[@col=''12'']/@value } }'
            passing p_Points
            columns
              member_id int path '@member_id',
              point_id int path '@point_id',
              country_numeric character(3) path '@country_numeric',
              place national character varying(50) path '@place',
              name national character varying(255) path '@name',
              currencies national character varying(255) path '@currencies',
              address national character varying(255) path '@address',
              contact national character varying(40) path '@contact',
              contact_phone national character varying(40) path '@contact_phone',
              details national character varying(255) path '@details',
              enabled_date character(10) path '@enabled_date',
              works national character varying(255) path '@works') ap;
      end;
    H1. Method table (XMLSequence ())
    2 minutes with the same input parameter
      create procedure update_Points (
        p_Points in xmltype
      ) as
      begin
        insert into Points (member_id, point_id, country_numeric, place, name, currencies, address, contact, contact_phone, details, enabled_date, works)
        select
          value(x).extract('row/column[@col=''1'']/@value').getStringVal() member_id,
          value(x).extract('row/column[@col=''2'']/@value').getStringVal() point_id,
          value(x).extract('row/column[@col=''3'']/@value').getStringVal() country_numeric,
          value(x).extract('row/column[@col=''4'']/@value').getStringVal() place,
          extractValue(value(x), '/row/column[@col=''5'']/@value') name,
          value(x).extract('row/column[@col=''6'']/@value').getStringVal() currencies,
          value(x).extract('row/column[@col=''7'']/@value').getStringVal() address,
          value(x).extract('row/column[@col=''8'']/@value').getStringVal() contact,
          value(x).extract('row/column[@col=''9'']/@value').getStringVal() contact_phone,
          value(x).extract('row/column[@col=''10'']/@value').getStringVal() details,
          to_date(value(x).extract('row/column[@col=''11'']/@value').getStringVal(), 'DD.MM.YYYY') enabled_date,
          value(x).extract('row/column[@col=''12'']/@value').getStringVal() works
        from
          table(xmlsequence(extract(p_Points, '/document/directory/reply[@type=''Points'']/data/row'))) x;
      end;
    H1. Small example of XML
    <?xml version="1.0"?>
    <document>
      <directory>
        <reply type="Points">
          <data>
            <row>
              <column col="1" value="0"></column>
              <column col="2" value=""></column>
              <column col="3" value="643"></column>
              <column col="4" value="Something"></column>
              <column col="5" value="&quot;Sample&quot;"></column>
              <column col="6" value=""></column>
              <column col="7" value="Blah"></column>
              <column col="8" value="Bar"></column>
              <column col="9" value="0123456789"></column>
              <column col="10" value=""></column>
              <column col="11" value="01.01.2010"></column>
              <column col="12" value=""></column>
            </row>
          </data>
        </reply>
      </directory>
    </document>
    Published by: 999663 on April 15, 2013 13:21

    Because you have them different tasks. With the XML Table, you create a game via the return of intermediate results. Why not use the same approach to Table (XMLSequence ()) as in

        select
          ap.member_id,
          ap.point_id,
          ap.country_numeric,
          ap.place,
          ap.name,
          ap.currencies,
          ap.address,
          ap.contact,
          ap.contact_phone,
          ap.details,
          to_date(ap.enabled_date, 'DD.MM.YYYY'),
          ap.works
        from
          xmltable('/document/directory/reply[@type=''Points'']/data/row'
            passing p_Points
            columns
              member_id int path 'column[@col="1"]/@value',
              point_id int path 'column[@col="2"]/@value',
              country_numeric character(3) path 'column[@col="3"]/@value',
              place national character varying(50) path 'column[@col="4"]/@value',
              name national character varying(255) path 'column[@col="5"]/@value',
              currencies national character varying(255) path 'column[@col="6"]/@value',
              address national character varying(255) path 'column[@col="7"]/@value',
              contact national character varying(40) path 'column[@col="8"]/@value',
              contact_phone national character varying(40) path 'column[@col="9"]/@value',
              details national character varying(255) path 'column[@col="10"]/@value',
              enabled_date character(10) path 'column[@col="11"]/@value',
              works national character varying(255) path 'column[@col="12"]/@value') ap;
    

    I hope it works now as fast as the old method, but you will need to provide the statistics on that. I'm interested to see the moment of execution.

    Now if you want it to run faster, then

    CREATE TABLE xml_hold (xml_col xmltype);  -- can be a global temporary table if you desire
    

    and in your code

    INSERT INTO xml_hold VALUES (p_points);
    

    then change select it above to

        from xml_hold xh
          xmltable('/document/directory/reply[@type=''Points'']/data/row'
            passing xh.xml_col
    

    This works because the default storage for XMLType columns in 11.2.0.2 was replaced by SECUREFILE XML BINARY. When you store XML in this column, Oracle preprocesses the XML file and stores the data in a binary format that is more effective to deal with. You can read about that in the Oracle documentation if you wish. Even with the charge to convert the XML into an internal format, the whole processing time should be faster given the application can now run much more efficiently.

  • How can I order items in a table of the element from the smallest to the largest?

    For example: I want to convert a table 1 d as [4,1,2,3] a table 1 d as [1,2,3,4]. How can I do?

    Sorry for the question but I am a beginner.

    Thanks for the replies.

    Go to the table palette; There is a sorting function node.

  • Download massive updated the planned orders in table msc_supplies

    Hi all

    I need your suggestion below requirement:

    For item RM, we planned order suggested that the CPHA; before releasing it, we want to change Date of implementation and the amount of order, then output the last modified scheduled released automatically to create the PR in purchases & Payables.

    In order to change the planned orders of RM, we export order planned the Workbench of the CPSA in the worksheet and then change dates, quantity, etc. in the worksheet. We want this change data to insert in the table msc_supplies automatically with manually intervene them and followed by releasing these planned automatically orders to create a PR

    We want to know how to achieve this requirement. We want to know the available custom hook and script to insert record in to msc_supplies.

    Have a great day.

    Thank you

    Sanngo

    Hello

    We expect steps below:

    (1) export the planned RM command suggested by the CPSA to the spreadsheet or report.

    (2) prepare the csv file with mandorty field as shown below in the table, i.e. date, quantity, etc. and format the data according to the custom intermediate table created.

    (3) custom concurrent requests created, which is used to locate the data file and upload the data to a custom intermediate table.

    (4) of the intermediate table that we are download the same data in the database MSC_SUPPLIES table (make a validation here check) in the same program. After that a manually scheduled commands added to the table of MSC_Supplies and can be found in the CPSA workbench.

    (4) in the same concurrent application of custom, call "automatic rejection" to release these records of the base table of msc_supplies, where release_flag a value of 1.

    We want to know the required fields need to be updated in the staging table custom and the base table:

    ORGANIZATION_CODE

    ORGANIZATION_ID

    ITEM_SEGMENTS

    INVENTORY_ITEM_ID

    ORDER_TYPE_TEXT

    ORDER_TYPE (5)

    New Date

    FIRM_DATE

    New quantity

    FIRM_QUANTITY

    Argument Plan_ID

    Transaction_id

    RELEASE_STATUS (1)

    SR_INSTANCE_ID

    You can test adding the manually planned adhoc decrees on Workbench CAWC namely, which are updating fields in the MSC_SUPPLIES table.

    Have a great day.

    Thank you

    Sannago

  • Adding field in the item table programmatically

    Hello.

    I'm doing a generic 'engine' for generating test reports/certificates.

    I made a custom data containing type report item, I used to do a local variables array of report called table of report item items.

    The data type contains generic areas (chain of title elements, a string of type item, etc.) and a container of the element data.

    The idea is to increment the array of items to report with report items and then fill the data container of the element with the fields of for example a Table element container.

    Either that, or just add a field in the report item with the data Table element type.

    But I can't find a way to add fields programmatically in a container.

    Anyone know if this is even possible?

    Found!

    Using from one stage of education, who points to the array of report items using the NewSubProperty method.

    Finished with the following statement:

    Parameters.Report_Element_Array.InsertElements (GetNumElements (Parameters.Report_Element_Array), 1, 0),
    Parameters.Report_Element_Array [GetNumElements (Parameters.Report_Element_Array)-1]. NewSubProperty("Element_Data",PropValType_NamedType,False,"NSE_Report_Table",0)

  • Update on the table by extracting the data from the table even under certain conditions

    Hi Experts,

    I have the table EMP which currently has 6 entries.

    EMP_SYS BATCH_NO JOIN_DATE LOGIN_ID STATUS FLAG

    1 FEBRUARY 10 PROD 84 Y IND123 ABC

    DEV 1-23 APRIL 98 Y IND123 ABC

    2 12 APRIL PROD 98 Y IND123 ABC

    2 2 APRIL DEV 98 Y IND123 ABC

    3 13 APRIL PROD 98 Y IND123 ABC

    3 3 APRIL DEV 98 Y IND123 ABC

    CONDITION: I need to take lines which has the minimum BATCH_NO for each of the EMP_SYS

    for example,.

    1 FEBRUARY 10 PROD 84 Y IND123 ABC

    DEV 1-23 APRIL 98 Y IND123 ABC

    For the above two lines, I need to update the status of DEF. How to select this criterion and update in the same query?

    Currently, I used the query to select the minimum BATCH_NO for each of the EMP_SYS below.

    SELECT EMP_SYS, BATCH_NO, JOIN_DATE, FLAG, LOGIN_ID, STATUS

    Of

    (

    EMP_SYS, BATCH_NO, JOIN_DATE, FLAG, LOGIN_ID, STATUS, SELECT ROW_NUMBER)

    COURSE NR (PARTITION BY ORDER OF EMP_SYS OF EMP_SYS)

    FROM EMP

    WHEN STATUS = 'ABC' AND FLAG = "Y".

    )

    WHERE

    NR = 1;

    If I try to use the update on the above query statement... It updates every 6 rows instead of 2 rows.

    Please suggest me a way to update only the two lines that has the minimum BATCH_NO for each of the EMP_SYS.

    But is possible to write the query without using the Group of?

    Update e EMP

    set STATUS = "DEF".

    where BATCH_NO = (select min (BATCH_NO) from EMP I where STATUS = 'ABC' AND FLAG = 'Y' and i.emp_sys = e.emp_sys)

  • How to change the order for table?

    I use oracle 10g 10.2.0.3.0

    I have a select statement
    SELECT /*+ leading v.Guest_Info v.Guest_Domain_Relation Guest_Address*/
    *
      FROM (SELECT 
             Cdr.Guest_Domain_Relation_Id,
             Ci.Guest_Id        
              FROM Guest_Info         Ci,
                   Guest_Domain_Relation Cdr
             WHERE Ci.Guest_Id = Cdr.Guest_Id) v,
           Guest_Address Ca
     WHERE v.Guest_Id = Ca.Guest_Id;
    and explain the Plan shows
    1     Plan hash value: 3785964411
    2      
    3     ---------------------------------------------------------------------------------------------------------
    4     | Id  | Operation                     | Name                    | Rows  | Bytes | Cost (%CPU)| Time     |
    5     ---------------------------------------------------------------------------------------------------------
    6     |   0 | SELECT STATEMENT              |                         |  1806 |   199K|     9  (23)| 00:00:01 |
    7     |*  1 |  HASH JOIN                    |                         |  1806 |   199K|     9  (23)| 00:00:01 |
    8     |   2 |   MERGE JOIN                  |                         |   482 | 48682 |     6  (17)| 00:00:01 |
    9     |   3 |    TABLE ACCESS BY INDEX ROWID| Guest_ADDRESS          |   919 | 87305 |     4   (0)| 00:00:01 |
    10     |   4 |     INDEX FULL SCAN           | XAK1Guest_ADDRESS      |   919 |       |     1   (0)| 00:00:01 |
    11     |*  5 |    SORT JOIN                  |                         |   482 |  2892 |     2  (50)| 00:00:01 |
    12     |   6 |     INDEX FULL SCAN           | XPKGuest_INFO          |   482 |  2892 |     1   (0)| 00:00:01 |
    13     |   7 |   VIEW                        | index$_join$_003        |  3493 | 41916 |     3   (0)| 00:00:01 |
    14     |*  8 |    HASH JOIN                  |                         |       |       |            |          |
    15     |   9 |     INDEX FAST FULL SCAN      | XAK1Guest_DOMAIN_Relation |  3493 | 41916 |     1   (0)| 00:00:01 |
    16     |  10 |     INDEX FAST FULL SCAN      | XPKGuest_DOMAIN_Relation  |  3493 | 41916 |     1   (0)| 00:00:01 |
    17     ---------------------------------------------------------------------------------------------------------
    18      
    19     Predicate Information (identified by operation id):
    20     ---------------------------------------------------
    21      
    Is there in any case, I have Guess_Domain_Relation table join firstly that the join to Guess_Address table of Guest_info?

    I tried a few ways to rewrite the query, but he's no luck

    Thank you

    Published by: Y.L on March 20, 2013 13:59

    Y.L wrote:
    And my another problem here... I don't know why my first clue didn't work...

    Probably the syntax. The main indicator uses parentheses, as

    /*+
    select /*+ leading(table1, table2) */ *
      from table1, table2
    */
    

    Remember that you must use the table alias name in tips for the identifier to be recognized

    You can also consider using the y indicator (if you must use a hint) for several tables - beware, it is MUCH easier to do worse performance with this suspicion using the order of the tables in the FROM clause in left to right

    /*+
    select /*+  ordered */ *
      from table1, table2, table3
    . . .
    */
    

    How I create index will affect how it works?

    How the index was created probably won't affect how it works. Indexes can be created using constraints and directly with the CREATE INDEX command. The creation of the index should not be as important as its defined characteristics: index type, columns, etc.

  • Values in the list by the order of table in SELECT Union

    Version: 11.2

    Apparently a very basic thing. But I couldn't do it :)

    In the UNION example below automatic sorting in is based on alphabetical order. I want to get rid of this sort and list the values according to the order of the table in the SELECT.

    Test data
    create table test1 (name1 varchar2(10));
    
    create table test2 (name2 varchar2(10));
    
    create table test3 (name3 varchar2(10));
    
    
    insert into test1 values ('EARTH');
    insert into test1 values ('TAURUS');
    insert into test2 values ('YELLOW');
    
    insert into test2 values ('ALPHA');
    insert into test2 values ('TANGO');
    
    
    insert into test3 values ('BRAVO');
    
    
    select name1 from test1
    union
    select name2 from test2
    union
    select name3 from test3;
    
    NAME1
    ----------
    ALPHA
    BRAVO
    EARTH
    TANGO
    TAURUS
    YELLOW
    
    6 rows selected.
    In the above example, I want the values in the first array SELECT listed first, then all the values of the second table in SELECT it and so on.

    Basically my requirement will be
    Return all values from test1 (alphabetically sorted)
    then
    Return all values from test2 (alphabetically sorted)
    then
    Return all values from test3 (alphabetically sorted)
    Expected results:
    NAME1
    ----------
    EARTH  ------------> from the first table in the SELECT
    TAURUS ------------> from the first table in the SELECT
    ALPHA  ----------------------> from the second table in the SELECT
    TANGO  ----------------------> from the second table in the SELECT
    YELLOW ----------------------> from the second table in the SELECT
    BRAVO  ------------------------------> from the third table in the SELECT

    Hello

    Union made a distinct in terms of the line. From the line "ALPHA", 2 and the line 'ALPHA', 3 are different, they both show in the result set.

    Further, you are all just lucky, that you get the results you want with the order clause:

    order by 2
    

    This performs a sort on the second column (1,2,3)
    Also, you want to sort on the first column (name1, name2 and Name3). The order clause should be (as already shown correctly abbove):

    order by
      2, 1
    

    Kind regards

    Peter

  • ORDER BY - table headers

    Hi Chaps,

    I have a DreamWeaver Recordset:

    @mysql_select_db ($database_conndb2, $conndb2);
    $query_rsProjects = "SELECT tbl_projects.projid, tbl_projects.projtitle, tbl_customers.custname, tbl_projects.projstart, tbl_projects.projdue, tbl_projects.projstatus, tbl_projects.projstatus, DATE_FORMAT (tbl_projects.projstart, '% d/%m/%Y'), like projstart_format, DATE_FORMAT (tbl_projects.projdue, '% d/%m/%Y'), projdue_format, tbl_projects.projpriority FROM tbl_projects, tbl_customers WHERE the tbl_projects.» FK_custid = tbl_customers. "CustID AND tbl_projects.projstatus! = 'Complete' ORDER BY PROJID ASC ';
    $rsProjects = mysql_query ($query_rsProjects, $conndb2) or die (mysql_error ());
    $row_rsProjects = mysql_fetch_assoc ($rsProjects);
    $totalRows_rsProjects = mysql_num_rows ($rsProjects);

    Data are presented in a table:

    < table border = "0" cellpadding = "0" cellspacing = "0" id = "tblrepeat_proj" >
    < caption >
    "" < img src = "... / Images/project.jpg ' border = '0' / > < a href =" project_add.php"" > < img src = ""... / Images/new.jpg "border = '0' / > < / has > < a href =" # "onclick ="print ()"" > < img src = ""... / Images/print.jpg "border = '0' / > < / has >"
    < / legend >
    < b >
    < scope = "col" th > Ref. < /th >
    < scope = "col" th > Document name < /th >
    < scope = "col" th > customer < /th >
    < scope = "col" th > Start Date < /th >
    < scope = "col" th > due Date < /th >
    < scope = "col" th > status < /th >
    < scope = "col" th > edit < /th >
    < scope = "col" th > delete < /th >
    < /tr >
    <? PHP {? >}
    < td >
    <? PHP echo $row_rsProjects ["PROJID'];? > < / span > < table >
    < td > < a href = "project_details.php? id = <?" PHP echo $row_rsProjects ["PROJID'];? > "> <?" PHP echo $row_rsProjects ["projtitle"];? > < /a > < table >
    < td > <? PHP echo $row_rsProjects ["custname"];? > < table >
    < td > <? PHP echo $row_rsProjects ["projstart_format"];? > < table >
    < td > <? PHP echo $row_rsProjects ["projdue_format"];? > < table >
    < td > <? PHP echo $row_rsProjects ["projstatus"];? > < / span > < table >
    < td > < a href = "project_edit.php? id = <?" PHP echo $row_rsProjects ["PROJID'];? > "> edit < /a > < table >"
    < td > < a href = "project_remove.php? id = <?" PHP echo $row_rsProjects ["PROJID'];? ">" onclick = "tmt_confirm ('Are % 20you % 20sure % 20you % 20want % 20to % 20delete % % 20record 20this?'); document to Retu rn. MM_returnValue"> delete < /a > < table >
    < /tr >
    <? PHP} while ($row_rsProjects = mysql_fetch_assoc ($rsProjects));? >
    < /table >

    Is it possible to use the table headers as the control of the ORDER BY in the SQL query?

    You can, but I think it's generally easier to use table sort client-side. It is much faster and easier to implement. Just get kind of table to the client side. Here is an example.

    http://www.Glendinning.org/WEBBuilder/sortTable/

  • single output item table

    I'm a picture fill successfully and now in train to go through each element and output of my VI.

    The problem I have is the for loop goes through without sending the value to my indicator. I flipped through all the options of tunnel and placed the marker inside the loop for. From my experience in programming, my logic seems solid. To finish > element in process > element Output > loop iteration until the condition is met. What is the missing piece that I can't translate into Labview code? Thank you.

    HI amacapa,

    you always miss the concept of stream...

    When FilteredOutput is an output of your VI you will always produce just a scalar value - after that the whole VI was executed!

  • Channel separation order waveform table parametricaly?

    Hello.

    I have an application where I gain two temperature & strain. The number of each type of sensors varies from one test to the other. I want graphic of each type on different graphics so that I can scale properly. I enclose a picture of my application.

    Is it possible to control through front?

    Say, using a digital command to set the number of strain gauges (first N channels are strain gauges, thermocouples of rest), then separate the data.

    Thank you

    Usuario

    Hi user,

    You can use the function split array.

    Mike

  • I'm not in fact it is a forum, but the Chat is closed (you know the one, open 24 hours 7 days a week).  I ordered items on March 5.  It is now March 7 and I always don't have not been "approved."  I needed the program 2 days ago.  Help?

    I really don't want this in a forum, but the Chat is closed (you know, the one that is available 24 hours a day 7 days a week).

    My apologies for the late reply.

    I left a private message. Please check & respond.

    Concerning

    Stéphane

  • ExtractValue, extracted, xmlsequence

    Could someone explain what extractvalue, xmlsequence and excerpt in the following query:
    select
       extractvalue(value(a),'Notebook/@Brand') As Brand
      ,extractvalue(value(a),'Notebook/@Model') As Model
    from prod_xml_tab b,
    table( xmlsequence( extract( demo_field,'Product/Notebook' ) ) ) a
    where demo_field is not null;
    I went through documentation and still don't get it and need some basic step by step explanations. for example, what actually GETS back for the first and second rows?
    the code in the table and the data is the following:
    create table prod_xml_tab (demo_field xmltype);
    
    insert into prod_xml_tab values('
      <Product type="Laptop">
                  <Notebook Brand="HP" Model="Pavilion dv6-3132TX Notebook">
                              <Harddisk>640 GB</Harddisk>
                              <Processor>Intel Core i7</Processor>
                              <RAM>4 GB</RAM>
                              <Price>1189</Price>
                              <Display Type="LED" MonitorSize="15.6"/>
                              <Weight>4.14</Weight>
                  </Notebook>
                  <Notebook Brand="HP" Model="HP Pavilion dv6-3032TX Notebook">
                              <Harddisk>640 GB</Harddisk>
                              <Processor>Intel Core i7</Processor>
                              <RAM>6 GB</RAM>
                              <Price>1104</Price>
                              <Display Type="LED" MonitorSize="15.6"/>
                              <Weight>4.1</Weight>
                  </Notebook>
                  <Notebook Brand="HP" Model="Pavilion dv6-3079TX Notebook">
                              <Harddisk>500 GB</Harddisk>
                              <Processor>Intel Core i7</Processor>
                              <RAM>4 GB</RAM>
                              <Price>1099</Price>
                              <Display Type="LED" MonitorSize="15.6"/>
                              <Weight>4.14</Weight>
                  </Notebook>
    </Product>');
    
    insert into prod_xml_tab values('
    <Product>
                  <Notebook Brand="Toshiba" Model="Satellite A660/07R 3D Notebook">
                              <Harddisk>640 GB</Harddisk>
                              <Processor>Intel Core i7</Processor>
                              <RAM>4 GB</RAM>
                              <Price>1444</Price>
                              <Display Type="LED" MonitorSize="15.6"/>
                              <Weight>4.88</Weight>
                  </Notebook>
    </Product>');

    943276 wrote:
    for example, if the first row not contained that single product/Notebook (as the second row) there is need to use TABLE (XMLSEQUENCE...), right? Only extractvalue (demo_field, "Product/Notebook/@Brand") would suffice, right? xmlsequence is necessary because the first line has several entrances laptop and all these multiple information is always returned as a bunch of items for laptop (knots?) instead of relational lines, is that correct? then xmlsequence comes into play in order to convert every book of this bunch of laptops in topics separated more later converted into relational lines by SCOREBOARD operator. is it more correct?

    Thank you

    Yep, that sounds about right.

    With XMLTABLE, it would be something like this...

    SQL> ed
    Wrote file afiedt.buf
    
      1  select x.*
      2  from   prod_xml_tab
      3        ,xmltable('/Product/Notebook'
      4                  passing prod_xml_tab.demo_field
      5                  columns Brand        varchar2(10) path './@Brand'
      6                         ,Model        varchar2(30) path './@Model'
      7                         ,Harddisk     varchar2(10) path './Harddisk'
      8                         ,Processor    varchar2(15) path './Processor'
      9                         ,RAM          varchar2(10) path './RAM'
     10                         ,Price        number       path './Price'
     11                         ,Display_Type varchar2(5)  path './Display/@Type'
     12                         ,Display_Size varchar2(5)  path './Display/@MonitorSize'
     13                         ,Weight       number       path './Weight'
     14*                ) x
    SQL> /
    
    BRAND      MODEL                          HARDDISK   PROCESSOR       RAM             PRICE DISPL DISPL     WEIGHT
    ---------- ------------------------------ ---------- --------------- ---------- ---------- ----- ----- ----------
    HP         Pavilion dv6-3132TX Notebook   640 GB     Intel Core i7   4 GB             1189 LED   15.6        4.14
    HP         HP Pavilion dv6-3032TX Noteboo 640 GB     Intel Core i7   6 GB             1104 LED   15.6         4.1
    HP         Pavilion dv6-3079TX Notebook   500 GB     Intel Core i7   4 GB             1099 LED   15.6        4.14
    Toshiba    Satellite A660/07R 3D Notebook 640 GB     Intel Core i7   4 GB             1444 LED   15.6        4.88
    
  • Extraction of a node in an XMLtype table - selection of the previous query

    Hey all,.

    I work with a server Oracle 11 g r2 and basically need to be able to analyse and select nodes from it. I spent hours scouring the net and reading the manual oracle xml db trying to find an appropriate solution to my problem, but I can't seem to identify the correct way to do it. I have some experience in programming, but none with databases oracle, sql or xml in general so forgive me if this is a trivial question.

    OK, so the question:

    I have a very simple XML file saved under catalog.xml and it is as follows:

    <>Catalog
    < cd >
    < title > hide your heart < /title >
    < artist > Bonnie Tyler < / artist >
    < Country > UK < / country >
    < company > CBS Records < / company >
    < price > 9.90 < / price >
    < year > 1988 < / year >
    < CD >
    < cd >
    Empire Burlesque < title > < /title >
    < artist > Bob Dylan < / artist >
    < country > USA < / country >
    < company > Columbia < / company >
    < price > 10.90 < / price >
    < year > 1985 < / year >
    < CD >
    < / catalogue >

    Now, I want to be able to extract the title of the given cd a certain artist. So, for example, if the artist is "bob dylan", the title should be "empire burlesque".

    Now I created an XMLType table in Oracle as follows:

    CREATE BINARY XMLTYPE STORE AS XML BINARY XMLType TABLE.

    I then load my xml file into oracle by:

    Insert the BINARY values (XMLTYPE (BFILENAME ('XML_DIR', 'catalog.xml'), nls_charset_id ('AL32UTF8')));

    So far so good.

    Now for the part of the excerpt:

    First of all I've tried:

    SELECT extract (b.object_value, ' / catalogue/cd/title ')
    Binary b
    WHERE existsNode (b.object_value,'/catalog/cd [artist = "Bob Dylan"]') = 1;

    EXTRACT(B.OBJECT_VALUE,'/CATALOG/CD/TITLE')
    --------------------------------------------------------------------------------

    < title > hide your heart < /title >
    Burlesque Empire < title > < /title >

    1 selected line.



    It did not work because the xml file was all in 1 row then I realized that I had to split my xml in separate rows. Doing that, I had to convert the nodes < title > a virtual table using the functions XMLSequence() and table(). These functions convert nodes two title returned by the extract() function in a virtual table composed of two XMLType objects, each of which contains a single title element.

    Second test:

    SELECT value (d)
    Binary B,
    Table (xmlsequence(extract(b.object_value,'/catalog/cd'))) d
    WHERE existsNode (b.object_value,'/catalog/cd [artist = "Bob Dylan"]') = 1;

    VALUE (D)
    --------------------------------------------------------------------------------

    < cd >
    < title > hide your heart < /title >
    < artist > Bonnie Tyler < / artist >
    < Country > UK < / country >
    < company > CBS Records < / company >
    < price > 9.90 < / price >
    < year > 1988 < / year >
    < CD >

    < cd >
    Empire Burlesque < title > < /title >
    < artist > Bob Dylan < / artist >
    < country > USA < / country >
    < company > Columbia < / company >
    < price > 10.90 < / price >
    < year > 1985 < / year >
    < CD >

    2 selected lines.


    It's better because it is now divided into 2 different lines so I should be able to make a selection - where, and then select the title from the artist.

    However, this is where I have questions, I tried to literally hours but I can't understand how to use the results of the query above in my next. So I tried to use a suquery in this way:

    Select extract (sub1, ' cd/title')
    Of
    (
    SELECT value (d)
    Binary B,
    Table (xmlsequence(extract(b.object_value,'/catalog/cd'))) d
    ) sub1
    WHERE existsNode (sub1,'/ cd [artist = "Bob Dylan"]') = 1;

    However, sql * plus displays an error:

    ORA-00904: "SUB1": invalid identifier.

    I've tried dozens of variations to try to use subqueries but I simly can't do things.

    I heard you can do also do this using variables or pl/sql, but I don't know where to start.

    Any help would be greatly appreciated I tried everything at my disposal.

    This should help you get started!

    select banner as "Oracle version" from v$version where banner like 'Oracle%';
    
    create table otn5test(
      id number,
      data xmltype
    );
    
    insert into otn5test values (1, xmltype('
    
    Hide your heart
    Bonnie Tyler
    UK
    CBS Records
    9.90
    1988
    
    
    Empire Burlesque
    Bob Dylan
    USA
    Columbia
    10.90
    1985
    
    
    '));
    
    select otn5test.id, x.*
    from otn5test,
         xmltable('/catalog/cd[artist/text()="Bob Dylan"]' passing otn5test.data
         columns title varchar2(20) path 'title') x;
    
    select otn5test.id,
           xmlcast(xmlquery('/catalog/cd[artist/text()="Bob Dylan"]/title'
                   passing otn5test.data returning content)
           as varchar2(20)) from otn5test;
    
    drop table otn5test;
    
    sqlplus> @otn-5.sql
    
    Oracle version
    ------------------------------------------------------------------------------
    Oracle Database 11g Release 11.2.0.1.0 - 64bit Production
    
    Table created.
    
    1 row created.
    
         ID TITLE
    ---------- --------------------
          1 Empire Burlesque
    
         ID XMLCAST(XMLQUERY('/C
    ---------- --------------------
          1 Empire Burlesque
    
    Table dropped.
    

Maybe you are looking for