XMLType extract help function

I have the example of XML structure below.
It has 2 child elements of type '< ns0:ItemMetaData >', has all first under element ' < ns0:ItemId > DSLGP603 < / ns0:ItemId > ' and second element sub "< ns0:ItemId > DSLGP603NY < / ns0:ItemId >.
But it is the only example of 2 parts in stock, there may be 10 these xml inside the chain elements.
How can I go/loop through all these elements '< ns0:ItemMetaData > '?
I think I need to change this part:
extract('//*'
But I have not managed to change.

--
select *
  from xmltable ('*/text()'
                 passing xmltype ('<ns0:FindItemMetaDataResponse xmlns:ns0="http://elion.ee/webservices/Sales/Dynamics">
  <ns0:ItemMetaData>
    <ns0:ItemMetaData>
      <ns0:ItemGroupId>IT.LS.VS.DSL</ns0:ItemGroupId>
      <ns0:ItemGroupName>IT lisad võrguseadmed DSL</ns0:ItemGroupName>
      <ns0:ItemId>DSLGP603</ns0:ItemId>
      <ns0:ItemName>ADSL SIP ST546</ns0:ItemName>
      <ns0:ItemType>Item</ns0:ItemType>
      <ns0:MacAddressMandatory>No</ns0:MacAddressMandatory>
      <ns0:SalesUnit>tk</ns0:SalesUnit>
      <ns0:SerialNumMandatory>No</ns0:SerialNumMandatory>
      <ns0:TaxValue>20.00</ns0:TaxValue>
    </ns0:ItemMetaData>
    <ns0:ItemMetaData>
      <ns0:CurrencyCode>EUR</ns0:CurrencyCode>
      <ns0:ItemGroupId>KL.PS.HGW</ns0:ItemGroupId>
      <ns0:ItemGroupName>Ruuterid</ns0:ItemGroupName>
      <ns0:ItemId>DSLGP603NY</ns0:ItemId>
      <ns0:ItemName>ADSL stardikomplekt Thomson ST546 stardi</ns0:ItemName>
      <ns0:ItemType>Item</ns0:ItemType>
      <ns0:MacAddressMandatory>No</ns0:MacAddressMandatory>
      <ns0:PriceWithoutVAT>12.78</ns0:PriceWithoutVAT>
      <ns0:PriceWithVAT>15.34</ns0:PriceWithVAT>
      <ns0:SalesUnit>tk</ns0:SalesUnit>
      <ns0:SerialNumMandatory>Yes</ns0:SerialNumMandatory>
      <ns0:TaxValue>20.00</ns0:TaxValue>
    </ns0:ItemMetaData>
  </ns0:ItemMetaData>
</ns0:FindItemMetaDataResponse>').extract('//*', 'xmlns="' || 'http://elion.ee/webservices/Sales/Dynamics' || '"')
                )
IT.LS.VS.DSL
IT lisad võrguseadmed DSL
DSLGP603
ADSL SIP ST546
Item
No
tk
No
20.00
EUR
KL.PS.HGW
Ruuterid
DSLGP603NY
ADSL stardikomplekt Thomson ST546 stardi
Item
No
12.78
15.34
tk
Yes
20.00
select * from v$version;

Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
PL/SQL Release 11.2.0.3.0 - Production
"CORE     11.2.0.3.0     Production"
TNS for Linux: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production

Should I then run the function "extract()" for each element node "" ItemMetaData"" sub I guess?

You can add other columns as you wish:

SQL> with sample_data (doc) as (
  2    select xmlparse(document
  3    '
  4    
  5      
  6        IT.LS.VS.DSL
  7        IT lisad võrguseadmed DSL
  8        DSLGP603
  9        ADSL SIP ST546
 10        Item
 11        No
 12        tk
 13        No
 14        20.00
 15      
 16      
 17        EUR
 18        KL.PS.HGW
 19        Ruuterid
 20        DSLGP603NY
 21        ADSL stardikomplekt Thomson ST546 stardi
 22        Item
 23        No
 24        12.78
 25        15.34
 26        tk
 27        Yes
 28        20.00
 29      
 30    
 31  ')
 32    from dual
 33  )
 34  select x.*
 35  from sample_data t
 36     , xmltable (
 37         xmlnamespaces(default 'http://elion.ee/webservices/Sales/Dynamics')
 38       , '/FindItemMetaDataResponse/ItemMetaData/ItemMetaData'
 39         passing t.doc
 40         columns item_id   varchar2(30) path 'ItemId'
 41               , item_name varchar2(80) path 'ItemName'
 42       ) x
 43  ;

ITEM_ID                        ITEM_NAME
------------------------------ --------------------------------------------------------------------------------
DSLGP603                       ADSL SIP ST546
DSLGP603NY                     ADSL stardikomplekt Thomson ST546 stardi
 

Tags: Database

Similar Questions

  • Extract all function extract all files at once - Win 8

    Recently, we bought a new laptop. She has Windows 8. Extract all functions does to extract all files found in the selected location. Only to choose the first or the last selected file. I have a crazy number of files to extract, and I can not just extract one by one. This feature allows to absolutely beautiful work in my old laptop... also on windows. Can someone pls help? I'm going nuts!

    I downloaded 7 - zip and it works (so far!  :)) Thanks!

  • Adobe Photoshop CS5.1 reinstalled because the help functions gives an error message (7).

    Hello

    When I tried to use the help function Adobe Prhotoshop CS5.1 a pop-up message shows errorcode (7) advise to reinstall the product. So I did, but it did not work. What can I do more? Mind you, the help in bridge function works as it should and the two products are installed at the same time.

    Kind regards

    AAD

    Thanks, I found a few topics on the error. I reinstalled and now it works.

    AAD

  • XMLType.extract cannot display French special characters in the select statement

    Hello
    E characters (acute e) get distorted when they are retrieved from the
    XMLType column of an ordinary table.

    How can we solve correctly get the characters e (acute e)?

    We tried setting 'setenv NLS_LANG French_France.WE8ISO8859P1' and
    "setenv NLS_LANG French_France.WE8DEC" before loading the table.

    Database version:
    SQL> select * from v$version;
    
    BANNER
    --------------------------------------------------------------------------------
    Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
    PL/SQL Release 11.2.0.2.0 - Production
    CORE    11.2.0.2.0      Production
    TNS for Linux: Version 11.2.0.2.0 - Production
    NLSRTL Version 11.2.0.2.0 - Production
    The test sample case is as follows:
    --connect to any schema where you can store XMLType
    set long 2000;
    set pagesize 2000;
    set serveroutput on;
    --delete from test;
    drop table test;
    create table test (id number, xmldata XMLType);
    
    
    declare
    featureDescriptorXML  CLOB;
    xml_type XMLType;
    new_xml_type XMLType;
    myName varchar2(100);
    myName2 varchar2(100);
    myName3 varchar2(100);
    stmt varchar2(4000);
    begin
     featureDescriptorXML :=
     '<?xml version="1.0" encoding="UTF-8"?>' ||
     '<abc:TheFeature xmlns:' || 'de' || '="' || 'http://abc.klmno.org/fghde' || '" xmlns:abc="http://www.ghijklmn.net/abc"' ||
     ' xmlns:xyz="http://www.ghijklmn.net/xyz">' ||
     '<abc:Name>de:MyGénérique</abc:Name>' ||
     '</abc:TheFeature>';
     xml_type := xmltype(featureDescriptorXML);
     myName := xml_type.extract('/abc:TheFeature/abc:Name/text()', 'xmlns:abc="http://www.ghijklmn.net/abc"').getStringVal();
     dbms_output.put_line('abc:Name value stored in VARCHAR2 variable from XMLType variable is ' || myName);
     -- can show French chars
    
     insert into test(id, xmldata) values(20, xml_type);
    
     stmt := 'select t.xmldata.extract(''/abc:TheFeature/abc:Name/text()'', ''xmlns:abc="http://www.ghijklmn.net/abc"'').getStringVal() from test t';
     execute immediate stmt into myName2;
     dbms_output.put_line('abc:Name value stored in VARCHAR2 variable from XMLType column in 2nd version is ' || myName2);
     -- cannot show French chars
    
    
     stmt := 'select  t.xmldata from test t';
     execute immediate stmt into new_xml_type;
     myName3 := new_xml_type.extract('/abc:TheFeature/abc:Name/text()', 'xmlns:abc="http://www.ghijklmn.net/abc"').getStringVal();
     dbms_output.put_line('abc:Name value stored in VARCHAR2 variable from first XMLType column and then from XMLType variable in 3rd version is ' || myName3);
     -- cannot show French chars
    
    end;
    /
    
    select t.xmldata.extract('/abc:TheFeature/abc:Name/text()', 'xmlns:abc="http://www.ghijklmn.net/abc"').getStringVal()
    from test t;
    -- Cannot show French chars
    
    
    select t.xmldata.extract('/abc:TheFeature/abc:Name/text()', 'xmlns:abc="http://www.ghijklmn.net/abc"').getStringVal() "myname"
    from test t;
    -- Cannot show French chars
    
    
    select t.xmldata.getCLOBVal() from test t;
    -- Cannot show French chars
    
    
    select t.xmldata from test t;
    -- Can show French chars
    Output is the following with setenv NLS_LANG French_France.WE8ISO8859P1
    and NLS_DATABASE_PARAMETERS are the following:
    SQL> select * from nls_database_parameters;
    
    PARAMETER                      VALUE
    ------------------------------ ----------------------------------------
    NLS_LANGUAGE                   AMERICAN
    NLS_TERRITORY                  AMERICA
    NLS_CURRENCY                   $
    NLS_ISO_CURRENCY               AMERICA
    NLS_NUMERIC_CHARACTERS         .,
    NLS_CHARACTERSET               WE8DEC
    NLS_CALENDAR                   GREGORIAN
    NLS_DATE_FORMAT                DD-MON-RR
    NLS_DATE_LANGUAGE              AMERICAN
    NLS_SORT                       BINARY
    NLS_TIME_FORMAT                HH.MI.SSXFF AM
    
    PARAMETER                      VALUE
    ------------------------------ ----------------------------------------
    NLS_TIMESTAMP_FORMAT           DD-MON-RR HH.MI.SSXFF AM
    NLS_TIME_TZ_FORMAT             HH.MI.SSXFF AM TZR
    NLS_TIMESTAMP_TZ_FORMAT        DD-MON-RR HH.MI.SSXFF AM TZR
    NLS_DUAL_CURRENCY              $
    NLS_COMP                       BINARY
    NLS_LENGTH_SEMANTICS           BYTE
    NLS_NCHAR_CONV_EXCP            FALSE
    NLS_NCHAR_CHARACTERSET         AL16UTF16
    NLS_RDBMS_VERSION              11.2.0.2.0
    
    20 ligne(s) sélectionnée(s).
    Table creé.
    
    abc:Name value stored in VARCHAR2 variable from XMLType variable is
    de:MyGénérique
    abc:Name value stored in VARCHAR2 variable from XMLType column in 2nd version is
    de:MyGénérique
    abc:Name value stored in VARCHAR2 variable from first XMLType column and then
    from XMLType variable in 3rd version is de:MyGénérique
    
    Procdure PL/SQL terminée avec succès.
    
    
    T.XMLDATA.EXTRACT('/ABC:THEFEATURE/ABC:NAME/TEXT()','XMLNS:ABC="HTTP://WWW.GHIJK
    --------------------------------------------------------------------------------
    de:MyGénérique
    
    
    myname
    --------------------------------------------------------------------------------
    de:MyGénérique
    
    
    T.XMLDATA.GETCLOBVAL()
    --------------------------------------------------------------------------------
    <?xml version="1.0" encoding="DEC-MCS"?>
    <abc:TheFeature xmlns:de="http://abc.klmno.org/fghde" xmlns:abc="http://www.ghij
    klmn.net/abc" xmlns:xyz="http://www.ghijklmn.net/xyz">
      <abc:Name>de:MyGénérique</abc:Name>
    </abc:TheFeature>
    
    
    
    XMLDATA
    --------------------------------------------------------------------------------
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <abc:TheFeature xmlns:de="http://abc.klmno.org/fghde" xmlns:abc="http://www.ghij
    klmn.net/abc" xmlns:xyz="http://www.ghijklmn.net/xyz">
      <abc:Name>de:MyGénérique</abc:Name>
    </abc:TheFeature>
    We also tried affecting NLS_CHARACTERSET AL32UTF8
    by CHARACTER SET of ALTER DATABASE.
    the database is closed and restarted.
    But that did not help.

    Thank you

    Ok. Wasn't sure. Thank you for that clarification.

    .. .but please make an attempt with XMLTABLE XMLQUERY, XMLCAST (or CAST) and other XML functions that support XQuery and not to use the engine of 'old '... I hope that these features will keep things as it should...

    .. .If not... create an SR with support of Oracle on this issue. Changes, if you base your SR on these 'old' operators XML/SQL and functions that are her will not be able to help, mainly due to the fact that your last version and stuff like EXTRACT / getStringVal() etc. are announced officially discouraged in this 11.2.0.2.0 version. As far as I know the t.xmldata.extract, the xml_type.extract and the other syntaxes, outlaw count of 10.1 (although I know, he appealed to java / OO people kind).

    Published by: Marco Gralike April 5, 2011 19:50

  • XMLTYPE extract some nodes

    Hello
    < book >
    < book >
    < id > 12 / < ID >
    Oracle < name > < / name >
    < / book >
    < book >
    < id > 15 / < ID >
    < name > net < / name >
    < / book >
    < / books >

    Please how can I retrieve the node containing the oracle book without the order of the element, in 10 g and 11 g

    I mean that the result should be

    < book >
    < id > 12 / < ID >
    Oracle < name > < / name >
    < / book >

    Thanks in advance

    How about using the EXTRACT with following XPath function? :
    book/books / [name = 'oracle']

    The whole sample test case:
    ------------------------------------------------------------
    CREATE TABLE testtab)
    ID NUMBER PRIMARY KEY,
    XML XMLTYPE
    );
    INSERT INTO testtab VALUES (1, XMLTYPE ('))

    12
    Oracle


    15
    NET

    '));
    COMMIT;

    SELECT EXTRACT (xml, '/ books/book [name = "oracle"]') FROM testtab;
    ------------------------------------------------------------

  • XMLType.extract: result of split

    Hello

    I use this function of the soap_api.sql for web services.
    FUNCTION get_return_value(p_response   IN OUT NOCOPY  t_response,
                              p_name       IN             VARCHAR2,
                              p_namespace  IN             VARCHAR2)
      RETURN VARCHAR2 AS
    -- ---------------------------------------------------------------------
    BEGIN
    
            RETURN p_response.doc.extract('//'||p_name||'/child::text()',p_namespace).getstringval();
    
    END;
    The problem is that it returns a large number of values, and they are all concatenated to the return value. Is there a way to divide all values with a separator or something?

    For example. It returns "TexasLos AngelesChicagoPhoenix" and I would like something like "Texas; Los Angeles; Chicago; Phoenix»

    I am using Oracle 11g

    Thank you

    Hello

    You can use the XMLQuery function and string-join (XPath 2.0).

    For example:

    SQL> DECLARE
      2
      3   xmldoc xmltype := xmltype(
      4  '
      5  Texas
      6  Los Angeles
      7  Chicago
      8  Phoenix
      9  '
     10  );
     11
     12   p_name      VARCHAR2(30) := 'city';
     13   p_namespace VARCHAR2(100) := 'test';
     14
     15   v_result    VARCHAR2(100);
     16
     17  BEGIN
     18
     19   select xmlcast(
     20    xmlquery(
     21     ( 'declare default element namespace "'||p_namespace||'"; (::)
     22       string-join(//'||p_name||'/child::text(),";")' )
     23     passing xmldoc
     24     returning content
     25    )
     26    as varchar2(100)
     27   ) into v_result
     28   from dual;
     29
     30   dbms_output.put_line(v_result);
     31
     32  END;
     33  /
    
    Texas;Los Angeles;Chicago;Phoenix
    
    PL/SQL procedure successfully completed
     
    

    It works well on 11.2, not sure about 11.1.

    Another way, by blocking the part extracted outside XQuery.
    Perhaps it fits better into your actual design:

    SQL> DECLARE
      2
      3   xmldoc xmltype := xmltype(
      4  '
      5  Texas
      6  Los Angeles
      7  Chicago
      8  Phoenix
      9  '
     10  );
     11
     12   p_name      VARCHAR2(30) := 'city';
     13   p_namespace VARCHAR2(100) := 'xmlns="test"';
     14
     15   v_result    VARCHAR2(100);
     16
     17  BEGIN
     18
     19   select xmlcast(
     20    xmlquery(
     21     'string-join(//text(),";")'
     22     passing extract(xmldoc, '//'||p_name, p_namespace)
     23     returning content
     24    )
     25    as varchar2(100)
     26   ) into v_result
     27   from dual;
     28
     29   dbms_output.put_line(v_result);
     30
     31  END;
     32  /
    
    Texas;Los Angeles;Chicago;Phoenix
    
    PL/SQL procedure successfully completed
     
    
  • How to implement a callback to the help function call library function node in LabView?

    I try to call a fuction from a SDK.dll library by using the node call library feature. The SDK has been provided to

    me and I don't have the source code, just the .dll and .h files.

    The SdkSetPropertyEventHandler function has a function of recall as one of its parameters. How to apply the

    callback using the NSI node? I'm a good programmer LabView but this is my first time using the library to call

    Function node. I read all the info I can find on the web site of NOR and the discussion Forum, but can not understand

    This one out. I'm using LabView 8.6.

    The deacribes SDK.h function as:

    Function: SdkSetPropertyEventHandler

    (SdkSetPropertyEventHandler) SdkError SDKAPI
    SdkCameraRef inCameraRef,
    SdkPropertyEvent inEvnet,
    SdkPropertyEventHandler inPropertyEventHandler,
    SdkVoid * context);

    //
    Description:
    Registers a callback function to receive the status
    change the notification events for the States of property on a camera.
    //
    Parameters:
    In: inCameraRef - designate the object camera.
    inEvent - designated one or all the events will be completed.
    inPropertyEventHandler - designate the pointer to the callback
    function to receive the camera property-related events.
    inContext - designated application information must be passed
    way to the callback function. All the data necessary to
    your application can be passed.
    Output: no
    //
    Returns: A sdk errors.
    -----------------------------------------------------------------------------*/

    A separate header called SDKTypes.h file contains the following data:

    typedef SdkUInt32 SdkPropertyEvent;
    typedef SdkUInt32 SdkPropertyID;
    typedef void SdkVoid;

    typedef struct __SdkObject * SdkBaseRef;
    typedef SdkBaseRef SdkCameraRef;

    /*-----------------------------------------------------------------------------
    SdkPropertyEventHandler
    -----------------------------------------------------------------------------*/
    typedef SdkError (SDKCALLBACK * SdkPropertyEventHandler))
    SdkPropertyEvent inEvent,
    SdkPropertyID inPropertyID,
    SdkUInt32 inParam,
    SdkVoid * context);

    Thanks for your help.
    Alejandro

    Andrew_E wrote:

    Hi Rolfk,

    You are absolutely right. This article describes what you were talking about? I'm just trying to get as much information as possible on this thread if the solution is easier to find for the future. Thank you.

    Yes, but I find the idea of using .net to call a LabVIEW VI as callback function C a bit as using a roll of Steam ironing your pants. Why do it? Well the steamroller has extra security guards that make it less likely that you'll break your pants in the process, but it's not elegant IMHO.

    Write a C DLL that translates between a C callback and a user event LabVIEW using the PostLVUserEvent() of the interface of the kernel to run LabVIEW function seems so eleganter for me. Yes, it's a bit of programming in C, but good!

    Rolf Kalbermatter

  • HELP function - new VI doesn't seem to work in built Application

    My Application is designed to coordinate several separate test (16) of control stations. Test stations can operate independently. I have a Test Manager application that starts the execution independently Test Runner live when the user has selected a test to be performed and the conditions to run with. There may be 0 to 16 Test Runner screws running at any given time. Each Test Runner VI uses the same model code of Test Runner.VI but is given a unique name based on a randomly generated GUID. I use a sequence of the function again, VI, VI. FP. Open and VI. Run VI to create the VI based on the template, give it a unique name and then launch it to run independently. Fragment JPG see attached.

    This design works perfectly well when it is used in the LabView 2010 development environment. But it does not work when I build the Test Manager as an EXE application. There is no errors generated, but the new VI is not launched, and I think that one of the functions of the sequence never returns. I don't know if the new VI is created or not.

    Does anyone know how to change this option so that the screws news can be created, unique, named and launched, it will work properly, regardless of if the creation VI runs either development (for debugging) or as a built application?

    Because of the sequence of the new VI, VI. FP. Open and VI. Pass the VI when used in a built application? Is there another method that will strive to meet this need?

    Is there a function in LabView that will launch an exe as WinExec done? Maybe I can use it.

    Thank you VERY MUCH for any advice.

    'New VI' is scripting.  It is blue. Scripting is explicitly not accessible at run time.

    what you want is 'Open VI référence' on a VI that is configured for the execution of reentry, with appropriate options defined in the properties of the VI and wired at the entrance to the REF VI open node Options (you want to 0x08 to returning with placeholders for data).  You can use a .lives, but this is not what they are for.

    Take the time to read the help file for reference VI open, it'll be worth it.

    other comments:

    Use the method fp.open, not property.

    "Auto has Ref" = true acts more like a standard VI call: LV will automatically close the ref when the called VI is idle.

  • Help function LabelField

    Hello

    I use many LabelField controls in the project do not wish to repeat the same code & would like help in creating a reusable function.

    Example:

    Import net.rim.blackberry.api.phone.Phone;

    LabelField lfOwner = new LabelField ("owner:" + OwnerInfo.getOwnerName (), DrawStyle.LEFT)
    {
    public void paint (Graphics g)
    {
    g.setColor (Color.DARKGREEN);
    g.setBackgroundColor (Color.WHITE);
    Super.Paint (g);
    }
    };

    LabelField lfOwnerInfo = new LabelField ("owner:" + OwnerInfo.getOwnerInformation (), DrawStyle.LEFT)
    {
    public void paint (Graphics g)
    {
    g.setColor (Color.DARKGREEN);
    g.setBackgroundColor (Color.WHITE);
    Super.Paint (g);
    }
    };

    As you can see, the two are LabelFields with graphics by placing of the same color. It makes no repeat the code point and would be better to be able to pass information to a function to set the color for label... Creating a class using a variable public to access the info above which is converted into a string before being passed to the LabelField control. Each LabelField will be in the same format:

    LabelName (sText + ":" + sText2, DrawStyle.LEFT);

    or

    MyLabelName ("owner", PhonesOwner(), DrawStyle.LEFT);

    producing a

    Owner: [name of the owner of some here]

    Following label:

    The owner Info: [info from the owner here]

    and so on

    That's what I wrote, but doesn't seem to work:

    ' Public Sub SetGreenLabel (field field, String sLabelText, String sFunctionName)
    {
    field = new LabelField (sLabelText + ":" + sFunctionName, DrawStyle.LEFT)
    {
    public void paint (Graphics g)
    {
    g.setColor (Color.DARKGREEN);
    g.setBackgroundColor (Color.WHITE);
    Super.Paint (g);
    }
    };
    };

    May extend to pass the ForeColor as parameter

    ' Public Sub SetLabelColour (String sLabelText, String sFunctionName, PlayStations color field, field)
    {
    field = new LabelField (sLabelText + ":" + sFunctionName, DrawStyle.LEFT)
    {
    public void paint (Graphics g)
    {
    g.setColor (cColour);
    g.setBackgroundColor (Color.WHITE);
    Super.Paint (g);
    }
    };
    };

    Perhaps an overload of the function as follows:

    SetLabelColour (String sText, String sText2)

    SetLabelColour (String sText2, String sText, color cForeColour)

    SetLabelColour (String sText2, String sText, cBackColour color, color cForeColour)

    My public variable

    MyClass mc = new MyClass();

    Label

    LabelField lf1;

    MC. SetLabelColour (lf1, 'Owner', PhonesOwner());

    Any ideas on how to write the correct functions?

    Thanks in advance

    Sure. Here is a more elaborate version of the idea of the subclass that has multiple constructors, commented to indicate what is happening. I have also set the colours.

    public class ColorLabelField extend LabelField {    /** Foreground color */    private int fg;
    
        /** Background color */    private int bg;
    
        /**     * Construct a ColorLabelField with empty text, default     * colors of dark green foreround and white background,     * and default style as determined by LabelField.     */    public ColorLabelField() {        this("", Color.DARKGREEN, Color.WHITE);    }
    
        /**     * Construct a ColorLabelField with indicated initial text,     * foreground and background colors, and default style.     * @param text the initial text     * @param fg the foreground color for the text     * @param bg the background color for the text     */    public ColorLabelField(String text, int fg, int bg) {        super(text);        this.fg = fg;        this.bg = bg;    }
    
        /**     * Construct a ColorLabelField with indicated initial text,     * foreground and background colors, and style.     * @param text the initial text     * @param fg the foreground color for the text     * @param bg the background color for the text     * @param style the style for the field     */    public ColorLabelField(String text, int fg, int bg, long style) {        super(text, style);        this.fg = fg;        this.bg = bg;    }
    
        /* No Javadoc comment. Just because. :) */    public void paint(Graphics g) {
            g.setColor(fg);
            g.setBackgroundColor(bg);
            super.paint(g);
        }
    }
    

    If you wish, you can add accessor functions to set the foreground and background colors after the ColorLabelField was built. As written, once you create them, the colors are immutable. (As far as the style of any field bits are immutable). If you add these accessor functions, you should consider if disabled then automatically the field when colors are changed or if it must remain until the client code to invalidate after everything he's done.

  • XMLType.extract changes data?

    declare

    l_xml xmltype.

    l_xml2 xmltype.

    Start

    l_xml: = xmltype.createxml (xmlData = > bfilename ('XMLDIR2', 'demo.xml'),)

    CSID = > 0,

    schema = > null);

    l_xml2: = l_xml.extract('/UNIVERSITY/PKU/DEP/ART');

    dbms_output.put_line (l_xml. GETSTRINGVAL);

    l_xml2: = l_xml.extract('/UNIVERSITY/PKU/DEP/ART');

    dbms_output.put_line (l_xml. GETSTRINGVAL);

    end;

    the outputs are

    UNIVERSITY <>

    < PKU >

    < num DEP = "3" >

    < ART / >

    < AUTO / >

    < CHEMICAL / >

    < / DEP >

    < / ECP >

    < TSINGHUA >

    < DEP num = "2" >

    < BUILDING / >

    < AUTO / >

    < / DEP >

    < / TSINGHUA >

    < PKU >

    < num DEP = "3" >

    < ART / >

    < AUTO / >

    < CHEMICAL / >

    < / DEP >

    < / ECP >

    < TSINGHUA >

    < DEP num = "2" >

    < BUILDING / >

    < AUTO / >

    < / DEP >

    < / TSINGHUA >

    < / UNIVERSITY >

    UNIVERSITY <>

    < PKU >

    < num DEP = "3" >

    < ART / >

    < AUTO / >

    < CHEMICAL / >

    < / DEP >

    < / ECP >

    < TSINGHUA >

    < DEP num = "2" >

    < BUILDING / >

    < AUTO / >

    < / DEP >

    < / TSINGHUA >

    < PKU >

    < num DEP = "3" >

    < ART / >

    < AUTO / >

    < CHEMICAL / >

    < / DEP >

    < / ECP >

    < TSINGHUA >

    < DEP num = "2" >

    < BUILDING / >

    < AUTO / >

    < / DEP >

    < / TSINGHUA >

    < PKU >

    < num DEP = "3" >

    < ART / >

    < AUTO / >

    < CHEMICAL / >

    < / DEP >

    < / ECP >

    < TSINGHUA >

    < DEP num = "2" >

    < BUILDING / >

    < AUTO / >

    < / DEP >

    < / TSINGHUA >

    < / UNIVERSITY >

    Cat demo.xml

    UNIVERSITY <>

    < PKU >

    < num DEP = "3" >

    < ART / >

    < AUTO / >

    < CHEMICAL / >

    < / DEP >

    < / ECP >

    < TSINGHUA >

    < DEP num = "2" >

    < BUILDING / >

    < AUTO / >

    < / DEP >

    < / TSINGHUA >

    < / UNIVERSITY >

    It seems l_xml changed every time an excerpt is called, why? Thank you very much!!!

    Hello

    I have the same problem on this version:

    BANNER

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

    Oracle Database 11 g Enterprise Edition Release 11.2.0.1.0 - 64 bit Production

    PL/SQL Release 11.2.0.1.0 - Production

    CORE 11.2.0.1.0 Production

    AMT for 64-bit Windows: Version 11.2.0.1.0 - Production

    NLSRTL Version 11.2.0.1.0 - Production

    5 selected lines.

    The problem seems to use createxml and getstringval:

    declare
    
      l_xml   xmltype;
      l_xml2  xmltype;
    
    begin
    
      l_xml  := xmltype.createxml(xmlData => bfilename('XMLDIR2', 'demo.xml'),
                                  csid    => 0,
                                  schema  => null);
    
      dbms_output.put_line('Run 1 (getstringval):');
      dbms_output.put_line(l_xml.getstringval);
      dbms_output.put_line('Run 2 (getstringval):');
      dbms_output.put_line(l_xml.getstringval);
      dbms_output.put_line('Run 3 (getstringval):');
      dbms_output.put_line(l_xml.getstringval);
    
    end;
    /
    

    Here is the result:

    Race 1 (getstringval):

    Race 2 (getstringval):

    Race 3 (getstringval):

    Replace getstringval with getclobval seems to fix the problem.

    By creating the xml as literal does not show the same problem.

    Probably a bug on this version.

    Kind regards.

    Alberto

  • XMLType extract query

    Hello:

    How to change the following query to get only the element with a given person_id? Actually, I have a CLOB containing an XML document. I thought that step 1 is to create a view, or something that casts of this column to an XMLType object, so I do that in the data of test here as well. If I do not need to do, it makes it very well.
    with base as ( -- Base XML
        select '<?xml version="1.0" encoding="UTF-8"?>
        <person_record_set>
        <person>
        <lname>Doe</lname>
        <fname>John</fname>
        <person_id>12345</person_id>
        </person>
        <person>
        <lname>Smith</lname>
        <fname>John</fname>
        <person_id>54321</person_id>
        </person>
        <person>
        <lname>Jones</lname>
        <fname>Mary</fname>
        <person_id>33333</person_id>
        </person>
        </person_record_set>' bdata
    from dual
    ),
    Q1 as ( -- We want it as an XMLType
    select xmltype(bdata) xtdata 
    from base)
    -- End of test data setup
    select '<rows>' || extract(xtdata,'//person') || '</rows>' from Q1
    Thank you

    You can use conditions on the xpath:

    with q1 as (select xmltype('
        
        
        Doe
        John
        12345
        
        
        Smith
        John
        54321
        
        
        Jones
        Mary
        33333
        
        ') xtdata from dual)
    -- End of test data setup
    select '' || extract(xtdata,'//person[person_id=12345]') || '' from Q1
    

    I don't like particularly the addition of '', though; that's what you do with this data? There are probably better ways to do this.

    Published by: Boneist on May 16, 2012 14:55

  • A parameter of xmltype extraction problem

    Hello
    I am using oracle 11g and I am trying to use an xmltype as input to an SP parameter, here's my SP:

    create or replace PROCEDURE ABC
    (FE_Param OF XMLType)
    AS
    BEGIN
    I'm IN
    (
    SELECT XMLTYPE. EXTRACT (VALUE (a),
    ' Root/FE_ID/text()').getstringval (LIKE FE_ID)
    TABLE
    (XMLSEQUENCE (FE_Param.EXTRACT
    ("/ FEData/Root")
    ) ) a )

    LOOP
    INSERT INTO table1
    VALUES (i.FE_ID);
    END LOOP;

    The XML parameter looks like this:
    <? XML version = "1.0" encoding = "utf - 8"? >
    < FEData >
    < root > < FE_ID > 900000031 < / FE_ID >
    < FE_ID > 900000032 < / FE_ID > < FE_ID > 900000050 < / FE_ID > < / root > < / FEData >

    Triple post - what's happened? :-)

    Published by: Kim Berg Hansen on August 22, 2011 16:47

  • Decode the help function

    Hello

    I'm new to the development of Oracle.

    MY requirement:

    I need to fill a column "ISMSG" by YES / NO based on the following condition

    When the code = the of ' or 'O'... the 'ISMSG' column should display any other YES no.

    That is, output should be like

    CODE ISMSG

    A NO
    S YES
    S YES
    O YES

    My code for the Decode function:

    CASE
    WHEN s = c.code ' THEN decode (c.code, the of ',' YES, 'NO')
    WHEN c.code = 'o' THEN decode (c.code, 'O', 'YES', 'NO')
    END ISMSG

    My code is correct? If Yes is the best way to do it?
    If this is not the case, correct the code.

    Is there an effective way to do it?

    Thanks in advance.

    Hello

    You can use CASES or DECODE for this; There is no need to use both.
    With the help of CASE:

    SELECT  c.code
    ,     CASE
             WHEN  c.code  IN  ('S', '0')  THEN  'YES'
                                               ELSE  'NO'
         END     AS ismsg
    FROM    table_x   c;
    

    Using DECODE:

    SELECT  c.code
    ,     DECODE ( c.code
                , 'S'      , 'YES'
                , '0'      , 'YES'
                              'NO'
                )          AS ismsg
    FROM    table_x   c;
    

    I suggest that you forget to DECODE and use always the CASE, at least while you are beginner.

    CASE may do everything they can to DECODE. There is a little bit simple, situations where DECODE is a little shorter than the CASE and therefore a bit clearer, but only a little and, as I said, these are just simple situations, and CASE is clear enough in them.
    DECODE is never much shorter or clearer than the CASE. The reverse is not true: there are many situations where the CASE is much, much shorter and lighter than DECODE.

  • Consolidation Help function

    Good,

    I know there must be an easier way to write this.
    Can someone tell me please in the right direction?

    There must be a way to use 1 function and a certain type of variable to add the new sprites to a table with a statement. I don't know how. Any help would be greatly appreciated.

    Thank you

    Wayne

    you have a typo in: the service should be services. and you don't need all that stuff on the sprites.

    and the flash needs help compiler, realize that your display objects are movieclips:

  • Help function Win32 API GetPrinter

    I use the WInspool.drv to determine the status of the printer.

    Using this DLL, I try to run the GetPrinter function.

    When I run the function, it returns an error.

    Can someone tell me what I am doing wrong?

    My separate functions to get the default printer, open and close the printer works successfully.


Maybe you are looking for

  • With the help of laptop recovery

    I have a Pavilion laptop G7. It came with a recovery on the hard drive partition as well as instructions on how to create a recovery media. Just two questions: (1) other that using different steps, is there a difference between the use of the partiti

  • Satellite P300 - cracks around screen

    Hello I have a P300 with 17.1 "display.The plastic around the screen is cracked (the screen is fine).Is it possible to replace this part?Where would I be able to get it? Thank you

  • Is the iPad 2 a 3G or lte at all?

    Is the iPad 2 a 3G or lte at all?

  • After installing SP3, computer caught in reboot loop

    I am able to download and install SP3, but when I restart my computer, it get stuck in a loop, windows does not 'normally' and when I choose Safe mode, it recognizes that sp3 is installed. Help, please... I had to restore my computer to an earlier ti

  • Archiving old videotapes with Windows Media Player

    I've got about 200-250 tapes at the time CD. I am running Windows XP Home Edition service pack 3 and Windows Media Player 11. I want to scan my old collection of tapes, rather than payagain for a bunch of songs that I already have. I have all the cor