Need help request! 2 tables

Using Coldfusion 8 and MySQL.  I have 2 tables, one called products (100 points) and another table called Clearance (5 items).

I see all 100 products and need to insert the discounted_price of the 5 elements of the game table in the query below.

(* write it down field discounted_price only exists in the table).

Also, how the returned below list can mark the checkboxes of the 5 elements of the game table.

(* note-productid is used in both tables. I guess you could call it the foreign key between tables).

I am a newbie and not sure how to write queries.  Any help would be appreciated.  Thanks in advance.

< cfoutput query ="getProducts">

< tr< cfif currentrow mod 2> class = 'weird'< / cfif >>

< td >< div align ="left">< entry type ="checkbox" name ="promo" value ="#">< table >

< td > (#getProducts.modelnumber #) #getProducts.modelnumber #< table >

< td >#getProducts.modeldescription #< table >

< td >#getProducts.category #< table >

< td >#getProducts.subcategory #< table >

< td > < input type ="text" name ="discounted_price" Value ="">< table >

< /tr >

< / cfoutput >


Select p.modelnumber, p.modeldescription, p.category, p.subcategory, C.discounted_price
left join products P C release on C.productid = P.productid

<>class = 'weird'>

checked >

#getProducts.modelnumber # (#getProducts.modelnumber #)

#getProducts.modeldescription #.

#getProducts.category #.

#getProducts.subcategory #.

I hope this helps...

Tags: ColdFusion

Similar Questions

  • Need help with a table

    Well guys I have a table which gives me positive and negative values.

    I need to use this table and get 2 new tables, one is the array of positive values, the second is the table with negative values, after that I need to get 2 values of it, one is the sum of all the positive elements and I need to know how much positive elements too.

    the second value is the sum of all the negatives and how much negative also.

    Example:

    Table: 5-12, 2, -3, 4

    First table: 5,2,4

    First value: 5 + 2 + 4 = 11

    Number of items: 3

    Second table:-12, -3

    Second value:-12+(-3) = - 15

    Number of items: 2

    Something like that!

    Thank you

    Here's my version 8.6

  • Need help request!

    Hi all

    I am faced with a request to generate a model:

    The problem is the following:

    I have a test table in

    create table test

    (

    Identification number,

    varchar2 (20 char) value,

    date date

    );

    and the row values are as follows:

    value date: ID:

    1:value1:Date1

    1:value2:date2

    1:value3:date 3

    where date1 is today, date2 is yesterday and date 3 is the day before yesterday.

    I have to generate a format like below:

    ID: old_value:new_value:changed_date

    1:value3:value2:date2

    1:value2:value1:Date1

    where id, old_value, new_value and modified date are columns.

    Any suggestions would be helpful.

    select *
    from (
      select id
           , lag(value) over(partition by id order by dt) as old_value
           , value as new_value
           , dt as changed_date
      from test
    )
    where old_value is not null ;
    
  • Desperately need help - "the partition table on device sda was unreadable." Erase all data?

    I'm forced to install CentOs on my Macbook using a machine virtual (VMWare, which is what I downloaded my teacher recommended). It's for my first class of operating systems, so bare with me because I don't know anything about operating systems (except about how to use Windows and my Macbook). I am also a daughter, what makes my same technical knowledge that much more rare. However, I am eager to learn...

    In any case, I downloaded them both. When I launch Fusion, I choose the file> New> install Windows or another OS on a virtual machine> continue without disk> click on the button that says 'Operating system installation disc using image file'> then I select the appropriate iso CentOS (CentOS - 5.4 - i386-bin-1of6) file> continue> drop down lists, I choose LINUX as operating system and Red Hat Enterprise Linux 5 as my Version> continue-> finish (no customization settings). It appears the screen of CentOS and I am invited by a text asking me if I want to install in text or graphics mode. (Don't know what to do here, but I select the graph). A bunch of white text scroll a screen of black background, then a blue screen shows up saying: 'Welcome to CentOS' at the top and a gray screen that says "to start testing CD media before installation OK press. Choose Ignore to ignore the media test and launch the installation. "I click on the red button (even once, if it is incorrect, let me know). A few rows of white text on black background (from anaconda... something on a video card...) then a nice graphic display of CentOS which I click NEXT. I then select English as my tongue (twice) and I gives me the message:

    "The partition table on device sda (VMware, VMware Virtual S 20473 MB) was unreadable. To create new partitions, it must be initialized, cauing the loss of all DATA on this drive. This operation will replace all choice on what players to ignore previous installation. You would like to initialize this drive, erasing all THE DATA? »

    I have no idea what to do here. I googled the message and others have been too, but they can talk about some hard file (and I have no idea what it is, and I can't seem to find mine).

    I can't lose what's on my hard drive (my school, music, photos, applications, files etc.). Clicking YES will erase my HD? I'm terribly afraid. I need to get this thing installed so I can do my operating systems class work, but I don't know if I did the installation correctly so far and especially, what to click at this point. Can someone help me out please (I spent 4 hours on this one today. "I have no one else to ask)? Finally, the installation is almost done after this step?

    Any help at all would be so greatly appreciated.

    I do not use Fusion, but I have VMware Workstation on Windows. I went through the same process that you went through. The answer to your question is that when you choose the operating system you install and you choose the option for the installation disc, it creates a virtual hard drive for you, size 20 GB. When they ask you to erase the hard drive, it's clear that virtual you create, not your actual computer hard drive. You can check by looking at the properties of the hard drive on your computer. It's probably 250 GB or 500 GB or something big like this. The CentOS WARNING speaks of a 20 GB hard drive, which is the size of the disk that VMware Fusion (and Workstation) create for CentOS.

  • Paging query needed help for large table - force a different index

    I use a slight modification of the pagination to be completed request to ask Tom: [http://www.oracle.com/technology/oramag/oracle/07-jan/o17asktom.html]

    Mine looks like this to extract the first 100 lines of everyone whose last name Smith, ordered by join date:
    SELECT members.*
    FROM members,
    (
        SELECT RID, rownum rnum
        FROM
        (
            SELECT rowid as RID 
            FROM members
            WHERE last_name = 'Smith'
            ORDER BY joindate
        ) 
        WHERE rownum <= 100 
    ) 
    WHERE rnum >= 1 
             and RID = members.rowid
    The difference between this and ask Tom is my innermost query returns just the ROWID. Then, in the outermost query we associate him returned to the members table ROWID, after that we have cut the ROWID down to only the 100 piece we want. This makes it MUCH more (verifiable) fast on our large tables, because it is able to use the index on the innermost query (well... to read more).
    The problem I have is this:
    SELECT rowid as RID 
    FROM members
    WHERE last_name = 'Smith'
    ORDER BY joindate
    It will use the index for the column predicate (last_name) rather than the unique index that I defined for the column joindate (joindate, sequence). (Verifiable with explain plan). It is much slower this way on a large table. So I can reference using one of the following methods:
    SELECT /*+ index(members, joindate_idx) */ rowid as RID 
    FROM members
    WHERE last_name = 'Smith'
    ORDER BY joindate
    SELECT /*+ first_rows(100) */ rowid as RID 
    FROM members
    WHERE last_name = 'Smith'
    ORDER BY joindate
    Whatever it is, it now uses the index of the column ORDER BY (joindate_idx), so now it's much faster there not to sort (remember, VERY large table, millions of records). If it sounds good. But now, on my outermost query, I join the rowid with the significant data in the members table columns, as commented below:
    SELECT members.*      -- Select all data from members table
    FROM members,           -- members table added to FROM clause 
    (
        SELECT RID, rownum rnum
        FROM
        (
            SELECT /*+ index(members, joindate_idx) */ rowid as RID   -- Hint is ignored now that I am joining in the outer query
            FROM members
            WHERE last_name = 'Smith'
            ORDER BY joindate
        ) 
        WHERE rownum <= 100 
    ) 
    WHERE rnum >= 1 
            and RID = members.rowid           -- Merge the members table on the rowid we pulled from the inner queries
    As soon as I did this join, this goes back to the use of the index of predicate (last_name) and perform the sort once he finds all the corresponding values (which can be a lot in this table, there is a cardinality high on some columns).

    My question therefore, in the query full above, is it possible that I can get to use the ORDER of indexing BY column to prevent having to sort? The join is what makes go back to using the predicate index, even with notes. Remove the join and just return the ROWID for these 100 records and it flies, even over 10 millions of documents.

    It would be great if there was some generic hint that could accomplish this, such as if we change the table/column/index, do not change the indicator (indicator FIRST_ROWS is a good example of this, while the INDEX indicator is the opposite), but any help would be appreciated. I can provide explain plans for the foregoing, if necessary.

    Thank you!
  • Need help with graph/table

    Heey everybody,

    I am currently using a Spider8 and Labview to get data from the sensors, after I use Labview to process the data in charts or graphs. Alltough I have 2 small problems using a table/chart:

    1: for some graphics I want to use 1 y axis (example: volts or current) and 1 x-axis, time. I want this time to be like clockwork that counts only the seconds (example: 0-100 sec), using absolute time or relative, for formatting is not an option because they rely much too strong/fast. There is an example of this type of charts in the Appendix: measurement of time current vs.

    2: for most of the other tables/graphs I want to use several axis y (example for a motor: current, RPM and torque) and I want to use a category axis that may go 'back' (example for a motor: rotations). There is an example of this type of charts in the Appendix: measurement of torque.

    I have no idea how to make good sense, so your help is welcome

    Thank you!

    Hi grasman,.

    have you read jcarmodys message on how to apply a trace on a scale there?

    See the attachment on how to draw 2 curves on a xy chart and attach each parcel on a scale. I strictly followed the message context help chart and jcarmodys...

    I would also say to stay away from express screws: they tend to make more problems than to provide aid. You are more involved in conversions of type (to/from DDT) - using simple son gives you simply more to control what's happening in your code!

  • Need help - multilevel nested table - create table problem

    Hello

    My version of oracle db: 11g

    I just created a table that contains a nested multi-level table.

    Here is the code:

    create or replace type sdef_t_nt_empNames21 is table of the varchar2 (50);

    create or replace type sdef_ot_SCmarks21 as an object (number of physics, chemistry number, number of Biology);

    create or replace type sdef_t_nt_SCmarks21 is table of the sdef_ot_SCmarks21;

    create or replace type sdef_ot_allsubmarks21 as an object (eid, eng, math, sc sdef_t_nt_SCmarks21 number number);

    create or replace type sdef_t_nt_dep_m_info21 is table of the sdef_ot_allsubmarks21;

    create the table nt_dep21

    (number of fact

    , dname varchar2 (50)

    c_sdef_t_nt_empNames21 sdef_t_nt_empNames21

    c_sdef_t_nt_dep_m_info21 sdef_t_nt_dep_m_info21)

    nested as NT_c_sdef_t_nt_empNames21 table c_sdef_t_nt_empNames21 store

    store table nested like NT_c_sdef_t_nt_dep_m_info21; c_sdef_t_nt_dep_m_info21  <-I know that the problem is here.

    TRACE OF THE ERROR:

    Error at startup on line: 13 in the command.

    create the table nt_dep21

    (number of fact

    , dname varchar2 (50)

    c_sdef_t_nt_empNames21 sdef_t_nt_empNames21

    c_sdef_t_nt_dep_m_info21 sdef_t_nt_dep_m_info21)

    nested as NT_c_sdef_t_nt_empNames21 table c_sdef_t_nt_empNames21 store

    Nested table c_sdef_t_nt_dep_m_info21 (sdef_t_nt_SCmarks21) store as NT_c_sdef_t_nt_dep_m_info21

    Error report-

    SQL error: ORA-00904: invalid identifier

    00904, 00000 - '% s: invalid identifier '.

    * Cause:

    * Action:

    PS: I'm just solve a problem given to me by some1, is not a practical implementation, I'm just trying to get through

    I'm sure that some1 could help me with this, I have searched a lot of this problem but could not find my answer, please help me.

    Concerning

    Rahul

    SQL > create table (nt_dep21)
    Did number 2,
    3 dname varchar2 (50).
    4 c_sdef_t_nt_empNames21 sdef_t_nt_empNames21,
    c_sdef_t_nt_dep_m_info21 5 sdef_t_nt_dep_m_info21
    6                       )
    store c_sdef_t_nt_empNames21 7 nested as NT_c_sdef_t_nt_empNames21 table
    store c_sdef_t_nt_dep_m_info21 8 table nested as NT_c_sdef_t_nt_dep_m_info21)
    9 table nested as NT_sc sc store
    10                                                                               )
    11.

    Table created.

    SQL >

    SY.

  • Need help with creating table that inserts the lines according to the amount of data

    Hello

    I try to create a table for supervisors to enter their subordinates of information and inserts lines for supervisors with several of his subordinates.  This form is not be connected to a data source, the supervisors will be simply fill out the form and print.  I want it sort of look like this:

    Name Position # Ranking Hours

    I really appreciate any help.  Thank you!

    Hi Laura,

    It's very strange. I downloaded a new version on the site and it works perfectly. The script is in the right place.

    I can sugggest you right click on the download link and select "save a copy as" the alternative menu. This should save the form locally and from there, you should be able to open it in Acrobat.

    If you are a Mac, make sure that the form opens in preview from Apple.

    Also make sure that Javascript is enabled in Acrobat (in the preferences window).

    Niall

  • Need help with a table, someone pls help8-)

    The problem I have right now is that I want to display variable myblock low 10 times and then test it for collison,.

    I use the variable to store the blocks, pls I apologize because I am new to this, if I put manally the variable i of lets say 1 and 2

    for collison, and then test it works, but when I use the loop for, it only detects that an object in the table, I think that there is something

    simple probably missing an additional variable, for example as you can see in the code that I am trying to use the 'i' to replace for example addChild(blockarray[1]);

    I put it manually to display two blocks in the code below, collison detection works, but when I want to use a loop to view and test the collison

    It takes only one of the blocks, don't know if it's because that variable i figure to 0 in the loop for, any help would be greatly appreciated, this is my first post here, as I'm new to Actionscript, ty for reading8-)

    var thehero:BlueBlock = new BlueBlock;
    Thehero.x = 20;
    Thehero.y = 20;
    addChild (thehero);


    var blockarray = new Array()

    for (var i: Number = 0; i < 10; i ++)

    This is where I place my blocks

    {

    var myblock:BlueBlock = new BlueBlock;
    [i] blockarray = myblock;


    blockarray [i] .x = Math.random () * 500;
    blockarray [i] there = Math.random () * 400;
    trace (blockarray [i]);
    blockarray.push (MyBlock);
    addChild (blockarray [i]);


    }
    addChild(blockarray[1]);
    addChild(blockarray[2]);

    Look for the keyboard events such as you pressed the arrow keys

    stage.addEventListener (KeyboardEvent.KEY_DOWN, myKeyDown);
    stage.addEventListener (Event.ENTER_FRAME, blockcollision);

    function myKeyDown (e:KeyboardEvent) {}

    If (e.keyCode == Keyboard.LEFT) {}
    Thehero.x-= 5;
    }

    If (e.keyCode == Keyboard.RIGHT) {}
    Thehero.x += 5;
    }

    If (e.keyCode == Keyboard.UP) {}
    Thehero.y-= 5;
    }

    If (e.keyCode == Keyboard.DOWN) {}
    Thehero.y += 5;
    }
    }
    function blockcollision(e:Event):void {}
    If (thehero.hitTestObject(blockarray[1]))
    {
    trace ("hit");

    }
    If (thehero.hitTestObject(blockarray[2]))
    {
    trace ("hit");

    }
    }

    Try this:

    function blockcollision(e:Event):void {
         for (var prop:String in blockarray) {
              if (thehero.hitTestObject(blockarray[prop]))
              {
                   trace("Hit", blockarray[prop]);
              }
         }
    }
    
  • Need help request not having

    -QUERY1
    SELECT DISTINCT A.EMP_ID
    OF EMP_ADDRESS A, USSX B, USERTVS C, D, UAS SDE E
    WHERE A.EMPC_ID = B.EMPC_ID
    AND C.SS_ID = B.SS_ID
    AND C.SS_ID = D.SS_ID
    AND D.SS_ID = B.SS_ID;

    HAVE A TABLE MORE

    -REQUEST 2
    Select C.EMP_ID from uaddressbs A, USSX B, EMP_ADDRESS C
    WHERE a.SS_ID = b.SS_ID =
    AND b.EMPC_ID c.EMPC_ID

    I JOINED the above QUERY to EXCLUDE THE VALUES RETURNING from THE query2 in query 1, but his does not work

    SELECT DISTINCT A.EMP_ID
    OF EMP_ADDRESS A, USSX B, USERTVS C, SDE D
    WHERE A.EMPC_ID = B.EMPC_ID
    AND C.SS_ID = B.SS_ID
    AND C.SS_ID = D.SS_ID
    AND D.SS_ID = B.SS_ID;
    and A.EMP_ID not in (select C.EMP_ID from uaddressbs A, USSX B, EMP_ADDRESS C
    WHERE the a.SS_ID = b.SS_ID = AND b.EMPC_ID c.EMPC_ID)

    Published by: [email protected] on May 27, 2009 10:21

    Please run the example INTERSECT, I have given and after the release.

    Please put {noformat}

    {noformat} before and after any code you're posting -- it makes it easier to read.
    
    Please show query +and the output+ of the query that you are running:
    

    WITH table1 AS)
    SELECT emp_id 123 OF DOUBLE UNION ALL
    SELECT 456 DOUBLE UNION ALL
    SELECT DOUBLE 890),
    Table2 AS)
    SELECT emp_id 456 OF DOUBLE UNION ALL
    SELECT DOUBLE 890)
    -end of test data
    SELECT *.
    FROM table1
    WHERE emp_id NOT IN ((in English only)
    SELECT emp_id
    FROM table2);

    EMP_ID
    ----------
    123

    SELECT *.
    FROM table1
    WHERE DOES NOT EXIST)
    SELECT 1
    FROM table2
    WHERE table1.emp_id = table2.emp_id);

    EMP_ID
    ----------
    123

    As you can see, only EMP_ID 123 was returned with both queries, so I don't see how you're getting the incorrect results.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
    
  • Need help with performance tables very very huge...

    Oracle Database 11 g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production.
    My DB has many tables and which I am interested in getting sales and product data.

    Select / * parallel 32 * / count (1))
    Select / * parallel 32 * / separate product pd, s sale prod_code
    where pd.prod_opt_cd is NULL
    and s.sales_id = pd.sales_id
    and s.creation_dts between to_date ('01-07-2012', "YYYY-MM-DD") and
    TO_DATE ('2012-07-31', "YYYY-MM-DD")

    );

    More information-
    Total of lines in the sales table - 18001217
    Total of lines in the product table - 411800392
    creation_dts don't have clue on this subject.


    I started the query in the background, but after 30 hours, I saw the error saying-
    ORA-01555: snapshot too old: rollback segment 153 with name number

    Is there another way to get over the optimized data?

    >
    Select / * parallel 32 * / count (1))
    >
    If you try to use a PARALLEL index and then use

    select /*+parallel (32) */count(1) from (
    

    See section PARALLEL to the doc of the SQL language indication
    http://docs.Oracle.com/CD/E11882_01/server.112/e26088/sql_elements006.htm#sthref669

  • Update sql need help for hierarchy table

    I'm trying to update the raw field based on each unit Qty is the appearance of the table.

    slevel | Manager | seller | unit_qty | gross Qty


    0 | Mary | Mary | 1. 1


    .1 | Mary | Lynn | 3. null


    .1 | Mary | Betty | 2. null


    .1 | Mary | Alice | 2. null


    .. 2. Alice | Susan | 1. null


    .1 | Mary | Amy | 4. null


    I'd like the table to look like this after the update, with the values

    slevel | Manager | seller | unit_qty | gross Qty


    0 | Mary | Mary | 1. 1


    .1 | Mary | Lynn | 3. 3 * 1 = {color: #ff0000} 3 {color}


    .1 | Mary | Betty | 2. 2 * 1 = {color: #ff0000} 2 {color}


    .1 | Mary | Alice | 2. {color: #008000} 2 * 1 {color} = {color: #ff0000} 2 {color}


    .. 2. Alice | Susan | {color: #0000ff} 1 {color} | {color: #008000} 2 * 1 {color} {color: #0000ff} * 1 {color} = {color: #ff0000} 2 {color}


    .1 | Mary | Amy | 4. 4 * 1 = {color: #ff0000} 4
    {color}
    It is the SQL, I've tried to use unsuccessfully.


    Update table set gross_qty = unit_qty * ({color: #ff0000} select gross_qty from table {color})


    ({color: #ff0000} where Manager = seller {color})


    where slevel & gt; 0

    This is not the same thing?

    UPDATE vendor s1
    SET s1.gross_qty =
    (CASE
    WHEN s1.slevel = 0 THEN s1.unit_qty
    WHEN s1.slevel > 0 THEN
    S1.unit_qty * (SELECT SELLER s2 WHERE s2.client = s1.manager s2.gross_qty)
    (END);

    I wrote here a basis of hierarchical queries:

    http://blog.mclaughlinsoftware.com/hierarchical-queries-basics/

    It could be that useful...

  • Need help to translate this into a request

    Need help to translate this into a request. I can make the followingusing a query?

    I have the data in this way and I want a report in one line.

    The available data as follows by joining 2-3 tables:

    er_id er_name carrier account records
    ------------------------------------------------------------
    1           XYZ           AT&T                     2
    1 XYZ Sprint 4
    1 Verizon Wireless XYZ 7
    XYZ T-Mobile 1 1
    2 AAA AT & T 18
    2 AAA Sprint 2
    2 AAA Sprint (Nextel) 1
    2 AAA T-Mobile 1

    Need the output in this format:

    ER_ID ER_NAME at & T, Sprint (Nextel) Sprint, Verizon Wireless, T-Mobile
    --------------------------------------------------------------------------------------------------------------------------
    1            XYZ               2            4                   0                                  7                            1
    2            AAA             18            2                   1                                  0                            1

    Is this possible with a simple query?

    It's called pivot. Assuming that you are on11g and AT & T, Sprint, Verizon Wireless and Sprint (Nextel), T-Mobile is a complete list of carriers:

    SET DEFINE OFF

    () AS T

    SELECT 1 ER_ID, ER_NAME "XYZ", "AT & T" COMPANY, NTC 2 UNION DOUBLE ALL THE

    SELECT 1, 'XYZ","Sprint", 4 DOUBLE UNION ALL

    SELECT 1, 'XYZ', "Verizon Wireless", 7 DOUBLE UNION ALL

    SELECT 1, 'XYZ', 't-Mobile', 1 DOUBLE UNION ALL

    SELECT 2, 'AAA', 'AT & T', 18 DOUBLE UNION ALL

    SELECT 2, 'AAA', 'Sprint', 2 DOUBLE UNION ALL

    SELECT 2, 'AAA', 'Sprint (Nextel)", 1 DOUBLE UNION ALL

    SELECT 2, 'AAA', 't-Mobile', 1 DOUBLE

    )

    SELECT ER_ID,

    ER_NAME,

    "" AT & T"_CNT" "AT & T"

    "" Sprint"_CNT" "Sprint."

    "" Sprint (Nextel)"_CNT" "Sprint (Nextel).

    "' T-Mobile"_CNT ""T-Mobile"

    ""Verizon Wireless"_CNT" "Verizon Wireless".

    T

    PIVOT)

    SUM (NTC) NTC

    Carriers to ("AT & T", "Sprint", "Sprint (Nextel)", "t-Mobile","Verizon Wireless)

    )

    /

    ER_ID ER_ AT & T Sprint Sprint (Nextel) T-Mobile Verizon Wireless
    ---------- --- ---------- ---------- --------------- ---------- ----------------
    1 XYZ          2          4                          1                7
    2 AAA         18          2               1          1

    Scott@pdb1orcl12 >

    Sy.

  • Need help in generating XML data to a table in XML format

    Hi all

    I need help to generate an xml file using the data below.

    The table name is T_Data have 4 columns as shown below with data.

    Neighbourhood region Division
    ---------- ----------------------- ----------- -----------
    Northwest Northern California San Jose SJStore1
    Northwest Northern California San Jose SJStore2
    Northwest North of California to the North of THE LAStore1
    Northwest North of California to the North of THE LAStore2
    Northwest North of California to the North of THE LAStore3

    I want to generate an XML file using SQL/XML functions and the XML file should look like as below.

    <>region
    < name of region > Northwest < / name of the region >
    < Division >
    Northern California < division name > < / Division name >
    District of <>
    SanJose < district name > < / District name >
    <>store
    < store name > SJStore1 < / name >
    < store name > SJStore2 < / name >
    < / store >
    < / district >
    < / division >
    < / region >

    Very much appreciate your help here.

    Thank you.

    I tried to group the lines, but they did not then provide a correct output.

    To unflatten dataset, we can use nested GROUP-BY subqueries.

    The following will produce a line by region.
    If all regions must be grouped in a single root element (does not so appear according to the directives of the sample), we just add an another XMLAgg.

    SQL> with sample_data as
      2  (
      3    select 'Northwest' reg, 'Northern California' div, 'San Jose' district, 'SJStore1' st from dual union all
      4    select 'Northwest' reg, 'Northern California' div, 'San Jose' district, 'SJStore2' st from dual union all
      5    select 'Northwest' reg, 'Northern California' div, 'North LA' district, 'LAStore1' st from dual union all
      6    select 'Northwest' reg, 'Northern California' div, 'North LA' district, 'LAStore2' st from dual union all
      7    select 'Northwest' reg, 'Northern California' div, 'North LA' district, 'LAStore3' st from dual
      8  )
      9  select reg
     10       , xmlserialize(document
     11           xmlelement("Region"
     12           , xmlelement("RegionName", reg)
     13           , xmlagg( division_xml )
     14           )
     15           indent -- for display purpose
     16         ) as region_xml
     17  from (
     18      select reg
     19           , xmlelement("Division"
     20             , xmlelement("DivisionName", div)
     21             , xmlagg( district_xml )
     22             ) as division_xml
     23      from (
     24          select reg
     25               , div
     26               , xmlelement("District"
     27                 , xmlelement("DistrictName", district)
     28                 , xmlelement("Store"
     29                   , xmlagg(
     30                       xmlelement("StoreName", st)
     31                     )
     32                   )
     33                 ) as district_xml
     34          from sample_data
     35          group by reg
     36                 , div
     37                 , district
     38      )
     39      group by reg, div
     40  )
     41  group by reg ;
    
    REG       REGION_XML
    --------- --------------------------------------------------------------------------------
    Northwest 
                Northwest
                
                  Northern California
                  
                    North LA
                    
                      LAStore1
                      LAStore3
                      LAStore2
                    
                  
                  
                    San Jose
                    
                      SJStore1
                      SJStore2
                    
                  
                
              
     
    
  • Need help for query flat_file type clobdata oracle table data.

    Hi Sir,

    I need help to query oracle table flat file data having given clob type.
    Oracle Version:
    
    Oracle Database 10g Express Edition Release 10.2.0.1.0 - Product
    PL/SQL Release 10.2.0.1.0 - Production
    "CORE     10.2.0.1.0     Production"
    TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    
    
    
    Source table
    
      CREATE TABLE order_details 
       (     QUEUE_SEQNUM NUMBER(10,0) NOT NULL ENABLE, 
         LINE_SEQNUM NUMBER(10,0) NOT NULL ENABLE, 
         CHAR_DATA CLOB, 
         OPTIMISTIC_LOCK_KEY NUMBER(20,0)
       ) 
    COLUMN FOR CHAR_DATA FLAT_FILE
    EU,6067AT,AT10,000000402004,NexiumGERDManagementProject,Z435,,ZZ29,NIS-GOLD,AT
    EU,6067AT,AT10,000000402038,NIS-OEU-ARI-2007/1,Z450,,ZZ29,NIS-OEU-ARI-2007/1,AT
    EU,6067AT,AT10,000000402039,SymbicortNISinCOPD,Z450,,ZZ29,NIS-REU-DUM-2007/1,AT
    EU,6067AT,AT10,000000402040,D1443L00044SeroquelXRRuby,Z450,,ZZ29,D1443L00044,AT
    EU,6067AT,AT10,000000402041,NIS-GEU-DUM-2008/1,Z450,,ZZ29,NIS-GEU-DUM-2008/1,AT
    EU,6067AT,AT10,000000402042,SonstigeAktivitätenLCM,Z450,,ZZ29,.,AT
    EU,6067AT,AT10,000000402134,D1680L00002Saxagliptin,Z450,,ZZ29,D1680L00002,AT
    EU,6067AT,AT10,000000402199,SeroquelWaveNIS,Z450,,ZZ29,NIS-NEU-DUM-2009/1,AT
    EU,6067AT,AT10,000000402313,SeroquelExtra(D1443L00082),Z450,,ZZ29,D1443L00082,AT
    EU,6067AT,AT10,000000402517,AtlanticD5130L00006(AZD6140),Z450,,ZZ29,D5130L00006,AT
    EU,6067AT,AT10,000000554494,ArimidexSt.Gallen(13+2),Z142,,ZZ09,,AT
    EU,6067AT,AT10,000000554495,ArimidexASCO(5delegates),Z142,,ZZ09,,AT
    EU,6067AT,AT10,000000554496,ArimidexSanAntonio6delegates,Z142,,ZZ09,,AT
    EU,6067AT,AT10,000000554497,ArimidexBreastCancerSummit(13+2),Z130,,ZZ09,,AT
    EU,6067AT,AT10,000000554498,ArimidexEIH(15delegates),Z130,,ZZ09,,AT
    EU,6067AT,AT10,000000554499,ArimidexNIFA(200delegates),Z135,,ZZ09,,AT
    EU,6067AT,AT10,000000554500,ArimidexNIFAworkshops(8x25),Z135,,ZZ09,,AT
    EU,6067AT,AT10,000000554501,ArimidexPraktischeGyn.Fortbildung,Z147,,ZZ09,,AT
    EU,6067AT,AT10,000000554502,ArimidexAGO,Z147,,ZZ09,,AT
    EU,6067AT,AT10,000000554503,ArimidexHämato/OnkologieKongress,Z147,,ZZ09,,AT
    EU,6067AT,AT10,000000554504,ARIMIDEXGYNäKOLOGENKONGRESS,Z147,,ZZ09,,AT
    EU,6067AT,AT10,000000554505,ArimidexChirurgenkongress,Z147,,ZZ09,,AT
    EXPECTED RESULTS:
    AFFIRM_CODE COMPANY_CODE INTERNAL_ORDER_CODE INTERNAL_ORDER_DESC ENIGMA_ACTIVITY             SUB_ACTIVITY_CODE IN_AFF_IND ORDER_TYPE EXTERNAL_ORDER COUNTRY        
    EU          6067AT       AT10                 000000402004       NEXIUMGERDMANAGEMENTPROJECT     Z435           NULL        ZZ29       NIS-GOLD        AT             
    EU          6068AT       AT11                 000000402005       NEXIUMGERDMANAGEMENTPROJECT     Z435           NULL        ZZ29       NIS-GOLD        AT             

    Sorry, my bad. Without database at hand, I'll try 'baby steps' (borrowed from Frank) so you don't confuse it with errors that I might add (happens far too often already, but at least you won't "swallow" as forum members think is one of the main goals of this fighter - help her learn - providing not only the proverbial fish.)
    Search the Forum - your problem is one of its best sellers. Watching {message identifier: = 10694602} ("split string into" was the key word used in research) you can try something as

    select table_row,
           level clob_row,
           regexp_substr(char_data,'[^' || chr(13) || chr(10) || ']+',1,level) the_line
      from (select to_char(queue_seqnum)||':'||to_char(line_seqnum) table_row,
                   char_data
              from order_details
           )
     connect by regexp_substr(char_data,'[^' || chr(13) || chr(10) || ']+',1,level) is not null
            and prior char_data = char_data
            and prior table_row = table_row
            and prior sys_guid() is not null
    

    to get all the s the_lineall CLOB and after that the use of the example even to get your columns of each the_line.

    Concerning

    Etbin

    Edited by: Etbin on 3.2.2013 09:01

    .. .but I m connected to do things according to the instructions, I can't do something.

    Used to happen to me too and I did as told to the but only after explaining any disadvantages, I was aware of in time. The last sentence is usually: "O.K. now be just and Don't come back with that kind of thing when it turns out that this isn't the right thing."
    rp0428 post - something to remember.

Maybe you are looking for