How to retrieve characters like '£' from the database and write to xml file

Hi ,
I have a requirement to retrieve the data from database and write to files in XML format.
I am able to do so successfuly by using XMLElement tag and writing to file through UTL_File package.
All characters like <&@^ get converted properly, but when it comes to multibyte chars like '£', they are not able to get converted as it is.
Can somebody please advise me how to go ahead.
Regards

Thanks odie.
The nls_charset for my database is WE8ISO8859P1 and database version is Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bi.
The data (with pound sign) is sitting in one of the columns of the table and when i query it directly, I am able to view it properly.
However when I use the below code to retrieve in XML format and print it to file, it gets changed. This file is also passed to one of the application GUI where this XML gets processsed and it is not visible properly.
below id the sample abstract of code I am using.
Declare
l_file UTL_FILE.FILE_TYPE;
l_clob CLOB;
l_buffer VARCHAR2(32767);
l_amount BINARY_INTEGER := 32767;
l_pos INTEGER := 1;
Begin
SELECT XMLElement("case",
XMLElement("comments",
XMLElement("comment",
XMLElement("comments",a.COMMENTS)
).getClobVal() val1 into l_clob
FROM TO_COMMENTS a
l_file :=
UTL_FILE.fopen (XMLDIR,
test.xml,
'w',
32767);
LOOP
DBMS_LOB.read (l_clob,
l_amount,
l_pos,
l_buffer);
UTL_FILE.put_line (l_file, l_buffer);
l_pos := l_pos + l_amount;
END LOOP;
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.NEW_LINE('Reached end of file');
END;
The comments column given contains the character like pound.
And once the file is generated and i see using the vi editor, the char is not viewable properly like £
And when the same is passed to GUI application to be processed, its not viewable propely in GUI from IE as well like �.

Similar Messages

  • Need help Take out the null values from the ResultSet and Create a XML file

    hi,
    I wrote something which connects to Database and gets the ResultSet. From that ResultSet I am creating
    a XML file. IN my program these are the main two classes Frame1 and ResultSetToXML. ResultSetToXML which
    takes ResultSet & Boolean value in its constructor. I am passing the ResultSet and Boolean value
    from Frame1 class. I am passing the boolean value to get the null values from the ResultSet and then add those
    null values to XML File. When i run the program it works alright and adds the null and not null values to
    the file. But when i pass the boolean value to take out the null values it would not take it out and adds
    the null and not null values.
    Please look at the code i am posing. I am showing step by step where its not adding the null values.
    Any help is always appreciated.
    Thanks in advance.
    ============================================================================
    Frame1 Class
    ============
    public class Frame1 extends JFrame{
    private JPanel contentPane;
    private XQuery xQuery1 = new XQuery();
    private XYLayout xYLayout1 = new XYLayout();
    public Document doc;
    private JButton jButton2 = new JButton();
    private Connection con;
    private Statement stmt;
    private ResultSetToXML rstx;
    //Construct the frame
    public Frame1() {
    enableEvents(AWTEvent.WINDOW_EVENT_MASK);
    try {
    jbInit();
    catch(Exception e) {
    e.printStackTrace();
    //Component initialization
    private void jbInit() throws Exception {
    //setIconImage(Toolkit.getDefaultToolkit().createImage(Frame1.class.getResource("[Your Icon]")));
    contentPane = (JPanel) this.getContentPane();
    xQuery1.setSql("");
    xQuery1.setUrl("jdbc:odbc:SCANODBC");
    xQuery1.setUserName("SYSDBA");
    xQuery1.setPassword("masterkey");
    xQuery1.setDriver("sun.jdbc.odbc.JdbcOdbcDriver");
    contentPane.setLayout(xYLayout1);
    this.setSize(new Dimension(400, 300));
    this.setTitle("Frame Title");
    xQuery1.setSql("Select * from Pinfo where pid=2 or pid=4");
    jButton2.setText("Get XML from DB");
    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    catch(java.lang.ClassNotFoundException ex) {
    System.err.print("ClassNotFoundException: ");
    System.err.println(ex.getMessage());
    try {
    con = DriverManager.getConnection("jdbc:odbc:SCANODBC","SYSDBA", "masterkey");
    stmt = con.createStatement();
    catch(SQLException ex) {
    System.err.println("SQLException: " + ex.getMessage());
    jButton2.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(ActionEvent e) {
    jButton2_actionPerformed(e);
    contentPane.add(jButton2, new XYConstraints(126, 113, -1, -1));
    //Overridden so we can exit when window is closed
    protected void processWindowEvent(WindowEvent e) {
    super.processWindowEvent(e);
    if (e.getID() == WindowEvent.WINDOW_CLOSING) {
    System.exit(0);
    void jButton2_actionPerformed(ActionEvent e) {
    try{
    OutputStream out;
    XMLOutputter outputter;
    Element root;
    org.jdom.Document doc;
    root = new Element("PINFO");
    String query = "SELECT * FROM PINFO WHERE PID=2 OR PID=4";
    ResultSet rs = stmt.executeQuery(query);
    /*===========This is where i am passing the ResultSet and boolean=======
    ===========value to either add the null or not null values in the file======*/
    rstx = new ResultSetToXML(rs,true);
    } //end of try
    catch(SQLException ex) {
    System.err.println("SQLException: " + ex.getMessage());
    ======================================================================================
    ResultSetToXML class
    ====================
    public class ResultSetToXML {
    private OutputStream out;
    private Element root;
    private XMLOutputter outputter;
    private Document doc;
    // Constructor
    public ResultSetToXML(ResultSet rs, boolean checkifnull){
    try{
    String tagname="";
    String tagvalue="";
    root = new Element("pinfo");
    while (rs.next()){
    Element users = new Element("Record");
    for(int i=1;i<=rs.getMetaData().getColumnCount(); ++i){
    tagname= rs.getMetaData().getColumnName(i);
    tagvalue=rs.getString(i);
    System.out.println(tagname);
    System.out.println(tagvalue);
    /*============if the boolean value is false it adds the null and not
    null value to the file =====================*/
    /*============else it checks if the value is null or the length is
    less than 0 and does the else clause in the if(checkifnull)===*/
    if(checkifnull){ 
    if((tagvalue == null) || tagvalue.length() < 0 ){
    users.addContent((new Element(tagname).setText(tagvalue)));
    else{
    users.addContent((new Element(tagname).setText(tagvalue)));
    else{
    users.addContent((new Element(tagname).setText(tagvalue)));
    root.addContent(users);
    out=new FileOutputStream("c:/XMLFile.xml");
    doc = new Document(root);
    outputter = new XMLOutputter();
    outputter.output(doc,out);
    catch(IOException ioe){
    System.out.println(ioe);
    catch(SQLException sqle){

    Can someone please help me with this problem
    Thanks.

  • I am using the database connectivity toolkit to retrieve data using a SQL query. The database has 1 million records, I am retrieving 4000 records from the database and the results are taking too long to get, is there any way of speeding it up?

    I am using the "fetch all" vi to do this, but it is retrieving one record at a time, (if you examine the block diagram) How can i retrieve all records in a faster more efficient manner?

    If this isn't faster than your previous method, then I think you found the wrong example. If you have the Database Connectivity Toolkit installed, then go to the LabVIEW Help menu and select "Find Examples". It defaults to searching for tasks, so open the "Communicating with External Applications" and "Databases" and open the Read All Data. The List Column names just gives the correct header to the resulting table and is a fast operation. That's not what you are supposed to be looking at ... it's the DBTools Select All Data subVI that is the important one. If you open it and look at its diagram, you'll see that it uses a completely different set of ADO methods and properties to retrieve all the data.

  • Retrieving an image from the database and printing it

    Can anybody help please
    i dont know how to retreive an image from a image database and send to the printer.
    The image is stored in the database in cells ( not as a path to a file).

    Hi,
    I want to print a gif image.
    How can i get this done?
    I am trying graphicsobject.drawImage(....),it prints the image only once.If i try second time the image wont be printed,where as if i switch off and then switch on the printer and try again ,then it will print.I am facing the same problem with a HP Laser Jet as well as a thermal Printer.Actually i want to print a bar code.
    some body pls help me to sort this issue.
    Regards,
    ciju
    [email protected]

  • How to modify data recieved from the database and displayed in a DG

    Hello, it's me again with a simple question :
    i've got the SQLi request who returns multiples rows.
    In this row i have for example :
    Reward --> 1
    How to, instead of displaying  1 in the datagrid, change this value to "YES"
    I follow this lead :
    private function onResultStats(event:ResultEvent):void
                    ServerStatsArr = new ArrayCollection(event.result.source);
                    for (var i:int=0; i < ServerStatsArr.length;i++)
                        if (ServerStatsArr[i].abonnement ==  304){
                            ServerStatsArr[i].abonnement = 'Premium';
                        }else{
                            ServerStatsArr[i].abonnement = 'Non';   
                        if (ServerStatsArr[i].transparence ==  1) {
                            ServerStatsArr[i].transparence = 'Oui' ;
                        }else{
                            ServerStatsArr[i].transparence = 'Non' ;
                    ServerStatsArr.refresh();
    Why this method is working for abonnement when (ServerStatsArr[i].abonnement ==  304) it displays Premium but it's NOT working for transparence ?
    i tested (ServerStatsArr[i].transparence ==  1) and (ServerStatsArr[i].transparence ==  '1')
    Thank you

    hi Again,
    private function setLabel(item:Object,column:DataGridColumn):String
    switch(column.dataField)
    case "transparence":
    if (item.transparence == "1")
    return ("yes")
    else
    return ("no")
    break;
    case "abonnement":
    if (item.abonnement == "304")
    return ("premium")
    else
    return ("none")
    break;
    default:
    return("");
    and the adjustments to your grid - add the labelfunction to the following columns
    <mx:DataGridColumn headerText="transparence" dataField="transparence" labelFunction="setLabel"/>
    <mx:DataGridColumn headerText="abonnement" dataField="abonnement" labelFunction="setLabel" />
    I hope we get a distinction credit for this assignment ...
    David.

  • How to search a string from the database?

    how to search a string from the database? starting with some character

    If you're trying to do this in a SELECT, you can use the LIKE verb in your WHERE clause.
    Here's an Example
      SELECT obj_name FROM tadir
        INTO prog
        WHERE pgmid = 'R3TR'
          AND object = 'PROG'
          AND obj_name LIKE 'Z%'.
    In this case it will select every row that obj_name starts with Z. 
    If you wanted to find every row that the field obj_name contains say... 'WIN'  you use LIKE '%WIN%'.
    Edited by: Paul Chapman on Apr 22, 2008 12:32 PM

  • How to select alternate entries from the database table

    Hi Experts,
    can u help me, how to select alternate entries from the database table.
    Thanks

    As there is no concept of sequence (unless there is a field specifically included for the purpose), there is no meaning to "alternate" records.
    What table do you have in mind, what data does it hold, and why do you want alternate records?
    matt

  • HT201317 My iPhone is running out of storage.  I want to delete a bunch of photos on my phone.  I have iCloud.  How do I delete photos from the iPhone and keep them on my computer?  I need to free up storage as my phone will no longer take photos.

    My iPhone is running out of storage.  I want to delete a bunch of photos on my phone.  I have iCloud.  How do I delete photos from the iPhone and keep them on my computer?  I need to free up storage as my phone will no longer take photos.

    The only way you can do that is to import them into your library first, but you may have done that already.
    The easiest way to tell is to select a photo from the photostream album in iPhoto and ctrl-click on it, if it gives you the option to import it isn't in your iPhoto library, if it offers you the option to show in library it has already been imorted.

  • Do any one knows how to add those arrows from the right and left side of the screen in the youtube widget which allows you to navigate back and forth between video clips?

    do any one knows how to add those arrows from the right and left side of the screen in the youtube widget which allows you to navigate back and forth between video clips?

    do any one knows how to add those arrows from the right and left side of the screen in the youtube widget which allows you to navigate back and forth between video clips?

  • I want to download an invoice template. How can I then fill in the template and place in a file?

    I want to download a template of an invoice. How can I then fill in the template and create a separate file?

    template in Word format? Excel? PDF? a little more information please.

  • Handling in java special characters read from the database

    Hello,
    I have a java application which processes data from the database. During processing I have to handle some special national characters which are specified with integer codes. The codes are defined in UTF-8 and the list of these characters and their codes is constant.
    How to handle them in java where char primitive type denotes characters in UTL-16, not UTF-8. Should I use class Charset and decoder like below?
    Charset charset = Charset.forName("UTF-8");
    CharsetDecoder decoder = charset.newDecoder();
    The problem which I see here is that class CharsetDecoder provides no method which would take integer code of the character in UTF-8 and return char value (in UTF-16).
    The only way I see is to provide ByteBuffer, but then I have to encode the codes of these characters in UTF-8 somehow (how?), as they have two bytes codes like 50048.
    Best wishes,
    Tomasz Michniewski
    Edited by: Tomasz Michniewski on 2009-09-08 04:19

    Please verify the followings:
    Make sure that from the SharePoint front end and application servers that you can ping your SQL server.
    Make sure that your Farm account has permission to the configuration database.
    Lastly verify that your database didn't for some reasons go into recovery mode.
    once everything is fine and you are still having issues, restart the SQL host service on the SQL server.
    Once the service is restarted you will need to reboot Central Admin and then your front end servers.
    In addition, as you built your farm inside the firewall, please disable the firwall, or create rules for SQL Server service in the firwall on SQL server.
    More information about creating rules in firewall, please refer to the following posts: http://social.technet.microsoft.com/Forums/en-US/c5d4d0d0-9a3b-4431-8150-17ccfbc6fb82/can-not-create-data-source-to-an-sql-server http://www.mssqltips.com/sqlservertip/1929/configure-windows-firewall-to-work-with-sql-server/
    Here is a similar post for you to take a look at: http://social.technet.microsoft.com/Forums/en-US/ea54e26c-1728-48d4-b2c5-2a3376a1082c/this-operation-can-be-performed-only-on-a-computer-that-is-joined-to-a-server-farm-by-users-who-have?forum=sharepointgeneral 
    Please 'propose as answer' if it helped you, also 'vote helpful' if you like this reply.

  • How I can transfer data from the database into a variable (or array)?

    I made my application according to the example (http://corlan.org/2009/06/12/working-in-flash-builder-4-with-flex-and-php/). Everything works fine. I changed one function to query the database - add the two parameters and get the value of the table in String format. A test operation shows that all is ok. If I want to display this value in the text area, I simply drag and drop service to this element in the design mode
    (<s:TextArea x="153" y="435" id="nameText" text="{getDataMeanResult.lastResult[0].name}"  width="296" height="89"  />).
    It also works fine, just a warning and encouraged to use ArrayCollection.getItemAt().
    Now I want to send the value to a variable or array, but in both cases I get an error: TypeError: Error #1010: A term is undefined and has no properties..
    How can I pass a value from the database into a variable? Thank you.
    public var nameTemp:String;
    getDataMeanResult.token = authors.getDataMean(arrayOfNumber[0], dir_id);
    nameTemp = getDataMeanResult.lastResult[0].name;
    public var nameArray:Array = new Array();
    for (var i:uint=o; i<3; i++){
    getDataMeanResult.token = authors.getDataMean(arrayOfNumber[i], dir_id);
    nameArray[i] = getDataMeanResult.lastResult[0].name;
    And how i can use syntax highlighting in this forum?

    Astraport2012 wrote:
    I have to go back to the discussion. The above example works fine when i want to get a single value of the database. But i need to pass an array and get an array, because i want to get at once all the values for all pictures tooltips. I rewrote the proposed Matt PHP-script and it works. However, i can not display the resulting array.
    yep, it won't work for Arrays, you'll have to do something slightly more intelligent for them.
    easiest way would be to get your PHP to generate XML, then read that into something like an ArrayList on your HTTPService result event (depends what you're doing with it).
    for example, you could have the PHP generate XML such as:
    <pictures>
         <location>test1.png</location>
         <location>test2.png</location>
         <location>test3.png</location>
         <location>test4.png</location>
         <location>test5.png</location>
         <location>test6.png</location>
    </pictures>
    then you'll read that in as the ResultEvent, and perform something like this on it
    private var tempAC:ArrayList = new ArrayList
    protected function getStuff_resultHandler(event:ResultEvent):void
        for each(var item:Object in event.result.pictures)
           var temp:String = (item.@location).toString();
           tempAC.addItem(temp);
    in my example on cookies
    http://www.mattlefevre.com/viewExample.php?tut=flash4PHP&proj=Using%20Cookies
    you'll see an example of how to format an XML structure containing multiple values:
    if($_COOKIE["firstName"])
            print "<stored>true</stored>";
            print "<userInfo>
                    <firstName>".$_COOKIE["firstName"]."</firstName>
                    <lastName>".$_COOKIE["lastName"]."</lastName>
                    <userAge>".$_COOKIE["userAge"]."</userAge>
                    <gender>".$_COOKIE["gender"]."</gender>
                   </userInfo>";
        else
            print "<stored>false</stored>";
    which i handle like so
    if(event.result.stored == true)
                        entryPanel.title = "Welcome back " + event.result.userInfo.firstName + " " + event.result.userInfo.lastName;
                        firstName.text = event.result.userInfo.firstName;
                        lastName.text = event.result.userInfo.lastName;
                        userAge.value = event.result.userInfo.userAge;
                        userGender.selectedIndex = event.result.userInfo.gender;
    depends on what type of Array you're after
    from the sounds of it (with the mention of picture tooltips) you're trying to create a gallery with an image, and a tooltip.
    so i'd probably adopt something like
    <picture>
         <location>example1.png</location>
         <tooltip>tooltip for picture #1</tooltip>
    </picture>
    <picture>
         <location>example2.png</location>
         <tooltip>tooltip for picture #2</tooltip>
    </picture>
    <picture>
         <location>example3.png</location>
         <tooltip>tooltip for picture #3</tooltip>
    </picture>
    etc...
    or
    <picture location="example1.png" tooltip="tooltip for picture #1"/>
    <picture location="example2.png" tooltip="tooltip for picture #2"/>
    <picture location="example3.png" tooltip="tooltip for picture #3"/>
    etc...

  • How to have a multilanguage from the database

    Hi,
    I have an application under jdev 11g.
    I am using the locale and the bundle for the multilanguage.
    My problem is with the data from the database.(i.g. select on choice with the items dynamic from the database)
    Also if i am displaying for example the customer info in af:outputtext i want his name to be displayed in english , arabic and other according to the locale choice
    The Fusion Web guide on specifies the resource bundle issue.
    Any hints, doc or sample regarding this issue.
    Best Regards
    Emile BITAR
    Edited by: ebitar on Jun 11, 2009 8:24 AM

    Hi,
    resource bundles work for labels but not data. If you have such a requirement then you need to add this using a discriminator column when querying it. Say you maintain the display data in multiple languages, then you would have a column that holds the language. The query would then be for the language the user expects. If you have static data - in the select one choice case - you can use
    http://thepeninsulasedge.com/frank_nimphius/2007/09/05/adf-faces-localizing-selectonechoice-labels/
    Frank

  • How to retrieve all data from iPod Touch and copy to new computer?

    I recently purchased a new iPod and MacBook. The MacBook was stolen and I had to buy a new one. I have a lot of music and photos on the iPod I would like to recover and copy back to the MacBook. However, the iTunes says it will delete everything. I want it to sync everything from the iPod and continue with that data.
    How can I do this?
    Thanks,
    gonzobrains

    You're welcome, child.
    "backups. But that's not my point. I find it disappointing that I cannot sync my data both ways."
    O.K. It still is the way it is.
    "Here I have gigabytes of data sitting right here on my iPod and no way to natively copy it back to my new computer without purchasing third-party software."
    Yes, this is true.
    "Every other mobile device I have ever owned let's you easily copy back to a computer. Just plug it in, mount it, and there you go."
    As you now know, this is not the case with the ipod touch.
    You asked how and I told you that you cannot without 3rd party software. What is it that you want?
    Simply maintaining a backup (basic) would solve the issue.

  • Loading an Image from the database and display it on browser

    I do not know if this is even possible.
    At the moment, to load an image inside an Html page you need to use the <img src=""> tag. and in the src you put the path of the image. Now I would like to save an image inside the database.
    An option to still display the image on the browser would be that my service object, would load the object from the database (saved as blob) then save it somewhere on the Server, and the still use the <img> tag to load the image from that location.
    However I was wondering wheather there is another way to do it without saving this image on the server. that is loading the bytes from the database (or a location on the server) and provided these bytes to the jsp page to display the image.
    Is this possible? or?
    regards,
    sim085

    hmm ... ok .. that sounds good .. but that means that
    a servlet must exsist at all time to display the
    required image.Servlets are usually instantiated by the servlet container upon an incoming request.

Maybe you are looking for

  • Problem in absent report(ABAP-HR)

    Hi to all I am getting a problem in Absent report.(HR-ABAP) Absent report shows next day irregular punch in case of  'C' shift(Timing 10:30 PM to 6:30 AM)  at the end of month. It happens only at the end of month like 31/10/2007 because in selection

  • APO DP Using BAdI SDP_SELECTOR

    Hi experts, I am trying to use BAdI /SAPAPO/SDP_SELECTOR but I can not get any method of it to stop at a breakpoint. What I want to implement: By opening a planning book and loading a specific selection profile, some fields in selection shuffler have

  • Offer a Noob help? General one key recovery question

    So I'm new to laptops, especially Lenovo, and when I got my laptop I had barely found out about the One Key Recovery Backup application AFTER I installed quite a few games. So I decided to make the backup but it ended up being 49GB so I put it on my

  • How to install squid on 5.5?

    I tried "yum install squid" but got this: No package squid available Is there a repository or something that I need to add somewhere to get squid? I also tried to install a downloaded rpm but a lot of dependencies are missing. Thanks for the help!

  • "cannot allocate memory" When trying to start a new project in FCPX

    So I am I getting the "cannot allocate memory" error whenever I try to start a new project in FCPX System specs: Model Name:          Mac Pro   Model Identifier:          MacPro3,1   Processor Name:          Quad-Core Intel Xeon   Processor Speed: