Include Column type in XML result set

Hi
I'm trying to get result of my query as XML but how I can specify columns data type in xml attributes?
This is my query:
SELECT * FROM Acc.GL FOR XML AUTO, ELEMENTS, TYPE, BINARY BASE64;
Unfortunately in XML result, column types are not specified:
<row>
<Id>23</Id>
<GLCode>1</GLCode>
<BranchRef>1</BranchRef>
<Title>Foo Title</Title>
<Balance>1</Balance>
</row>
<row>
<Id>24</Id>
<GLCode>2</GLCode>
<BranchRef>1</BranchRef>
<Title>Bar Title</Title>
<Balance>1</Balance>
</row>
What I expect is something like this:
<row>
<Id type="int">23</Id>
<GLCode type="int">1</GLCode>
<BranchRef type="int">1</BranchRef>
<Title type="nvarchar">Foo Title</Title>
<Balance type="int">1</Balance>
</row>
<row>
<Id type="int">24</Id>
<GLCode type="int">2</GLCode>
<BranchRef type="int">1</BranchRef>
<Title type="nvarchar">Bar Title</Title>
<Balance type="int">1</Balance>
</row>
What should I change in my query?
Jalalx

how I can specify columns data type in xml attributes?
Hello,
XML Format don't allow to specify the data types in this way, you have to create XSD = "Schema Definition" instead, here are the data types defined.
Olaf Helper
[ Blog] [ Xing] [ MVP]

