Trying to pivot based on a dynamically created query which generates XML data

Hi there,
Hope someone can help
I'm trying to pivot row data into a pivot type result set where the records for a given employee are pivoted to a single row.
To do this, I've declared a dynamic query to retrieve the GUID values of the different training course- the actual course names are full of SQL escape characters e.g. ', (,) which I thought might mess up the dynamically generated query
I've got as far as writing
DECLARE
@employeeidsVARCHAR(10)
DECLARE
@coursesVARCHAR(max)
DECLARE
@queryVARCHAR(max)
SELECT
  @courses=STUFF((SELECT 
DISTINCT[TRAIN_ID]
FROM  
[Megapay_IWA].[dbo].[HRS_TRAINING]
FORXMLPATH('')
),2,0,'')+']'
SET
@query=
'SELECT * FROM
(  SELECT t.TRAIN_TRAINING,
   EMPL_EMPLOYEE_ID
        FROM 
[Megapay_IWA].[dbo].[HRSTRNDONE] as tc
left  join  Megapay_IWA.dbo.PAYEMPL  as e on tc.TRND_ONRID = e.EMPL_EMPLOYEE_id
left join [Megapay_IWA].[dbo].[HRS_TRAINING] as t on tc.TRND_TRAIN_ID =t.TRAIN_ID
) t
PIVOT (COUNT(EMPL_EMPLOYEE_ID) FOR TRAIN_ID in
+@courses+'))
AS pvt'
EXECUTE
(@query)
which generates a dynamic query along the following lines but how to I update the query to correctly read the train_id values in the xml
SELECT * FROM
(  SELECT t.TRAIN_TRAINING,
   EMPL_EMPLOYEE_ID
        FROM 
[Megapay_IWA].[dbo].[HRSTRNDONE] as tc
left  join  Megapay_IWA.dbo.PAYEMPL  as e on tc.TRND_ONRID = e.EMPL_EMPLOYEE_id
left join [Megapay_IWA].[dbo].[HRS_TRAINING] as t on tc.TRND_TRAIN_ID =t.TRAIN_ID
) t
PIVOT (COUNT(EMPL_EMPLOYEE_ID) FOR TRAIN_ID in
<TRAIN_ID>F607BA64-BD24-4C6F-810E-001E7487FB4B</TRAIN_ID><TRAIN_ID>784EF318-628F-407E-8844-0049E3DD8F86</TRAIN_ID><TRAIN_ID>C7F3B365-7E6C-4CDF-9F0C-010207D1E493</TRAIN_ID><TRAIN_ID>7A82C4C1-5A9F-4EB0-9988-018405D3347A</TRAIN_ID><TRAIN_ID>E3FC88F5-AF5F-4D75-816A-02085190FC5C</TRAIN_ID><TRAIN_ID>BEB39D10-7887-494C-ADCC-0254A1514D06</TRAIN_ID><TRAIN_ID>6D870918-CFA1-4ADA-8427-049FF01902AC</TRAIN_ID><TRAIN_ID>61D1B40A-A9B6-4835-82C4-04FDCCAF7E6D</TRAIN_ID><TRAIN_ID>CA6D6B7-5ACA-4BE0-8A08-0EE87F77F10E</TRAIN_ID><TRAIN_ID>F86E6E93-544E-43F5-A97A-10E96834C781</TRAIN_ID><TRAIN_ID>EB898326-705F-4E70-B7BB-119B8953DFA9</TRAIN_ID><TRAIN_ID>491BFC77-0FA9-42C5-A255-11C49AA28CDD</TRAIN_ID><TRAIN_ID>C7A972FB-1E73-41FC-A4EF-12F5811C9853</TRAIN_ID><TRAIN_ID>3FD2CEE3-E85F-4624-87D7-13767D2DB391</TRAIN_ID><TRAIN_ID>F8A784C0-6E56-4769-92D2-1480BCAB2BEA</TRAIN_ID><TRAIN_ID>60D36A51-E642-40A2-A2F7-14D158B59781</TRAIN_ID><TRAIN_ID>67ED29A3-E2AD-42EC-8312-156084C0BB26</TRAIN_ID><TRAIN_ID>64B637B9-CC7D-47C8-9220-15D5FA76E65F</TRAIN_ID><TRAIN_ID>59B5D61C-4228-485D-89EE-185B74E42F3C</TRAIN_ID>
Note I'm also fine with updating the dynamic query to generate a statement that generates a normal where in constraint e.g.
PIVOT (COUNT(EMPL_EMPLOYEE_ID) FOR TRAIN_ID in
('F607BA64-BD24-4C6F-810E-001E7487FB4B','784EF318-628F-407E-8844-0049E3DD8F86')
Thanks
John

Thanks guys, that helped immensely,
For the record here is the slightly modified version [made generic to show the overall principle] that got it working for me in the end
DECLARE @ColumnList VARCHAR(MAX) = '';
DECLARE @query VARCHAR(max);
WITH Data AS (
        SELECT columnname
         FROM    dbo.table
         SELECT         @ColumnList +='[' +  [columnname] +'],'
         FROM         Data;
SET @ColumnList = STUFF(@ColumnList, 2, 0, '');
SET @ColumnList = LEFT(@ColumnList, LEN(@ColumnList) - 1)
--print @columnlist
SET @query=
'SELECT otherfields, ' +@ColumnList +' FROM
(  SELECT   otherfields,columnname, datefield
         FROM        dbo.table
) t
PIVOT (max(datefield) FOR [columnname] in (' +@ColumnList + ')
) AS pvt'
execute (@query)

Similar Messages

  • How set dynamically created query in GridControl?

    How set dynamically created query in GridControl?
    Thank you

    If your dynamic query is based on an Entity object, then you can probably use RowSetInfo setQueryInfo method.
    The argument to this method is a 'Query' object. There are three flavours provided in the oracle.dacf.dataset
    package.
    oracle.dacf.dataset.QueryViewInfo
    defines an updateable SQL query based on a predefined BC4J View Object.
    oracle.dacf.dataset.QueryStatementInfo
    Creates a view object based on an arbitrary SQL statement.
    oracle.dacf.dataset.QueryInfo
    Creates a View Object from an Entity Object and additional SQL clauses. The View Object will have
    that Entity Object as its sole Entity Object base.
    If in your application you are able to specify the name of the entity, then you can use the QueryInfo method to define your
    query. Please try the following.
    SessionInfo si = ....
    void runDynamicQuery()
    RowSetInfo rsi = new RowSetInfo();
    AttributeInfo ai = new AttibuteInfo(..);
    ai.setName(..);
    rsi..addChild(ai);
    si.addChild( rsi)
    rsi.setQueryInfo( new QueryInfo( ...../* include entity name */ .... ));
    rsi.setName(....);
    rsi.open(true);
    grid.setDataItemName(...);
    Hope this helps,
    Sathish.

  • Need generic dynamic sql query to generate nodes depending on dealer levels

    Input table:
    create table #test(dealerid integer ,dealerlvl integer)
    insert into #test values(1,1)
    insert into #test values(1,2)
    insert into #test values(1,3)
    insert into #test values(1,4)
    insert into #test values(2,1)
    insert into #test values(2,2)
    insert into #test values(2,3)
    insert into #test values(2,4)
    insert into #test values(2,5)
    insert into #test values(2,6)
    go
    create table #test2(dealerid integer,node integer,prntnode integer,dealerlvl integer)
    insert into #test2 values (1,234,124,2)
    insert into #test2 values (1,123,234,1)
    insert into #test2 values (1,238,123,2)
    insert into #test2 values (1,235,238,3)
    insert into #test2 values (1,253,235,4)
    insert into #test2 values (2,21674,124,3)
    insert into #test2 values (2,1233,21674,1)
    insert into #test2 values (2,2144,1233,2)
    insert into #test2 values (2,2354,2144,3)
    insert into #test2 values (2,24353,2354,4)
    insert into #test2 values (2,245213,24353,5)
    insert into #test2 values (2,2213,245213,6)
    Expected result :
    I have two test case here with dealerID1 and dealerID 2 
    Result for DealerID1
    Result needed for DealerID2:
    the levels for dealers might change (Dealer1 has 4 levels, and Dealer 2 has 6 levels) so i need to create an dynamic sql query which lists each node as separate columns depending on the levels. 
    I have hacked the query to give the result I need 
    select a.dealerid,a.node as Lvl1,b.node as lvl2,c.node as lvl3,d.node as lvl4
    from #test2 a 
    join #test2 b on a.node=b.prntnode
    join #test2 c on b.node=c.prntnode
    join #test2 d on c.node=d.prntnode
    where a.dealerid=1 and a.dealerlvl=2
    select  a.dealerid,a.node asLvl1,
    b.node as lvl2,c.node as lvl3,d.node as lvl4,e.node as lvl5,f.node as lvl6--,a.dealerlvl,a.dealerid
    from #test2 a 
    join #test2 b on a.node=b.prntnode
    join #test2 c on b.node=c.prntnode
    join #test2 d on c.node=d.prntnode
    join #test2 e on d.node=e.prntnode
    join #test2 f on e.node=f.prntnode
    where a.dealerid=2 and a.dealerlvl=3
    I am sure there is a better way to do this with dynamic sql. please help.
    Thanks

    -- Dynamic PIVOT
     DECLARE @T AS TABLE(y INT NOT NULL PRIMARY KEY);
    DECLARE
       @cols AS NVARCHAR(MAX),
       @y    AS INT,
       @sql  AS NVARCHAR(MAX);
    -- Construct the column list for the IN clause
     SET @cols = STUFF(
       (SELECT N',' + QUOTENAME(y) AS [text()]
        FROM (SELECT DISTINCT dealerlvl AS y FROM dbo.test2) AS Y
        ORDER BY y
        FOR XML PATH('')),
       1, 1, N'');
    -- Construct the full T-SQL statement
     -- and execute dynamically
     SET @sql = N'SELECT *
     FROM (SELECT dealerid, dealerlvl, node
           FROM dbo.Test2) AS D
       PIVOT(MAX(node) FOR dealerlvl IN(' + @cols + N')) AS P;';
    EXEC sp_executesql @sql;
     GO

  • How to create a report using XML data source from Crystal Report Designer

    Hi,
    Iu2019m having Crystal Report Designer XI R2 SP4. Iu2019m trying to create a report using XML data source stored on disk. This is a customer order report and the xml is structured in such a way that it has an order details header part (master) and then it has several order lines (detail). One order line can have several order line characteristics (detail-detail). So what I need to know is now I can design this layout from the designer. If this was done using views I can do it with sub-reports but using xml data this seems to be different. Can you help me to design this layout? I have included the xml and xsd as well.
    Thank you in advance.
    Regards,
    Chanaka
    XML
    <?xml version="1.0" encoding="UTF-8"?>
    <CUSTOMER_ORDER_CONF_REP_REQUEST xmlns:xsi="http://www.w3.org/2001/XMLSchema" xmlns="urn:ifsworld-com:customer_order_conf_rep">
        <CUSTOMER_ORDER_CONF_REP>
            <ORDER_NO>D555809</ORDER_NO>
            <PRINTED_DATE>2009-03-26T08:52:54</PRINTED_DATE>
            <AUTHORIZE_NAME>Chanaka</AUTHORIZE_NAME>
            <CUSTOMER_NO>CU-1473-INV</CUSTOMER_NO>
            <CUST_NAME>Mr.Johan Matts</CUST_NAME>
            <SHIP_ADDR_1>93,Main Street</SHIP_ADDR_1>
            <SHIP_ADDR_2>Negambo Road</SHIP_ADDR_2>
            <SHIP_ADDR_3>Watthala</SHIP_ADDR_3>
            <SHIP_ADDR_4>SRI LANKA</SHIP_ADDR_4>
            <BILL_ADDR_1>93,Main Street</BILL_ADDR_1>
            <BILL_ADDR_2>Negambo Road</BILL_ADDR_2>
            <BILL_ADDR_3>Watthala</BILL_ADDR_3>
            <BILL_ADDR_4>SRI LANKA</BILL_ADDR_4>
            <CUSTOMER_PO_NO>112984638</CUSTOMER_PO_NO>
            <CUSTOMER_FAX>112984639</CUSTOMER_FAX>
            <CUSTOMER_EMAIL>abcbababab</CUSTOMER_EMAIL>
            <ORDER_LINES>
                <ORDER_LINE>
                    <LINE_NO>1</LINE_NO>
                    <CUSTOMER_PART_NO>NW-IP11</CUSTOMER_PART_NO>
                    <CUSTOMER_PART_DESC>iPod</CUSTOMER_PART_DESC>
                    <SALE_UNIT_PRICE>1200</SALE_UNIT_PRICE>
                    <PRICE_TOTAL>1200</PRICE_TOTAL>
                    <DISCOUNT>0</DISCOUNT>
                    <PRICE_QTY>1</PRICE_QTY>
                    <ORDER_LINE_CHARACTERSTICS>
                        <CHARACTERISTIC_ITEM>
                            <CHARACTERISTIC_ID xsi:nil="1"/>
                            <CHARACTERISTIC_VALUE xsi:nil="1"/>
                        </CHARACTERISTIC_ITEM>
                    </ORDER_LINE_CHARACTERSTICS>
                </ORDER_LINE>
                <ORDER_LINE>
                    <LINE_NO>2</LINE_NO>
                    <CUSTOMER_PART_NO>NW-IP24</CUSTOMER_PART_NO>
                    <CUSTOMER_PART_DESC>XGA Projector</CUSTOMER_PART_DESC>
                    <SALE_UNIT_PRICE>500</SALE_UNIT_PRICE>
                    <PRICE_TOTAL>1500</PRICE_TOTAL>
                    <DISCOUNT>0</DISCOUNT>
                    <PRICE_QTY>3</PRICE_QTY>
                    <ORDER_LINE_CHARACTERSTICS>
                        <CHARACTERISTIC_ITEM>
                            <CHARACTERISTIC_ID>1</CHARACTERISTIC_ID>
                            <CHARACTERISTIC_VALUE>Free Instalation</CHARACTERISTIC_VALUE>
                        </CHARACTERISTIC_ITEM>
                    </ORDER_LINE_CHARACTERSTICS>
                </ORDER_LINE>
                <ORDER_LINE>
                    <LINE_NO>3</LINE_NO>
                    <CUSTOMER_PART_NO>NW-IP02</CUSTOMER_PART_NO>
                    <CUSTOMER_PART_DESC>Sony DVD Player</CUSTOMER_PART_DESC>
                    <SALE_UNIT_PRICE>1000</SALE_UNIT_PRICE>
                    <PRICE_TOTAL>1000</PRICE_TOTAL>
                    <DISCOUNT>0</DISCOUNT>
                    <PRICE_QTY>1</PRICE_QTY>
                    <ORDER_LINE_CHARACTERSTICS>
                        <CHARACTERISTIC_ITEM>
                            <CHARACTERISTIC_ID>1</CHARACTERISTIC_ID>
                            <CHARACTERISTIC_VALUE>Free 5 DVDs</CHARACTERISTIC_VALUE>
                        </CHARACTERISTIC_ITEM>
                    </ORDER_LINE_CHARACTERSTICS>
                </ORDER_LINE>
                <ORDER_LINE>
                    <LINE_NO>4</LINE_NO>
                    <CUSTOMER_PART_NO>NW-IP99</CUSTOMER_PART_NO>
                    <CUSTOMER_PART_DESC>Flatscreen TV</CUSTOMER_PART_DESC>
                    <SALE_UNIT_PRICE>1500</SALE_UNIT_PRICE>
                    <PRICE_TOTAL>1350</PRICE_TOTAL>
                    <DISCOUNT>10</DISCOUNT>
                    <PRICE_QTY>1</PRICE_QTY>
                    <ORDER_LINE_CHARACTERSTICS>
                        <CHARACTERISTIC_ITEM>
                            <CHARACTERISTIC_ID>1</CHARACTERISTIC_ID>
                            <CHARACTERISTIC_VALUE>Free Delivery</CHARACTERISTIC_VALUE>
                        </CHARACTERISTIC_ITEM>
                        <CHARACTERISTIC_ITEM>
                            <CHARACTERISTIC_ID>2</CHARACTERISTIC_ID>
                            <CHARACTERISTIC_VALUE>1 year additional warranty</CHARACTERISTIC_VALUE>
                        </CHARACTERISTIC_ITEM>
                    </ORDER_LINE_CHARACTERSTICS>
                </ORDER_LINE>
                <ORDER_LINE>
                    <LINE_NO>5</LINE_NO>
                    <CUSTOMER_PART_NO>NW-IP56</CUSTOMER_PART_NO>
                    <CUSTOMER_PART_DESC>Sony MP3 Player</CUSTOMER_PART_DESC>
                    <SALE_UNIT_PRICE>200</SALE_UNIT_PRICE>
                    <PRICE_TOTAL>400</PRICE_TOTAL>
                    <DISCOUNT>0</DISCOUNT>
                    <PRICE_QTY>2</PRICE_QTY>
                    <ORDER_LINE_CHARACTERSTICS>
                        <CHARACTERISTIC_ITEM>
                            <CHARACTERISTIC_ID>1</CHARACTERISTIC_ID>
                            <CHARACTERISTIC_VALUE>Free carry belt</CHARACTERISTIC_VALUE>
                        </CHARACTERISTIC_ITEM>
                        <CHARACTERISTIC_ITEM>
                            <CHARACTERISTIC_ID>2</CHARACTERISTIC_ID>
                            <CHARACTERISTIC_VALUE>Free promotional 4GB memory bar</CHARACTERISTIC_VALUE>
                        </CHARACTERISTIC_ITEM>
                        <CHARACTERISTIC_ITEM>
                            <CHARACTERISTIC_ID>3</CHARACTERISTIC_ID>
                            <CHARACTERISTIC_VALUE>No warranty on memory bar</CHARACTERISTIC_VALUE>
                        </CHARACTERISTIC_ITEM>
                    </ORDER_LINE_CHARACTERSTICS>
                </ORDER_LINE>
            </ORDER_LINES>
        </CUSTOMER_ORDER_CONF_REP>
    </CUSTOMER_ORDER_CONF_REP_REQUEST>
    XSD
    <?xml version="1.0" encoding="UTF-8"?>
    <?report  module="ORDER" package="CUSTOMER_ORDER_CONF_REP" ?>
    <xs:schema targetNamespace="urn:ifsworld-com:customer_order_conf_rep" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="urn:ifsworld-com:customer_order_conf_rep" elementFormDefault="qualified" attributeFormDefault="unqualified">
    <xs:element name="CUSTOMER_ORDER_CONF_REP_REQUEST">
    <xs:complexType>
    <xs:all minOccurs="1" maxOccurs="1">
    <xs:element name="CUSTOMER_ORDER_CONF_REP">
    <xs:complexType>
    <xs:choice minOccurs="0" maxOccurs="50">
    <xs:element name="ORDER_NO" nillable="true" minOccurs="0">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:maxLength value="2000"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    <xs:element name="PRINTED_DATE" type="xs:dateTime" nillable="true" minOccurs="0"/>
    <xs:element name="AUTHORIZE_NAME" nillable="true" minOccurs="0">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:maxLength value="2000"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    <xs:element name="CUSTOMER_NO" nillable="true" minOccurs="0">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:maxLength value="2000"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    <xs:element name="CUSTOMER_PO_NO" nillable="true" minOccurs="0">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:maxLength value="2000"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    <xs:element name="CUST_NAME" nillable="true" minOccurs="0">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:maxLength value="2000"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    <xs:element name="SHIP_ADDR_1" nillable="true" minOccurs="0">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:maxLength value="2000"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    <xs:element name="SHIP_ADDR_2" nillable="true" minOccurs="0">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:maxLength value="2000"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    <xs:element name="SHIP_ADDR_3" nillable="true" minOccurs="0">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:maxLength value="2000"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    <xs:element name="SHIP_ADDR_4" nillable="true" minOccurs="0">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:maxLength value="2000"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    <xs:element name="BILL_ADDR_1" nillable="true" minOccurs="0">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:maxLength value="2000"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    <xs:element name="BILL_ADDR_2" nillable="true" minOccurs="0">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:maxLength value="2000"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    <xs:element name="BILL_ADDR_3" nillable="true" minOccurs="0">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:maxLength value="2000"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    <xs:element name="BILL_ADDR_4" nillable="true" minOccurs="0">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:maxLength value="2000"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    <xs:element name="CUSTOMER_FAX" nillable="true" minOccurs="0">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:maxLength value="2000"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    <xs:element name="CUSTOMER_EMAIL" nillable="true" minOccurs="0">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:maxLength value="2000"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    <xs:element name="ORDER_LINES" nillable="true" minOccurs="0">
    <xs:complexType>
    <xs:sequence minOccurs="0" maxOccurs="unbounded">
    <xs:element name="ORDER_LINE">
    <xs:complexType>
    <xs:choice minOccurs="0" maxOccurs="39">
    <xs:element name="LINE_NO" nillable="true" minOccurs="0">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:maxLength value="2000"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    <xs:element name="SALE_UNIT_PRICE" type="xs:float" nillable="true" minOccurs="0"/>
    <xs:element name="PRICE_TOTAL" type="xs:float" nillable="true" minOccurs="0"/>
    <xs:element name="DISCOUNT" type="xs:float" nillable="true" minOccurs="0"/>
    <xs:element name="PRICE_QTY" type="xs:float" nillable="true" minOccurs="0"/>
    <xs:element name="CUSTOMER_PART_NO" nillable="true" minOccurs="0">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:maxLength value="4000"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    <xs:element name="CUSTOMER_PART_DESC" nillable="true" minOccurs="0">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:maxLength value="4000"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    <xs:element name="ORDER_LINE_CHARACTERSTICS" nillable="true" minOccurs="0">
    <xs:complexType>
    <xs:sequence minOccurs="0" maxOccurs="unbounded">
    <xs:element name="CHARACTERISTIC_ITEM">
    <xs:complexType>
    <xs:choice minOccurs="0" maxOccurs="6">
    <xs:element name="CHARACTERISTIC_ID" nillable="true" minOccurs="0">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:maxLength value="2000"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    <xs:element name="CHARACTERISTIC_VALUE" nillable="true" minOccurs="0">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:maxLength value="2000"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    </xs:choice>
    </xs:complexType>
    </xs:element>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    </xs:choice>
    </xs:complexType>
    </xs:element>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    </xs:choice>
    </xs:complexType>
    </xs:element>
    </xs:all>
    </xs:complexType>
    </xs:element>
    </xs:schema>

    Hi Sourashree,
    Thank you for the response and ideas you have given me so far. I can get the fetch the data from the data source without any problem. That is I do the following,
    1.     New Report
    2.     From Create New Connection-> XML
    3.     Provide the u201CLocal XML Fileu201D and have u201CSpecify Schema Fileu201D checked -> Next
    4.     Provide the u201CLocal Schema Fileu201D  -> Finish
    Then I can see the following under XML
    + CUSTOMER_ORDER_CONF_REP_REQUEST
            CUSTOMER_ORDER_CONF_REP_REQUEST
         CUSTOMER_ORDER_CONF_REP_REQUEST/CUSTOMER_ORDER_CONF_REP
         CUSTOMER_ORDER_CONF_REP_REQUEST/ CUSTOMER_ORDER_CONF_REP/ORDER_LINES
         CUSTOMER_ORDER_CONF_REP_REQUEST/ CUSTOMER_ORDER_CONF_REP/ORDER_LINES/ORDER_LINE
         CUSTOMER_ORDER_CONF_REP_REQUEST/ CUSTOMER_ORDER_CONF_REP/ORDER_LINES/ORDER_LINE/ORDER_LINE_CHARACTERSTICS
         CUSTOMER_ORDER_CONF_REP_REQUEST/ CUSTOMER_ORDER_CONF_REP/ORDER_LINES/ORDER_LINE/ORDER_LINE_CHARACTERSTICS/CHARACTERSTIC_ITEM
    And from here if I add the following three I can get all the fields I need to the report
         CUSTOMER_ORDER_CONF_REP_REQUEST/CUSTOMER_ORDER_CONF_REP
         CUSTOMER_ORDER_CONF_REP_REQUEST/ CUSTOMER_ORDER_CONF_REP/ORDER_LINES/ORDER_LINE
         CUSTOMER_ORDER_CONF_REP_REQUEST/ CUSTOMER_ORDER_CONF_REP/ORDER_LINES/ORDER_LINE/ORDER_LINE_CHARACTERSTICS/CHARACTERSTIC_ITEM
    Then I come to the Linking section. Here I canu2019t link anything. There is a common field called u201CInternal_IDu201D but I canu2019t link using it. So I get a message when I click Next. From here I add all the fields.
    For this point onwards only I need help. How do I group, add fields and design the layout so I can get an report output as follows.
    Date
    Order number                                   Authorized code
    Customer No
    Name
    Phone
    Fax email
    Shipping address 1                              Billing Address 1
    Shipping address 2                              Billing Address 2
    Shipping address 3                              Billing Address 3
    Shipping address 4                              Billing Address 4
    Order Line 1 detailsu2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026                      LINE_NO     CUSTOMER_PART_NO          CUSTOMER_PART_DESC     SALE_UNIT_PRICE     PRICE_QTY     DISCOUNT     PRICE_TOTAL
    Characteristic details belonging to Order line 1       CHARACTERISTIC_ID 1  CHARACTERISTIC_VALUE1
                                           CHARACTERISTIC_ID 2  CHARACTERISTIC_VALUE2
                                           CHARACTERISTIC_ID 3  CHARACTERISTIC_VALUE3
    Order Line 2 detailsu2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026
    Characteristic details belonging to Order line 2
    Order Line 3 detailsu2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026
    Characteristic details belonging to Order line 3
    Order Line 4 detailsu2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026
    Characteristic details belonging to Order line 4
    Order Line 5 detailsu2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026
    Characteristic details belonging to Order line 5
    How can I achieve this kind of a layout using the give xml and xsd? Should I use grouping if so how should I do the grouping?
    I have included the full xml and xsd in the first mail I posted but I canu2019t see it now. I can include that again if you want.
    Regards,
    Chanaka

  • Japanese characters alone are not passing correctly (passing like ??? or some unreadable characters) to Adobe application when we create input variable as XML data type. The same solution works fine if we change input variable data type to document type a

    Dear Team,
    Japanese characters alone are not passing correctly (passing like ??? or some unreadable characters) to Adobe application when we create input variable as XML data type. The same solution works fine if we change input variable data type to document type. Could you please do needful. Thank you

    Hello,
    most recent patches for IGS and kernel installed. Now it works.

  • Create XLS file with XML data

    Hello,
    Is there Java libraries to create Excel files from XML data, like FOP that creating PDF files ?
    Another question : where can I find the javadoc of FOP's classes, particularly org.apache.fop.apps.Driver class ? Because I can't find it on http://xml.apache.org
    Thanks

    Use http://jakarta.apache.org/poi/

  • (Urgent) Dynamically created buttons: which one?

    I need to dynamically create an array of gridpanels. There is a button and some other components on each gridpanel. I need to implement an action handler for the button (using method binding). But how do I know which button fires the event?
    Thanks a lot!

    Hi,
    One of the possible solutions is:
    Have a hidden field in the form. For each of the buttons write a javascript onclick event method in which the id of the button clicked is assigned to the hidden field. The value of this hidden field is available in the method handler. This helps in identifying which button was clicked.
    Hope this helps
    Cheers
    Giri

  • Dynamically creating multiple LineSeries from XML

    Hi,
    I'm unable to figure out why my chart does not display. My
    task is to read in an XML file, depending on which multiple line
    series will be created and displayed on a line chart. (I am using
    the Flex-Ajax Bridge)
    In my mxml, I have:
    [Bindable]
    public var _elements:XMLList;
    public function createXMLList(data:String):XMLList
    var _xml:XML = new XML(data);
    _elements = _xml.elements();
    return _elements;
    <mx:Panel width="450" height="400" id="panel" >
    <mx:LineChart id="chart" height="350" width="300"
    paddingLeft="5" paddingRight="5"
    showDataTips="true" visible="false"
    dataProvider="{_elements}">
    </mx:LineChart>
    </mx:Panel>
    In my html file, I use the XMLHttpRequest to get my xml and
    do the
    following:
    function createChart() {
    if (req.readystate == 4 && req.status == 200) {
    var seriesArray = new Array();
    var flexApp = FABridge.example.root();
    var chart = flexApp.getPanel().getChildByName("chart");
    var s =
    FABridge.example.create("mx.charts.series.LineSeries");
    flexApp.createXMLList(req.responseText);
    s.set("yField", "datapoint");
    seriesArray.push(s);
    chart.setSeries(seriesArray);
    chart.setVisible("true");
    My XML file has the following structure:
    <?xml version="1.0" encoding="utf-8"?>
    <result metricDfn="Price">
    <company1 id="1">
    <datapoint date="Jan">50</datapoint>
    <datapoint date="Feb">60</datapoint>
    <datapoint date="Mar">40</datapoint>
    <datapoint date="Apr">50</datapoint>
    <datapoint date="May">40</datapoint>
    </company1>
    </result>
    Anything obvious that I'm not doing right?

    This link is great for describing how to manipulate charts in ActionScript:
    http://livedocs.adobe.com/flex/3/html/help.html?content=charts_intro_7.html
    If this post answers your question or helps, please mark it as such.

  • Can I create an XSD from XML data in a CLOB?

    Environment:
    Oracle 11.2.0.3 EE on Solaris.
    Very much an XML newbie so please be kind! 
    I have spent the past few days pouring through the documentation and various blogs, especially this one, but ... I need some help.
    I am trying to extract XML data stored in a CLOB and produce a flat file for the user's consumption.
    They have sent me what they think is the XSD for the XML data but when I look at the data in the CLOB I don't see the tags documented in the XSD.
    I'd like to produce an XSD based on the actual data to compare with what they've sent.
    Is this possible?
    I am able to query the XML data using the tags I see in the data using XMLTable and it's working fine.
    Any help is greatly appreciated.
    -gary

    Welcome to the XML side of the world, where you will love it and curse it, just like any other piece of technology.
    So as I understand it, the scope of your operation is to extract information from an XML file and then write that information to disk, correct?
    Some questions
    - Why is the XML stored in a CLOB instead of an XMLType column?  Without knowing the system history, it is a valid question.
    - How big are the XML?  The reason I ask this is because when the XML is stored in XMLType columns (of Object Relational structure or SECUREFILE BINARY XML format), then Oracle can parse the XML substantially easier than when it is stored as a CLOB.  If the XML is fairly small, you may see no performance difference between the two.
    The Oracle DB itself has no built in ability to generate a schema from an XML file.  In order to do that, you would need to use some third party tool that has that functionality built in.  For example, XML Spy can do this.  Other tools can as well, but that is what came to mind first as it is what I use.  The one thing to remember is that the schema it builds represents that one instance of XML.  Other instances of XML may be different and not validate against the schema you generated, but still have been valid against the unknown original schema.
    You can register the schema in the database and then use the XML to create an XMLType instance associated to the schema and then validate the XML that way.  One example can be found at XML DB FAQ and here is another example Re: XML Schema validation
    Hope that helps you continue on.

  • Query with bind var created under apex to generate xml data

    Hi all;
    BiP: 10.1.3.4
    Apex: 4
    DB 10G
    Goal: want to generate a report by running a query with bind variables under apex.
    problem: when attempted to create a query under shared components in apex, at the downloading xml data stage, I always get "no data found" eror. Thus I can't save xml data for further report work. This only occurs when bind var involved. I have tticked "incl. session variables" and added the item but to no avail.
    Does anyone know how to do this and get the xml data to recive the bind variable ?
    Thanks.
    lulu

    To get the xml data, sql query has to return something. Why the sql is not returning anything can be better investigated outside the BI Publisher with special tool like SQL Developer or TOAD. There you have to run your query and make it working. One of the steps would be to try the sql without the parameter, see what data it brings back and go from there. One of possibilities why the parameter kills the output may be the NULL values involved, but you need to try the sql outside the BIP first.

  • Dynamically create Value Objects from XML file

    Hi
    I want to create a value object from Xml file dynamically,like in the xml file i have the name of the variable and the datatype of the variable.is it possible do that,if so how.

    Read about apache's Digester tool. This is part of the Jakartha project. This tool helps in creating java objects from the XML files. I am not sure, if that is what u r looking for.

  • Dynamically create Payload with snippet of data

    I have requirement to validate the payload in custom Java mapping and create snippet of data from current payload as separate payload.
    Why need snippet as seperate payload - Business requirement is to error out this payload and after fixing the error on target system, they want to rerun the errored payload loater, and did not want to stop the rest of data in first payload.
    These errors should be queued to further process as the errors got fixed.
    I appreciate any thoughts regarding this.

    Hi ravi,
    Could you please go through this weblog /people/ranjit.deshmukh/blog/2008/01/14/validations-using-java-for-those-not-having-pi71 and find whether it can help to resolve your issue.
    Cheers,
    Jag

  • Dynamically creating reports with an xml file and a dataset??

    Post Author: Xaisoft
    CA Forum: .NET
    I have an xml file I created called ReportFields.xml which looks like this:
    <?xml version="1.0" encoding="utf-8" ?>
    <ReportFields>
    <AccountNumber></AccountNumber
    <FirstName></FirstName>
    <LastName></LastName>
    </ReportFields>
    I then create a blank crystal report and go into the Database Expert and choose ADO.NET DataSets, I browse to the xml file I just created, in this case ReportFields and give it a Class Name of ReportFields.  Now under Database Fields, I have a ReportFields table with the following columns:
    AccountNumber, FirstName, and LastName.
    I drag AccountNumber onto the Details section of the report.  I have a stored procedure I created called GetAccts which basically has the following syntax:
    select top 50 a.Account_Number from tbAccounts.
    Depending on which client database this is run against, it will obviously return different results.  I am using the Microsoft Application Data Access Block from Enterprise Library 3.1 to Return a DataSet.  Once I get the DataSet which would only have 1 table with 1 column (Account Numbers), how can I bind the AccountNumber field on the report to what is returned in the DataSet?
    Thanks Very Much in Advance,
    Xaisoft

    OK, i figured this much out:
    Dim ds As New DataSet
            Dim myXmlReader As New System.Xml.XmlTextReader("C:\SystemSetup.xml")
            ds.ReadXml(myXmlReader, XmlReadMode.InferTypedSchema)
            mydatatable = ds.Tables(0)

  • Linking a class to a dynamic text field to load XML data.

    Hi,
    I'm quite new to ActionScript and would be grateful for any help here.
    I want to load text into a dynamic text field (called 'about_tab') using  a class depending on the language selected (by clicking on a flag icon)  by the user.
    I managed to get this to work when the ActionScript was written directly  in the timeline, but am having problems with doing the same thing via a  class.
    This is my class file:
    package
    import flash.display.SimpleButton;
    import flash.display.MovieClip;
    import flash.events.MouseEvent;
    import flash.net.URLRequest;
    import flash.net.URLLoader;
    import flash.events.Event;
    public class ChangeLang extends SimpleButton
    public function ChangeLang()
    addEventListener(MouseEvent.CLICK, switchLang);
    trace("ChangeLang class working");
    public function switchLang(event:MouseEvent):void
    var lang = event.target.name;
    var req:URLRequest = new  URLRequest("languages/"+lang+".xml");
    var loader:URLLoader = new URLLoader();
    var substance:XML;
    function xmlLoaded(event:Event):void
    trace("function xmlLoaded is running");
    substance = new XML(loader.data);
    about_tab.text =  substance.about_lbl;
    loader.addEventListener(Event.COMPLETE, xmlLoaded);
    loader.load(req);
    Here's one of my XML files (the other is the same except "About" is  written in German):
    <substance>
    <about_lbl>About</about_lbl>
    </substance>
    When I run it, it returns my trace statements that the class ChangeLang  and the function xmlLoaded are running, but no text appears in the  dynamic text field (I should/want to see the word 'About'). I get this  error message:
    1120: Access of undefined property about_tab
    The problem, I'm guessing, is in the part in red in my code. I think I need to target the text field in the display list by creating a  reference to it. If so, could someonw point out how I do this, or perhaps a tutorial that would help. I've tried adding the word stage (i.e.,stage.about_tab.text =  substance.about_lbl; ) but it still doesn't connect. I guess there's something really simple I'm missing, so I  apologize if this comes across as a stupid question
    Thanks for any help.

    Hello flashrocket!
    I'm also new to AS3 and I've just started using external classes and I think I know what you should do to put your code to work.
    Instead of using the text field you created inside your flash file, why don't you use the "TextField" class to create an instance of this object? It's the exact same thing as when you create and instantiate a new text field inside Flash.
    First, import flash.text.*; (includes classes like TextField, TextFieldAutoSize, TextFormat, TextFormatAlign, etc)
    Than you just have to create a var like
    public var about_tab : TextField;
    or
    public var about_tab : TextField = new TextField();
    then, to adjust the properties of this tab you use dotsyntax as if it where on your stage like:
    about_tab.x = 50; about_tab.alpha = .5; etc...
    you can even create a function to "config your textField"
              private function createAndConfigTextField() : void {
                   about_tab = new TextField(); //you only need this line if you
              // only typed something like "public var about_tab:TextField;
              // if instead you used "public var about_tab:TextField = new TextField(); outside
              // this function, just skip this first line because you already have an instance of
              // text field named "about_tab"...
                            about_tab.autoSize = TextFieldAutoSize.CENTER;
                   about_tab.background = true;
                   about_tab.border = true;
                   var aboutTextFormat : TextFormat = new TextFormat();
                   format.font = "Arial";
                   format.color = 0x000000;
                   format.size = 11;
                   format.bold = true;
                   format.align = TextFormatAlign.CENTER;
                   about_tab.defaultTextFormat = aboutTextFormat;
                   addChild(about_tab);
    This is just an example of what you can do... I hope you get it... let me know if you have any doubt...

  • Creating af:Table programatically : XML Data coming from CLOB

    Hi ,
    This is my Use case ::
    JDev version :: 11.1.2.3
    I am presenting my use case in XE database format.
    1) We have a procedure say:
    PROCEDURE GET_EMP_FOR_DEPT(DeptId IN Number,XMLDeptData OUT CLOB);
    based on DeptId Input it returns the Employees Under Department.
    2) Have created JaxB class using xsd say EmpUnderDeptDataSet.java
    3) I have created method for calling this proc and and receiving the CLOB as output in the object of Type
       EmpUnderDeptDataSet , in AMImpl class
    4) We don't have the choice for creating EJB or other Data Control....and Programmatic EO..VO...
       So added method to expose the Data received as List using client Interface in AMImpl
        public List<EmpUnderDeptDataSet> getEmpUnderDeptCollection();
    5) Now we need to have 1 Page where on Left Panel we have LOV to select the Dept.
    On right panel, based on DeptId selected we have to show the Table of Employees returned
    by the procedure.Refreshed every time the DeptId changes
    Also, the Left Panel has to be Region.
    How can we implement this. Please advise.

    Use the EXTRACTVALUE SQL function.
    XMLType Operations

Maybe you are looking for

  • G/L A/C OUTSTANDING SHOWING CLEARED IN ALL ITEMS ON SAME DATE

    Dear Expert G/L A/C outstanding documents are showing cleared transactions in all items category using the same date in FBL1N. To illustrate in detail when we click on the radio button with open item with date 17.11.2009 i  m getting certain uncleare

  • Video camera doesn't work after installing IOS 7

    I can't use video camera with iPad 2 after upgrading to IOS 7. Anyone knows why?

  • Reaching Swing Components

    I am having a problem with a program, i am using a variation of the InternalFrameDemo as a base for my user interface. Its just that some sections of the program are not accessable to other parts of the program as far as i can see. In the following p

  • Custom Finders

    Is it possible to implement a finder that achieves "Select from myTable where id1='abc' and id2='def' and id3='ghi'" The number of arguments in where being variable (i.e 1 to 3). I tried using a finder with the following EjbQL "SELECT OBJECT(p) FROM

  • Recording forced to stop low system resources

    Hi Everyone, I hop that you can help. I'm trying Captivate as a solution for ctreating online tutorials for my clients. This involves on-screen demos along with soem text slides, nothing fancy... Up until today I'v e been very happy with what I have