tags of the query return data XML XML to lose

I have a recordset returned by SQL Server 2005 by using a stored procedure. One of the fields is XML. When I left this field in my cfm page, all the XML tags are gone. I don't know where they get lost or how to get back them. I need to process this XML using a XSLT stylesheet so that only part of the XML data is displayed. Any ideas? Thank you!

Oh! You're right - thank you! I thought that my XSLT was not working, but it was.

I changed the XSLT to display the data in HTML and it's all good. Thanks again!

Tags: ColdFusion

Similar Questions

  • Add a user in the system-jazn-"Data.xml" file

    I have an ADf application (developed in JDeveloper 10.1.3.3).
    It implements security using xml. (jazn.xml points to the system-jazn-"Data.xml")

    In the system-jazn-"Data.xml", I have entries like -
    -< user >
    < name > DataBase_User_OfYmnJXIxCAH90iuGKMkBoZmd5Sfm44M < / name >
    < guid > AA61EF7072F211DD8F62B3BA7CB157C2 < / guid >
    < powers {903} OfYmnJXIxCAH90iuGKMkBoZmd5Sfm44M > < / qualifications >
    < / user >

    no idea what are these entries and why they are here.

    Hello

    as it appears, it comes to forwarding password for a data source. In order to avoid the definitions of data source by clear text password, the defined data sources use an entry in the system-jazn-"Data.xml" where they are encrypted.

    Frank

  • Add a string when the query returns all records

    DB version: 11.2

    create table t (empname varchar2 (25), salary number, varchar2 (20) months, number of over_time);

    insert into values t ('JOHN', 2000, "NOVEMBER2014", 0);

    insert into values t ('KATE', 2000, "NOVEMBER2014", 300);

    insert into values t ('HANS', 5000, "NOVEMBER2014", 100);

    insert into values t ("KRISHNA", 2500, "NOVEMBER2014", 0);

    insert into values t ("SIEW", 3000, "NOVEMBER2014", 0);

    commit;

    SQL > select * from t;

    EMPNAME MONTHS SALARY OVER_TIME

    ------------------------- ---------- -------------------- ----------

    JOHN 2000 NOVEMBER2014 0

    KATE 2000 NOVEMBER2014 300

    HANS 5000 NOVEMBER2014 100

    KRISHNA 2500 NOVEMBER2014 0

    SIEW 3000 NOVEMBER2014 0

    SQL > select * from t where MONTH = 'NOVEMBER2014' and OVER_TIME! = 0 ;

    EMPNAME MONTHS SALARY OVER_TIME

    ------------------------- ---------- -------------------- ----------

    KATE 2000 NOVEMBER2014 300

    HANS 5000 NOVEMBER2014 100

    What I need is:

    If the query above returns at least one record, it should display the line ' Yes. We have one or more employees who worked overtime in November2014'

    before the documents are printed

    Thus, the expected production is

    Yes. We have one or more employees who worked overtime at the November2014

    EMPNAME MONTHS SALARY OVER_TIME

    ------------------------- ---------- -------------------- ----------

    KATE 2000 NOVEMBER2014 300

    HANS 5000 NOVEMBER2014 100

    If the query returns no records then usual 'no rows selected' isn't enough

    Lothar G.f. says:

    In fact, sql * more is no good tool for use considered.

    Really?  It may be a good reporting tool if you learn to use it as such...

    for example

    SQL > ttitle left 'Yes. We have one or more employees who worked overtime in November2014.
    SQL > select * from emp where empno = 1234;

    no selected line

    SQL > select * from emp where empno = 7788;

    Yes. We have one or more employees who worked overtime at the November2014
    EMPNO, ENAME, JOB HIREDATE DEPTNO COMM SAL MGR
    ---------- ---------- --------- ---------- -------------------- ---------- ---------- ----------
    7788, SCOTT, ANALYST, 7566 19 APRIL 1987 00:00:00 3000 20

    This is just a basic example.  It is possible to get SQL * more to ask for the required criteria and that the title could adjust according to this criterion, as well as the query building on it also.

    However, the OP did not specify SQL * as the reporting tool, so there is little interest providing a complete solution which, until they specify what user interface that they are actually using.

  • When the redeployment, jazn-"Data.xml" crushes users the App provides on Weblogic

    Hello world

    I use
    -JDeveloper 11.1.2.1.0
    -Weblogic 10.3.5

    I found that when I transferred a request, it seemed that whatever the roles that I have setup in the Console of Administration WebLogic for users who are not defined in the jazn of application data, gets crushed by the data from jazn-Application data

    for example
    I have an application with jazn-"Data.xml", defined as follows:
    -Creation of 4 users
    -Created the company 3 roles (role of customer, NormalRole, ReadOnlyRole)
    -Assigned 4 users to roles of business as a result
    -Given the workflow, Web Page and ADF entity as a result object

    If I configure the 5th, 6th, 7th and so on users through the Console of Administration WebLogic and grant them a role (i.e. NormalRole). As soon as I redeploy the application, all users (except 4 which are defined in the jazn-data application) seem to lose the delivered business role that I gave earlier in the Console of Administration WebLogic.

    It's not ideal because we always maintain user through the Console of Administration WebLogic (so we can add / remove / update user information at any time, rather than having to do it by changing jazn-Application data and do a redeployment). Is that what I was wrong? I tried excluding the jazn-"Data.xml" during deployment, but the application does not work. What should I do to prevent this?

    Thanks for any information.


    Kind regards
    Andi

    You are aware of the request-> Application-> deployment 'Deployment of Security Options' properties, particularly checkboxes to crush the security on the deployment objects?

    CM.

  • By using the query table data pump

    I am trying to perform an export of data pump on a table by using a query in a parfile and I'm getting a strange behavior. The database version is 10.2.0.4.3 and the AIX 5.3 operating system. The query looks like this.

    QUERY = "POSDECLARATIONQUEUE:where SESSIONID in (select"B.SESSIONID"from POSACCOUNT A, POSDECLARATIONQUEUE B, POSDECLARATIONSESSION C, where"B.SESSIONID"="C.ID"and"C.ACCOUNTID"= 'A.ID' and 'Inform' = '10252')" "

    This works, but gets 0 rows. If I run the query against the instance in a session of SQLPlus as below then I get 0 rows returned.

    Select * from POSDECLARATIONQUEUE where SESSIONID in (select "B.SESSIONID" from POSACCOUNT A, POSDECLARATIONQUEUE B, POSDECLARATIONSESSION C, where "B.SESSIONID" = "C.ID" AND "C.ACCOUNTID" = 'A.ID' and 'Inform' = '10252');

    If I take the columns all about apostrophes in the query on the Forum with SQLPlus, I get over 2000 rows returned.

    SQL > select count (*) in the POSDECLARATIONQUEUE where SESSIONID in (select B.SESSIONID from POSACCOUNT A, POSDECLARATIONQUEUE B, POSDECLARATIONSESSION C where B.SESSIONID = C.ID and C.ACCOUNTID = A.ID and inform = 10252);

    COUNT (*)
    ----------
    2098

    If I remove the apostrophes in the query parfile then I get the following error in data pump export.

    DEU-00014: invalid value for the parameter, "schemas".

    The PATTERNS option is not specified in parfile him and the TABLES option specifies that the table POSDECLARATIONQUEUE.

    Can someone help with this, I can't seem to be able to get the syntax just to work within data pump.

    Kind regards.
    Graeme.

    Published by: user12219844 on April 14, 2010 03:34

    It seems that your query can be a little wrong:

    That's what you have:

    QUERY = "POSDECLARATIONQUEUE:where SESSIONID in (select"B.SESSIONID"from POSACCOUNT A, POSDECLARATIONQUEUE B, POSDECLARATIONSESSION C, where"B.SESSIONID"="C.ID"and"C.ACCOUNTID"= 'A.ID' and 'Inform' = '10252')" "

    That's what I would have thought it should look like:

    QUERY = POSDECLARATIONQUEUE: "where SESSIONID in (select B.SESSIONID from POSACCOUNT A, POSDECLARATIONQUEUE B, POSDECLARATIONSESSION C where B.SESSIONID = C.ID and C.ACCOUNTID = A.ID and inform = 10252).

    You want to double "around the full query and you have not need single ' around all =." The single ' treat these values as strings and he said

    "B.SESSIONID" = "C.ID".
    the B.SESSIONID string is the string C.ID

    In your query you used in sql has been

    B.SESSIONID = C.ID

    that said, it is that the B.SESSIONID stored value equal to the value stored at C.ID

    Which is what you want.

    Dean

  • Select from another table, when the query returns no result

    Hello

    I have a question where I'm supposed to retrieve the address of an account id-based billing. However, the table of billing may not have an address. There is a table of addresses that always has an address for an account. If the billing address exists, it should be used, so I can't use the address table. Is it possible in a select statement to query to the billing address and if it does not exist, use the address table.

    SELECT * FROM accounts a, b billings WHERE a.accountid = b.accountid

    Any help will be greatly appreciated.

    Thank you.

    user10407139 wrote:
    Hello

    I have a question where I'm supposed to retrieve the address of an account id-based billing. However, the table of billing may not have an address. There is a table of addresses that always has an address for an account. If the billing address exists, it should be used, so I can't use the address table. Is it possible in a select statement to query to the billing address and if it does not exist, use the address table.

    SELECT * FROM accounts a, b billings WHERE a.accountid = b.accountid

    Any help will be greatly appreciated.

    I think you need to explain more clearly if

    -you only have a couple of "billing" columns which is empty and in this case, you want to use the columns from the table 'accounts '.

    - or you have a join with another table that doesn't return data, for example a foreign key "address_id" "billing" is zero and therefore the join to other tables 'address' will return all the data

    In the first case, you have already been provided with some examples here, how to use NVL or similar functions to achieve, even if the first post first evaluates the information of 'accounts' and if it is white using information from "billing". According to your description you need the other way around. The second post a subquery recursive useless in my opinion.

    In the latter case, you should probably use an "outer" join so that the data in your table "bills" are returned, even if the join to another table is not at all the lines.

    SELECT
    NVL(AD1.ADDRESS_ATTR1, AD2.ADDRESS_ATTR1) as ADDRESS_ATTR1,
    NVL(AD1.ADDRESS_ATTR2, AD2.ADDRESS_ATTR2) as ADDRESS_ATTR2,
    NVL(AD1.ADDRESS_STREET, AD2.ADDRESS_STREET) as ADDRESS_STREET,
    ...
    FROM accounts a
    INNER JOIN billings b
    ON a.accountid = b.accountid
    LEFT OUTER JOIN address ad1
    ON b.address_id = ad1.address_id
    INNER JOIN address ad2
    ON a.address_id = ad2.address_id;
    

    In this way you pick up the address stored in the "invoices" table, if it existed, otherwise you pick up the address assigned to the "accounts" table I used an inner for the second address join join because you said that the account always has an assigned address.

    Kind regards
    Randolf

    Oracle related blog stuff:
    http://Oracle-Randolf.blogspot.com/

    SQLTools ++ for Oracle (Open source Oracle GUI for Windows):
    http://www.sqltools-plusplus.org:7676 /.
    http://sourceforge.NET/projects/SQLT-pp/

  • sys_refcursor do not fetch any data, even if the query returns the value

    I use sys_refcursor to return the columns and aid below the procedure to do. Although the data are there in table_1 and table_2.

    PROCEDURE test_pro (abc_date N, DATE,
    cur_get_data ON sys_refcursor
    )

    OPEN cur_get_data
    for
    Select A.col1, B.col2
    from table_1 A
    where A.dis_date = abc_date
    left outer join
    table_2 B
    on
    A.dis_date = B.dis_date;

    IF cur_get_data % rowcount = 0
    then
    raise e_error;
    END if;

    EXCEPTION
    When e_error
    then
    -no_data_found;
    while others
    then
    -(giving an error with the SQL error code);

    END test_pro;


    When running under sql in the sql pl/sql developer window pick
    data
    Select A.col1, B.col2
    from table_1 A
    where A.dis_date = abc_date
    left outer join
    table_2 B
    on
    A.dis_date = B.dis_date;

    But while testing the test_pro in the test of the pl/sql Developer window, it is
    do not fetch all data and raise e_error every time

    is there a problem arising from the use IF cur_get_data % rowcount = 0 whenever that happens in the exception block.

    so can someone please put a few ideas what cud be the reason for this?
    PROCEDURE test_pro(abc_date IN DATE,
                       cur_get_data OUT sys_refcursor
                      ) is
    BEGIN
    
      OPEN cur_get_data for select A.col1,B.col2
                              from table_1 A
                             where A.dis_date = abc_date
                                   left outer join
                                   table_2 B
                                on A.dis_date = B.dis_date;
    
    /* while testing let exceptions just pop out
    EXCEPTION
    
      when no_data_found
      then
    ------no_data_found;
      when others
      then
    --------(giving SQL error with error code);
    */
    END test_pro;
    

    then you test as something like

    declare
    
      my_date   date := to_date('20120621','yyyymmdd');
      my_cursor sys_refcursor;
      col1      ... ;
      col2      ... ;
    
    begin
    
      test_pro(my_date,my_cursor);
    
      loop
    
        fetch my_cursor into col1,col2;
        exit when my_cursor%notfound;
        dbms_output.put_line(col1 || ' ~ ' || col2);
    
      end loop;
    
    end;
    

    Concerning

    Etbin

  • When the query returns no data, I get a strange behavior

    Hi all!

    I use jDev 11.1.2.1.0

    I've implemented a .jspx a read-only table with a query at the top. The user can press the 'new' button and a popup with an editable form appears in the order the user to insert a new record.
    The user can press "ok" in the dialog box and the record is validated, or press 'cancel' and the restore operation is executed. Which is more or less all the features of the form.

    I have the following problem.
    If I have a query in a way so that no record is returned (so read only table is empty) and press the 'new' button, the validation of the VO are enabled in the form (that is, all the required fields are red). If I press cancel, the restore operation is performed, but there is a blank line in the table ready only. The user does not see the postings at this time, neither the blank line. BTY, if I try to delete this empty line, I 25039-Houston: RowNotFoundException, which makes sense, since there is no current record should be deleted. On re - interview, he disappears.

    This problem occurs only when there is no trace at all in the table.

    I can't understand...
    Any suggestions? Any clue?

    Thank you very much
    ~ apostolos

    In the popupCanceledListener have you tried to do a PPR manually using (.addPartialTarget) AdfFacesContext.getCurrentInstance ()?

    Thank you
    TK

  • Problem with the query and date

    I'm trying to show only the specific results in my query based on the following:

    If the 'agreedate' is greater than today's date, less than 60 days, show it. Otherwise I don't want results.

    I always get the results of the last year and I don't know why.

    Here is my code:

    <!-the value date today less than 60 days. This works and shows the correct date->

    < cfset invitelimit = #now () # >
    < cfset invitelimit = #DateFormat (DateAdd (would be ', - 60, invitelimit), 'dd-mm-yyyy') #.

    <! - query items from the db and try to catch only to those with a more agreedate then the invitelimit date - >


    < name cfquery = "qinvite" datasource = "#Application.ds #" >

    SELECT DISTINCT * from team a

    INNER JOIN followed b ON a.id = b.team_id
    INNER JOIN termsagreement c ON a.login = c.login

    WHERE c.agreedate > #invitelimit # AND b.comp_id = 0

    Group By a.teamname

    < / cfquery >

    First of all.  Confirm that the "argeedate" column is a datetime column.  Not another type of data that would be much more difficult to work with.

    Secondly, you should provide an appropriate database datetime value.  The easiest way would be with the tag.

    I.E.

    WHERE

    c.agreedate > AND

    b.comp_id =

  • SYS_REFCURSOR: Variables of the game results or the query return types do not match

    Hello
    I have 2 snippets below, it codes marked 'Test 1' does not work, it gives the error message, see the code below. Why it gives an error? The second code succeeds and works according to the needs.

    Test1 in brief:
    Call proc P3
    Proc calls P3 P1

    Test 2 in brief:
    Call func P2,
    Proc calls P2 P1.

    ---


    1. test 1, it breaks down:
    create or replace procedure P1 ( i_name IN VARCHAR2, 
       o_cur          out   SYS_REFCURSOR )
    is
       v_cur          SYS_REFCURSOR;   
    begin
       open o_cur for
          select i_name from dual;
    end P1;
    /
    
    create or replace function P2 ( i_name IN VARCHAR2
    ) 
    return SYS_REFCURSOR
    is
       v_cur          SYS_REFCURSOR;   
    begin
       p1( i_name, v_cur); 
       return v_cur;
    end P2;
    /
    
    create or replace procedure P3 ( i_name IN VARCHAR2, 
       o_cur          out   SYS_REFCURSOR )
    is
       v_cur          SYS_REFCURSOR;   
    begin
       p1( i_name, o_cur);      
    end P3;
    /
    
    
    declare
       v_name         varchar2(100) := 'test1';
       v_cur          SYS_REFCURSOR;      
       v_fetch_var    varchar2(100);
    begin
       P3(v_name, v_cur);
       --v_cur := P2(v_name);
       
       if v_cur%ISOPEN then
          dbms_output.put_line('v_cur%ISOPEN=true');
       else
          dbms_output.put_line('v_cur%ISOPEN=false');
       end if;
       --
       loop
          fetch v_cur into v_fetch_var;
             exit when v_cur%notfound;
             dbms_output.put_line('v_fetch_var='||v_fetch_var);
       end loop;
    end;
    /*
    Output:
    v_cur%ISOPEN=true
    ORA-06504: PL/SQL: Return types of Result Set variables or query do not match
    ORA-06512: at line 16
    */
    2. test cycle 2, he succeeds:
    create or replace procedure P1 ( i_name IN VARCHAR2, 
       o_cur          out   SYS_REFCURSOR )
    is
       v_cur          SYS_REFCURSOR;   
    begin
       open o_cur for
          select i_name from dual;
    end P1;
    /
    
    create or replace function P2 ( i_name IN VARCHAR2
    ) 
    return SYS_REFCURSOR
    is
       v_cur          SYS_REFCURSOR;   
    begin
       p1( i_name, v_cur); 
       return v_cur;
    end P2;
    /
    
    create or replace procedure P3 ( i_name IN VARCHAR2, 
       o_cur          out   SYS_REFCURSOR )
    is
       v_cur          SYS_REFCURSOR;   
    begin
       p1( i_name, o_cur);      
    end P3;
    /
    
    
    declare
       v_name         varchar2(100) := 'test1';
       v_cur          SYS_REFCURSOR;      
       v_fetch_var    varchar2(100);
    begin
       --P3(v_name, v_cur);
       v_cur := P2(v_name);
       
       if v_cur%ISOPEN then
          dbms_output.put_line('v_cur%ISOPEN=true');
       else
          dbms_output.put_line('v_cur%ISOPEN=false');
       end if;
       --
       loop
          fetch v_cur into v_fetch_var;
             exit when v_cur%notfound;
             dbms_output.put_line('v_fetch_var='||v_fetch_var);
       end loop;
    end;
    /*
    Output:
    PROCEDURE P1 compiled
    FUNCTION P2 compiled
    PROCEDURE P3 compiled
    anonymous block completed
    v_cur%ISOPEN=true
    v_fetch_var=test1
    */
    Published by: CharlesRoos on February 8, 2010 05:06

    CharlesRoos wrote:

    Thenn should be documentation that says "recovery of the data type that sys_refcursor fails if you pass by reference too often."

    I can't really work on what your nested code is supposed to do, but in a simple example, this statement is false.

    SQL> create or replace procedure p1 (l_c out sys_refcursor)
      2  is
      3  begin
      4      open l_c for select dummy from dual;
      5  end;
      6  /
    
    Procedure created.
    
    SQL> create or replace procedure p2 (l_c out sys_refcursor)
      2  is
      3  begin
      4      p1 (l_c);
      5  end;
      6  /
    
    Procedure created.
    
    SQL> var c refcursor
    SQL> exec p2 (:c)
    
    PL/SQL procedure successfully completed.
    
    SQL> print c
    
    D
    -
    X
    
    SQL> create or replace procedure p3 (l_c out sys_refcursor)
      2  is
      3  begin
      4      p2 (l_c);
      5  end;
      6  /
    
    Procedure created.
    
    SQL> exec p3 (:c)
    
    PL/SQL procedure successfully completed.
    
    SQL> print c
    
    D
    -
    X
    
    SQL>
    

    However, I would say from a Ref Cursor once between PL/SQL procedures is already too.

    Re: Extract of the cursor variable

    And there is documentation saying that.

    http://download.Oracle.com/docs/CD/E11882_01/AppDev.112/e10472/static.htm#CIHCJBJJ

    Purpose of cursor Variables

    Variable cursor allows you to pass between PL/SQL stored subprograms and their clientssets of query results. This is possible because the PL/SQL and its clients share a pointer to the work area where the result set is stored.

  • Updated content item highlight when execute the query returns records to prevent

    Hello

    I use form 10g and I was wondering if it is possible to achieve the effect shows:

    The performance of a query for a block of data in data table, the content / the value of the first element in the first record returned is always highlighted. Is it possible to prevent this highlighting, and simply place the focus of the cursor on the 'start' of the field before the first character of the value of the element. Thanks in advance for any suggestions,

    Kind regards

    Kevin.

    Keep the position of the cursor to Yes Dungeon.
    Right after the call to the build-in execute_query try a synchronization;

  • Scope Descrepancy between the tag and the query script

    I'm fairly certain I've found a bug in scope. I use CF11 and FW/1 and I have the following query - the work of the tag, cfscript equivalent raises an exception "Table named rc.qSignerLinks is not found in the memory":

    / * Works * /.

    "< name ="cfquery local.qResultSet"result =" local.qResult "dbtype ="query">

    SELECT

    *

    Of

    rc.qRSRecipient

    where

    [email] = < cfqueryparam value = "#session.user.getEmail ()" # "cfsqltype ="CF_SQL_VARCHAR"maxlength ="50"/ >"

    < / cfquery >

    / * exception * /.

    < cfscript >

    local.qObj = new query();

    local.qObj.setDBType ("query");

    local.qObj.setSQL(")

    SELECT

    *

    Of

    rc.qRSRecipient

    where

    [email] =: email

    ");

    local.qObj.addParam (name = "email", value = "" #session.user.getEmail () # ", cfsqltype =" CF_SQL_VARCHAR", maxlength ="50");

    local.qObjResult = local.qObj.execute ();

    local.qResultSet = local.qObjResult.getResult () .recordCount NEQ 0;

    < / cfscript >

    Yes, Steve, this is a known issue for some years now. The usual solution is to add the result set using setAttributes(), like this:

    local.qObj.setAttributes(tbl = rc.qRSRecipient);

    local.qObj.setSQL ("SELECT * FROM tbl WHERE [email] =: email");

  • refine the query using dates

    Hello.

    I currently have a datablock, interviewed once brings a list of records. I'm looking to refine this list of records by declaring the from_date and to_date so that it retrieves only records = > from_date and < = to_date. the field that must be between these dates is the reg_date

    in my query before trigger I have:

    : car.reg_date: = * don't know what to put here *.

    any help on this would be great, thanks.

    Published by: user13390506 on 02-Sep-2010 07:10

    I suggest you explicitly cast values:

    Declare
      LC$Where  Varchar2(1000);
    Begin
      LC$Where := 'date between TO_DATE(''' || TO_CHAR(:blk.date_start, 'DD.MM.YYYY') || ''',''DD.MM.YYYY'') and TO_DATE(''' || TO_CHAR(:blk.date_end, 'DD.MM.YYYY') || ''',''DD.MM.YYYY'')' ;
      Set_Block_Property( 'BLK', DEFAULT_WHERE, LC$Where ) ;
      Go_Block ('BLK' ) ;
      Execute_query ;
    End;
    
  • reload the page when SQL query returns a value

    Hello world

    the title of this discussion may seem strange, but I'll try to explain why I need this:

    A user has the ability to connect on my APEX application. There are several tabs in my application that are visible only if a certain SQL statement returns a value which is not the case by default. The user has also the ability to download a file that is transferred to an external system that analyzes the file and writes the data in the database. During this writing process - which may take several minutes - conditions for some of the tabs to show the will becomes real (-> the query will return a value). When the user refreshes the page manually, the tabs will be displayed. However, I want the tabs will appear automatically when the condition is met.

    Is it possible to refresh the page as soon as the query returns a value? It is perhaps possible to check it on the client side and trigger a refresh of the page when the condition is met. It would be even better if only the tabset has been updated, but refreshing the full page is fine as well.

    Thank you!

    Here is an overview of how it can be done

    This is possible thanks to a dynamic action being performed on a timer.

    View default tabs and dynamic action hide them on loading the page if they are not to be considered

    Create a dynamic action that will execute your query every 5 seconds or more

    If the query returns data, you can use the dynamic action to show your tabs using javascript

  • XML query returns empty when tags no data

    Hi all

    I have a problem that I can't solve.

    I have the following query:
     select
                xmlelement
                (
                   "users",
                   xmlagg
                   (
                      xmlelement
                      (
                         "user",
                         xmlelement
                         (
                            "username",
                            e.pin
                         ),
                         xmlagg
                         (
                            xmlelement
                            (
                               "details",
                               xmlforest
                               (
                                  e.password as "password"
                                 ,e.first_name as "forename"
                                 ,e.surname as "surname"
                                 ,'0' as "retired"
                                 ,e.email_address as "email"
                                 ,e.telephone_number as "phone"
                                 ,'No External Ref' as "externalRef"
                                 ,add_months(sysdate,+60) as "expiryDate"
                               )
                            )
                         )
                      )
                   )
                ) xml_out
             from   aqaost_examiners e
             group by e.pin;
    The query returns the XML code in the desired structure.

    But the problem I have is that when there is no data found by the query, I always get a single row returned by the following: < user > < / users >

    I tried so many things to try to have the query return nothing if there is no data available, but I can't do without something else goes wrong (to mess up the XML structure, etc.).

    Please is - can anyone help or point me in the right direction?

    I thank very you much in advance!

    Robin

    Hello

    Peter,

    This is the GROUP that does this.

    Actually no, the GROUP BY refers to the deepest XMLAgg and is required if e.pin is not unique.

    Let it out, and you also seem to have of many XMLAGG (?)

    That's assuming that e.pin is unique within the table (which is probably a fair assumption in this case).

    In fact, the behavior comes from the XMLAgg in the foreground:

    SQL> select xmlelement("users",
      2           xmlagg(
      3             xmlelement("user",
      4               xmlelement("username", e.empno)
      5             , xmlelement("details",
      6                 xmlforest(
      7                   e.ename as "name"
      8                 , e.job as "job"
      9                 )
     10               )
     11             )
     12           )
     13         ) xml_out
     14  from scott.emp e
     15  where 1 = 0
     16  ;
    
    XML_OUT
    -------------------------------------
    
     
    

    As with other global functions (such as SUM or AVG) adding a GROUP OF 'something' solves the problem:

    SQL> select xmlelement("users",
      2           xmlagg(
      3             xmlelement("user",
      4               xmlelement("username", e.empno)
      5             , xmlelement("details",
      6                 xmlforest(
      7                   e.ename as "name"
      8                 , e.job as "job"
      9                 )
     10               )
     11             )
     12           )
     13         ) xml_out
     14  from scott.emp e
     15  where 1 = 0
     16  group by null
     17  ;
    
    no rows selected
    

    Robin,
    So the more intimate XMLAgg is really necessary, you can use a subquery:

    select xmlelement("users", v.users)
    from (
      select xmlagg(
               xmlelement("user",
                 xmlelement("username", e.empno)
               , xmlagg(
                   xmlelement("details",
                     xmlforest(
                       e.ename as "name"
                     , e.job as "job"
                     )
                   )
                 )
               )
             ) as users
      from scott.emp e
      group by e.empno
    ) v
    where v.users is not null
    ;
    

Maybe you are looking for

  • HP Pavilion 15-n057sr: AMD graphics card does not work on windows 10

    Hello! I have an AMD graphics card in my laptop, but there is no drivers for windows 10 forher. Installation driver Windows 8.1, latest drivers from amd or windows has always led to a screen of death, and after him, he appears each time you start. To

  • Front mounted at the rear of the cover Panel

    Hi all I dropped my iphone two days back. Thanks to my phone armor lid and screen in tempered glass protector, the damage did not on the phone. Operations are working perfectly. However, I noticed that the hinge of the façade are popping out of the g

  • HP OfficeJetPro 8600: How to scan from the desktop?

    I want to fax from the desktop.  A Word document.

  • Error-1967362041, DSC module, read the historical traces

    Hello. I'm reading some historical traces, but I get error-1967362041 and the message: HIST_ReadNumericTraceCORE.VI, \\hostname\library\Variable: IAK_SHARED: (Hex 0x8ABC7007) out of reach. This happens when using VI server to run my remote applicatio

  • I can't find the tab compatibility list!

    I can't run a Middle Earth 2 in the guide it says: right click for the game icon and then click Properties. In the Properties menu, click Compatibility tab.But in my computer, there is no compatibility tab. How can I do? EDIT: Sorry, I chose windows