Similar Messages

  • How to return two XML result sets using the function

    Hi Experts,
    Thanks.

    So that I want to return two XML result sets if the query returns more than 50,000 records.
    One XML result set with 50,000 and another XML result set with remaining records.
    How to incorporate this in my function.
    Have the function return a collection of CLOB then.
    DBMS_XMLGEN can handle pagination so it's easy to adapt your existing code.
    Here's an example fetching data in batches of max. 3 rows each, using a pipelined function :
    SQL> create or replace type clob_array is table of clob;
      2  /
    Type created
    SQL>
    SQL> create or replace function genXmlRowset (p_deptno in number) return clob_array pipelined
      2  is
      3    ctx    dbms_xmlgen.ctxHandle;
      4    doc    clob;
      5  begin
      6 
      7    ctx := dbms_xmlgen.newContext('SELECT empno, ename FROM scott.emp WHERE deptno = :1');
      8    dbms_xmlgen.setBindValue(ctx, '1', p_deptno);
      9    dbms_xmlgen.setMaxRows(ctx, 3);
    10 
    11    loop
    12 
    13      doc := dbms_xmlgen.getXML(ctx);
    14      exit when dbms_xmlgen.getNumRowsProcessed(ctx) = 0;
    15      pipe row (doc);
    16 
    17    end loop;
    18 
    19    dbms_xmlgen.closeContext(ctx);
    20 
    21    return;
    22 
    23  end;
    24  /
    Function created
    SQL> set long 5000
    SQL> select * from table(genXmlRowset(30));
    COLUMN_VALUE
    <?xml version="1.0"?>
    <ROWSET>
    <ROW>
      <EMPNO>7499</EMPNO>
      <ENAME>ALLEN</ENAME>
    </ROW>
    <ROW>
      <EMPNO>7521</EMPNO>
      <ENAME>WARD</ENAME>
    </ROW>
    <ROW>
      <EMPNO>7654</EMPNO>
      <ENAME>MARTIN</ENAME>
    </ROW>
    </ROWSET>
    <?xml version="1.0"?>
    <ROWSET>
    <ROW>
      <EMPNO>7698</EMPNO>
      <ENAME>BLAKE</ENAME>
    </ROW>
    <ROW>
      <EMPNO>7844</EMPNO>
      <ENAME>TURNER</ENAME>
    </ROW>
    <ROW>
      <EMPNO>7900</EMPNO>
      <ENAME>JAMES</ENAME>
    </ROW>
    </ROWSET>
    SQL>
    (and don't forget to use bind variables in your query)

  • How to Create a new column from two different result sets

    How to Create a new column from two different result sets, both the result set uses the different date dimensions.

    i got solutions for this is apply filters in column formula it self, based on the requirement.

  • Hide or Remove OCI Check Box column from Standard MDM Result Set iview

    Hi,
    Can we hide or remove the OCI Check box column from the Standard MDM Result set ivew?
    Though i have made OCI disabled, I dont want to display the check boxes along with the product list.
    Can you please help?
    Thanks and best regards,
    Arun prabhu S

    Hi Arun,
    If you are talking about the very first check box, then that is not related to OCI. Use of check box is to anable multiple item selection which can be used adding the records in the workflow, for comparison etc.
    Regards,
    Jitesh Talreja

  • Adding hard coded column values to a result set.

    DB version:10gR2
    Example from sample schema SCOTT
    select e.ename, e.empno, d.loc
    from
    emp e inner join dept d on (e.deptno=d.deptno)
    and e.ename like 'M%';
    ENAME           EMPNO LOC
    MARTIN           7654 CHICAGO
    MILLER           7934 DALLAS
    For every ename like 'MARTIN' the following two rows (hardcoded column values 001-985 and 003-745 ) should get created.
    PAY_TYPES   PAY_CODES               
       001           985               
       003           745    
       Everything else must remain same.
    The result set should look like the following. Here two rows got created for MARTIN and MILLER.Everything else remains the same
      ENAME           EMPNO  PAY_TYPES   PAY_CODES               LOC
      MARTIN           7654  001           985               CHICAGO
      MARTIN        7654  003           745                       CHICAGO
      MILLER           7934  001           985                  DALLAS
      MILLER           7934  003           745                  DALLAS
      How is this possible?

    Hello Scott,
    Try this,
    SELECT ENAME, EMPNO, PAY_TYPES, PAY_CODES, LOC
      FROM (SELECT K.*, ROW_NUMBER() OVER(PARTITION BY ENAME ORDER BY ENAME) ID
              FROM (SELECT *
                      FROM (SELECT ENAME, EMPNO, LOC
                              FROM EMP E, DEPT D
                             WHERE E.DEPTNO = D.DEPTNO
                               AND ENAME LIKE 'M%')
                     WHERE CONNECT_BY_ISLEAF = 1
                    CONNECT BY LEVEL <= 2) K)
    MODEL
       DIMENSION BY (ENAME, ID)
       MEASURES ( EMPNO, LOC, '000' AS PAY_TYPES, '000' AS PAY_CODES )
       RULES    ( PAY_TYPES[FOR (ENAME) IN (SELECT ENAME FROM EMP WHERE ENAME LIKE 'M%' ),1] = '001' ,
                  PAY_CODES[FOR (ENAME) IN (SELECT ENAME FROM EMP WHERE ENAME LIKE 'M%' ),1] = '985' ,
                  PAY_TYPES[FOR (ENAME) IN (SELECT ENAME FROM EMP WHERE ENAME LIKE 'M%' ),2] = '003' ,
                  PAY_CODES[FOR (ENAME) IN (SELECT ENAME FROM EMP WHERE ENAME LIKE 'M%' ),2] = '745' )   Regards,
    Christian Balz

  • XML result set storage and stored procedures

    Hi,
    Is there an alternative way to store and process a large data result set from an XML document without using temporary tables in an Oracle DB? If so, how can this be implemented using stored procedures?
    Additional Info:
    I am planning to use a directory server as my data source and returning an XML document to the store procedure that executes a query to this server. I read somewhere that table variables can be used as an alternative, however it is not the desired option when you have large result sets due to potential performance issues. Any guidance you can provide would be appreciated. Thanks

    You could have a go with XML functions, but probably, because you mentioned "large data result set", you will have to deal with it programmatically. I have read once good examples in a book called "Building Oracle XML Applications" from Steve Muench (http://www.oreilly.com/catalog/orxmlapp/), but it is a little bit dated. Nevertheless a book from Steve is worth while.

  • I want to change the type of a Result Set

    Hello all,
    I was using a ResultSet object to store the results of a query, and when i attempted to use the ResultSet function "last()", i had a SQL exception saying that I cannot use this function on a ResultSet of type TYPE_FORWARD_ONLY. How can I change the type of a ResultSet to be for example TYPE_SCROLL_SENSITIVE, so that i can use the 'last()' function? I can only find a function caleed getType() but i want a function to allow me to set the type of the ResultSet.....
    Thanks a lot

    The type is determined when you create the Statement or PreparedStatement object. See the documention for Connection.createStatement or Connection.prepareStatement.

  • Row to column conversion in large result set

    I need to get the differnt levels of alerts for each user, with the total alert counts and counts for each type of alert.
    SELECT COUNT(*) TOTAL,
            u.name,
            d.deptname,
            COUNT(CASE WHEN al.severity = 5 THEN 1 END) INDETERMINATE,
            COUNT(CASE WHEN al.severity = 4 THEN 1 END) WARNING,
            COUNT(CASE WHEN al.severity = 3 THEN 1 END) MINOR,
            COUNT(CASE WHEN al.severity = 2 THEN 1 END) MAJOR,
            COUNT(CASE WHEN al.severity = 1 THEN 1 END) CRITICAL
    FROM alerts al, user u, dept d
    WHERE al.userid = u.userid
      AND u.deptid = d.deptid
      AND al.time = sysdate - 4/24
      AND al.time <= sysdate
    GROUP BY u.name, d.deptname  This might be inefficient especially when the amount of data is huge and potentially you could be looking at millions of rows in a given interval. So I was thinking of grouping by severity, which would eliminate the CASE statements, but then the problem on group by is that I get it as a rows instead of columns.
    Would anyone have a suggestion as to do it effeciently especially one that has millions of rows? Thanks.

    I guess eventually we are probably going to move towards that, but using a staright forward query is the immediate solution and any help on that would be great. Thanks.

  • How to use column name from subquery result set.

    I have these 2 tables
    SQL> select * from temp
      2  ;
    TABLE_NAME                     COLUMN_NAME                    TYPE
    lst                            name                           STATUS
    lst                            val
    SQL> select * from lst;
    TYPE                           NAME
      VAL
    STATUS                         Pending
      Pendiente
    STATUS                         Closed
      Cerrado
    STATUS                         ABC
      ABSI want to select column_name from temp table and generate select statements.
    select name from lst;
    select (select COLUMN_NAME from temp where rownum<2) from lst;
    SQL> select (select COLUMN_NAME from temp where rownum<2) from lst;
    (SELECTCOLUMN_NAMEFROMTEMPWHER
    name
    name
    nameoutput I expect is
    SQL> select name from lst;
    NAME
    Pending
    Closed
    ABC

    MichaelS wrote:
    Can I do it using SQLe.g.:)
    I was just about to post a similar approach (which should work from 10.2 and upwards) :
    SQL> SELECT value(x).getRootElement() col_name,
      2         extractvalue(value(x),'*') col_value
      3  FROM ( SELECT column_name, table_name
      4         FROM temp
      5         WHERE rownum = 1
      6       ) v
      7     , XMLTable(
      8        '/ROWSET/ROW/*'
      9        passing dbms_xmlgen.getXMLType('SELECT '||v.column_name||' FROM '||v.table_name)
    10       ) x
    11  ;
    COL_NAME        COL_VALUE
    NAME            Pending
    NAME            Closed
    NAME            ABC

  • ADF BC : "Attributes selected in query with no column type found! ..."

    hi
    Using JDeveloper 10.1.3.3.0, I have this "Selected in Query" attribute, "Never" updatable, in my Entity Object.
    The Entity Object is based on the SCOTT.EMP table and the attribute, called "BonusInfo", is defined using the expression " '[bonus info ' || (SAL * 2) || ']' ".
    see http://verveja.footsteps.be/~verveja/files/oracle/NoColumnTypeFoundApp-v0.01.zip
    While creating this Entity Object, I got a "Business Components" dialog that says:
    "Column type is not specified for this attribute. Specifying column-type and precision results in better query performance at runtime. Do you wish to set column type to VARCHAR2(255)?"
    I clicked "Yes".
    I also created two View Objects based on this Entity Object.
    In the "Create View Object" wizard "Step 4 of 7: Attribute Settings" I got a "Business Components" diaglog that says:
    "Attributes selected in query with no column type found! Specifying column-type and precision results in better query performance at runtime. Do you wish to set default column type for these attributes?"
    I clicked "Yes".
    Testing the query in "Step 5 of 7: SQL Statement" showed "Query is valid.".
    question:
    Why do I keep getting the message ...
    "Attributes selected in query with no column type found! Specifying column-type and precision results in better query performance at runtime. Do you wish to set default column type for these attributes?"
    ... in the View Object Editor if I click on different attributes?
    (I don't get such a message the first time I click on an attribute after opening the View Object Editor, but after that it keeps popping up each time I click on a different attribute, no matter what I answer "Yes", "No" or "Cancel".)
    many thanks
    Jan Vervecken

    Jan,
    BC needs the column type and precision so that we can allocate the correct JDBC buffer size; otherwise we would just allocate 2k per string.
    Blaise

  • Attributes selected in query with no column type found! (solved)

    Dear JHeadstart Team,
    In the view object Editor I have two entity based attributes attrib1 and attrib2
    both with type Number. Both have aliases with type number(9,0)
    If attrib1 is null I want to have the value of attrib2.
    In the expression box I put: nvl(attrib1,attrib2)
    When I press the ok button I get the next error message.
    "Attributes selected in query with no column type found!
    Specifying column-type and precision results in better query performance at runtime.
    Do you wish to set default column type for these attributes? "
    When I say ok I get the next message:
    "An error occurred. Unable to apply all the wizard changes.
    Column type cannot be changed for Entity based attribute.
    Exception: oracle.jbo.dt.objects.JboExeption."
    The details button serves no extra information.
    Since both the attributes have the same type I thought the nvl commando should work.
    But what does the "no column type found" sentence mean?
    regards,
    Marcel.
    Message was edited by:
    user571204

    Thanks Jan,
    You've put me on the right track.
    I found out that this is only possible in the entity object class.
    So I have to check my limited java skills.

  • How can I use a Lookup task to lookup from my SQL Result set and have a join

    So in my Control Flow, I have an Execute SQL Task which gets my Table result set. I then have a Foreach Loop Container that iterates through the result set and a Data Flow. The first task in the Data Flow is an OLE DB Source SQL Command that retrieves data
    columns associated with my result set. I then do a Derived Column so I can SUBSTRING from one of my data columns and now I want to perform a Lookup to my Application Database.
    How do I code my Lookup task to utilize my SQL Result set variable and match on it? I cannot use the GUI for the Lookup task as my Lookup has to have some JOINS in it.
    Thanks for your review and am hopeful for a reply.

    Can you expand on that? I'm sorry but I am new and a novice to the SSIS world and I want to do this as best I can and as efficiently as I can. Are you saying that Rajen's way suggested above is the way to go?
    A little background....external data from a 3rd party client. I'v staged that external data to a SQL Server staging table. I have to try and match that data up to our database using SSN, DOB, and Gender...and if I can't match that way then I have to try
    and match by Name. I need to make sure that there is only one and only one account for that match. If I cannot match and match one and only one, then I'll create rows on a DataAnomaly Table. If I do match, then I have to check and make sure that there is only
    one and only one Member span for that match. Similarly handle the data anomaly and then check and make sure there is a "Diabetes" claim and similarly handle the DataAnomaly accordingly.
    That's where I'm at. Sooooo are you saying to use Rajen's suggestion? I don't think I can do that because I need multiple SQL tasks and I cannot connect multiple OLE DB Source tasks.
    Any help and suggestions are greatly appreciated.
    Thanks.

  • Incorrect result set with using isnull() function  in IQ 16

    Hi team,
    We have IQ 16 on HP UX.
    When we use isnull() function in where clause we get incorrect result set if we do not use column name in the result set.
    In first select we get result with one row but in second one we get an empty result set.
    select ID, dat_start, dat_end, dat_stop
    from table_test
    where ID=1105935925
    and isnull(dat_stop,dat_start) <> dat_end
    select ID
    from table_test
    where ID=1105935925
    and isnull(dat_stop,dat_start) <> dat_end
    It depends on number of row or volume of data in table, It is possible to use option Revert_To_V15_Optimizer to get the correct result.
    Do you have any different idea how to solve it?
    Thanks Milos.

    We have tested two versions:
    Sybase IQ/16.0.0.653/131122/P/sp03/ITANIUM/HP-UXi 11.31/64bit/2013-11-22 01:49:18
    SAP IQ/16.0.0.807/140507/P/sp08/ITANIUM/HP-UXi 11.31/64bit/2014-05-07 21:11:45
    Both versions have given same mistake.
    We have not opened any support case for this issue because it is data depended issue. It is not easy to simulate it as an example.
    Do you think we should open a support case for it?
    Miloš

  • Access result set in user define type of table

    here is the situation. I have a stored procedure that dequeues messages of a AQ and passes them as an OUT parameter in a collection of a user defined type. The same type used to define the queues. The java code executes properly but seems like we don't/can't access the result set. We don't receive any erros but don't know how to access the results. I've included relevant parts of the problem.
    I know this should be doable but........Can someone please tell us what we are doing wrong....thanks in advance.
    -----create object type
    create type evt_ot as object(
    table_name varchar(40),
    table_data varchar(4000));
    ---create table of object types.
    create type msg_evt_table is table of evt_ot;
    ----create queue table with object type
    begin
    DBMS_AQADM.CREATE_QUEUE_TABLE (
    Queue_table => 'etlload.aq_qtt_text',
    Queue_payload_type => 'etlload.evt_ot');
    end;
    ---create queues.
    begin
    DBMS_AQADM.CREATE_QUEUE (
    Queue_name => 'etlload.aq_text_que',
    Queue_table => 'etlload.aq_qtt_text');
    end;
    Rem
    Rem Starting the queues and enable both enqueue and dequeue
    Rem
    EXECUTE DBMS_AQADM.START_QUEUE (Queue_name => 'etlload.aq_text_que');
    ----create procedure to dequeue an array and pass it OUT using msg_evt_table ---type collection.
    create or replace procedure test_aq_q (
    i_array_size in number ,
    o_array_size out number ,
    text1 out msg_evt_table) is
    begin
    DECLARE
    message_properties_array dbms_aq.message_properties_array_t :=
    dbms_aq.message_properties_array_t();
    msgid_array dbms_aq.msgid_array_t;
    dequeue_options dbms_aq.dequeue_options_t;
    message etlload.msg_evt_table;
    id pls_integer := 0;
    retval pls_integer := 0;
    total_retval pls_integer := 0;
    ctr number :=0;
    havedata boolean :=true;
    java_exp exception;
    no_messages exception;
    pragma EXCEPTION_INIT (java_exp, -24197);
    pragma exception_init (no_messages, -25228);
    BEGIN
    DBMS_OUTPUT.ENABLE (20000);
    dequeue_options.wait :=0;
    dequeue_options.correlation := 'event' ;
    id := i_array_size;
    -- Dequeue this message from AQ queue using DBMS_AQ package
    begin
    retval := dbms_aq.dequeue_array(
    queue_name => 'etlload.aq_text_que',
    dequeue_options => dequeue_options,
    array_size => id,
    message_properties_array => message_properties_array,
    payload_array => message,
    msgid_array => msgid_array);
    text1 := message;
    o_array_size := retval;
    EXCEPTION
    WHEN java_exp THEN
    dbms_output.put_line('exception information:');
    WHEN no_messages THEN
    havedata := false;
    o_array_size := 0;
    end;
    end;
    END;
    ----below is the java code....
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Struct;
    import oracle.jdbc.driver.OracleCallableStatement;
    import oracle.jdbc.driver.OracleTypes;
    public class TestOracleArray {
         private final String SQL = "{call etlload.test_aq_q(?,?,?)}";//array size, var name for return value, MessageEventTable
         private final String driverClass = "oracle.jdbc.driver.OracleDriver";
         private final String serverName = "OurServerName";
         private final String port = "1500";
         private final String sid = "OurSid";
         private final String userId = "OurUser";
         private final String pwd = "OurPwd";
         Connection conn = null;
         public static void main(String[] args){
              TestOracleArray toa = new TestOracleArray();
              try {
                   toa.go();
              } catch (InstantiationException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              } catch (IllegalAccessException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              } catch (ClassNotFoundException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              } catch (SQLException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
         private void go() throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException{
              Class.forName(driverClass).newInstance();
              String url = "jdbc:oracle:thin:@"+serverName+":"+port+":"+sid;
              conn = DriverManager.getConnection(url,userId,pwd);
              OracleCallableStatement stmt = (OracleCallableStatement)conn.prepareCall(SQL);
              //set 1 input
              stmt.setInt(1, 50);
              //register out 1
              stmt.registerOutParameter(2, OracleTypes.NUMERIC);
              //register out 2
              stmt.registerOutParameter(3, OracleTypes.ARRAY, "MSG_EVT_TABLE");
              * This code returns a non-null ResultSet but there is no data in the ResultSet
              * ResultSet rs = stmt.executeQuery();
              * rs.close();
              * Tried all sorts of combinations of getXXXX(1);
              * All return the same error Message: Invalid column index
              * So it appears that the execute statment returns no data.
              stmt.execute();
              Struct myObject = (Struct)stmt.getObject(1);
              stmt.close();
              conn.close();
    }

    Hi,
    Sorry but I'd refer you to the following sections (and code samples/snippets) in my book:
    Mapping User-Defined Object Types (AD) to oracle.sql.STRUCT in section 3.3, shows how to pass user defined types as IN, OUT,IN/OUT
    JMS over Streams/AQ in the Database: shows how to consume AQ
    message paylod in section 4.2.4
    CorporateOnine, in section 17.2, show how to exchanges user defined type objects b/w AQ and JMS
    All these will hopefully help you achieve what you are trying to do.
    Kuassi

  • Including HTML tags in Spry XML data sets

    How does one add HTML tags to Spry XML data sets so that the displayed items include that markup?
    For example, I might want to bold-face words within XML data items. I have tried adding the markup, but instead of seeing, for example:
    This is bold face
    in the Spry table, I see:
    This is <b>bold</b> face
    I have tried using CDATA elements in the XML to no avail.

    Set the data type for the column as per
    var ds1 = new Spry.Data.XMLDataSet("myData.xml", "rows/row");
    ds1.setColumnType("myColumn", "html");
    Gramps

Maybe you are looking for

  • GOODS TRANSPORT SERVICE TAX

    Hi the scenario is As per Notification No. 35/2004, in relation to the transport services, the onus of collection and payment of service tax has come to the recipient of the services unlike the provider of the services in other cases. Hence organizat

  • Reading/snooping through backed up files

    Hi all - I backed up my Blackberry using BB Desktop software to my Mac about two months ago.  I'm giving my Mac to a  family member, who is NOSY and I want to make sure they can't recover /snoop through my personal information (backed up texts, MMS's

  • Error Message on my L7590 related to missing or bad ink cartridges

    I opened the ink cartridge door to get the numbers off the back of the cartridges (need a new yellow).  You can't see the numbers so I didn't touch any thing and closed the door.  Now I am getting a message that my cyan and black cartridges "appear t

  • HH3 vers the Bt Bus hub HGV 2701v

    Hi All IS the HH3 holding back the speeds When the HH3 ver b is connected via infinity Download speed is 65mb with upload of 8.91 just tried my BT infinity HGV2701 v Got download speeds of 77.5 with upload of 17mb tried the speedteat.net tester few t

  • Cannot add my yahoo email account to my iphone5

    i cannot add my yahoo email account to my iphone5. I have been trying for many times and it keeps saying "Yahoo server is unavailable". I can access my email on my computer, and was also able to add another email account to my iphone5, but not the ya