Charset decoding problem. UTF-8

Hi,
I'm using Jakarta Commons HttpClient and am having trouble reading the response to a GetMethod.
// execute method
byte[] bytes = method.getResponseBody();
String response = new String(bytes, "UTF-8");
// method.getResponseCharSet() returns "utf-8"
System.out.println(response);Unfortunately this just displays garbage.
I added code to iterate through and print out the value of each byte. Some come up negative which surprises me. If I put the first 50 or so values here maybe someone can identify what the problem is:
031 -117 008 000 000 000 000 000 000 011 -115 086 075 111 -029 054 016 -066 -025 087
008 -070 056 001 -078 090 -110 018 -011 -088 031 064 -110 -090 -040 093 036 -023 -042 -021
108 015 069 015 -076 -060 -040 066 -012 048 036 058 -117 -004 -005 114 -122 018 035 -045 It should read
<html><head><meta HTTP-EQUIV="pragma" CONTENT="no-cache">
<script language="Javascript">...
Thanks

If the String object
<html><head><meta HTTP-EQUIV="pragma"CONTENT="no-cache"><script language="Javascript">is transformed to a byte array with UTF-8 encoding then its elements are as follows.
14 97 103 109 97 34 67 79 78 84 69 78 84 61 34 110 111 45 99 97 99 104 101 34 62 60 115 99 114 105 112 116 32 108 97 110 103 117 97 103 101 61 34 74 97 118 97 115 99 114 105 112 116 34 62Probably encoding does not coincide or your byte array is different from what intended.

Similar Messages

  • Charset Decoding Problem

    Please let me know why this program doesn't work!
    ByteBuffer buffer = null;
    CharBuffer charBuffer = CharBuffer.allocate(100);
    buffer = ByteBuffer.wrap(new String("Server 10").getBytes());
    buffer.flip();
    Charset cs = Charset.forName("ISO-8859-1");
    CharsetDecoder cd = cs.newDecoder();
    cd.decode(buffer,charBuffer,false);
    System.out.println("Char Buffer " + charBuffer.toString());
    buffer.clear();
    This does not display any output at all.
    Please let me know ... if you have any clue .. on this!
    Thanks in Advance.

    Hi..thanks for the response.
    Yes..I did try that. It still gives the same output. I even tried a charBuffer.flip() too. No help !
    ByteBuffer buffer = null;
    CharBuffer charBuffer = CharBuffer.wrap(new String(""));
    PropertyConfigurator.configure("log.properties");
    buffer = ByteBuffer.wrap(new String("Server 10").getBytes());
    Charset cs = Charset.forName("ISO-8859-1");
    CharsetDecoder cd = cs.newDecoder();
    cd.decode(buffer,charBuffer,true);
    logger.debug("Decoding done");
    logger.info("Char Buffer " + charBuffer.toString());
    logger.info("Length = " + charBuffer.toString().length());
    buffer.clear();
    The output is ...
    2003 Jul 01 17:30:46 [main] DEBUG TestCharset - Decoding done
    2003 Jul 01 17:30:46 [main] INFO TestCharset - Char Buffer
    2003 Jul 01 17:30:46 [main] INFO TestCharset - Length = 0
    Any further clues will be really helpful.
    thanks in advance

  • Latin Charset Problems UTF-8 and ISo-8859-1

    Hello all,
    I'm having problems displaying latin characters in my application such as ~, ^, ´, ` and so on.
    Using jinitiator works fine, but i'm using java 1.5.0_04, it's a client requisit.
    I'm using IAS 10gr2 and forms 10gr2 also.
    Is there any configuration property that i can change to allow a correct char displaying.
    Can anyone help me please?
    Thanks in advanced
    João Antunes

    Hello Francois,
    Thanks for replying.
    It only happens when i'm writing, all the values queried to the DB are returned ok.
    My NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P1.
    Thanks in advanced
    João Antunes

  • JavaMail cannot detect charset/decode e-mail after JAX-WS Endpoint init

    There is the code (failed in Tomcat 6.0.20 / Jetty, JDK 1.6.0_18, JavaMail 1.4.3):
         <?xml version="1.0" encoding="UTF-8"?>
         <web-app xmlns="http://java.sun.com/xml/ns/javaee"
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
                   http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
                  version="2.5">
             <filter>
                 <filter-name>CompressResponse</filter-name>
                 <filter-class>Filter</filter-class>
             </filter>
         </web-app>
         import runner.RunWebService;
         import javax.servlet.*;
         import java.io.IOException;
         public class Filter implements javax.servlet.Filter {
             public void init(FilterConfig filterConfig) throws ServletException {
                 try {
                     RunWebService run = new RunWebService();
                     run.readEmail();
                     run.initWebService();
                     run.readEmail();
                 } catch (Exception e) {
                     e.printStackTrace();
             public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
             public void destroy() {
         package runner;
         import javax.mail.Folder;
         import javax.mail.Message;
         import javax.mail.Session;
         import javax.mail.Store;
         import javax.mail.internet.MimeMessage;
         import javax.xml.ws.Endpoint;
         import java.util.Properties;
         public class RunWebService {
             public static void main(String[] arg) {
                 RunWebService runWebService = new RunWebService();
                 runWebService.initWebService();
                 runWebService.readEmail();
             public void readEmail() {
                 try {
                     Properties props = System.getProperties();
                     props.put("mail.pop3.host", "pop.yandex.ru");
                     Session session = Session.getDefaultInstance(props, null);
                     Store store = session.getStore("pop3");
                     store.connect("pop.yandex.ru", 110, "**********@yandex.ru", "**********");
                     Folder folder = store.getFolder("INBOX");
                     folder.open(Folder.READ_WRITE);
                     Message message[] = folder.getMessages();
                     for (int i=0, n=message.length; i<n; i++) {
                         MimeMessage m = (MimeMessage) message;
         System.out.println(i + ": " + message[i].getFrom()[0] + "\t" + message[i].getSubject());
         System.out.println(m.getContent());
         folder.close(false);
         store.close();
         } catch (Exception e) {
         e.printStackTrace();
         public void initWebService() {
         String serviceUrl = "http://localhost:8088/";
         Endpoint.publish(serviceUrl+ Test.class.getSimpleName(), new Test());
         package runner;
         import javax.jws.WebService;
         @WebService
         public class Test {
         public void log() {
         System.out.println("test");
    How JAX-WS can affect JavaMail e-mail decoding ? How to fix it ?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    Got the following from the JAX-WS team:
    I think it is related to:
    [https://jax-ws.dev.java.net/issues/show_bug.cgi?id=707|https://jax-ws.dev.java.net/issues/show_bug.cgi?id=707]
    [https://jax-ws.dev.java.net/issues/show_bug.cgi?id=656|https://jax-ws.dev.java.net/issues/show_bug.cgi?id=656]
    In short, JAX-WS was registering a DataContentHandler that doesn't honor charset for text/plain mime type. We fixed it by copying the same data content handler from JavaMail.

  • Charset Encoding Problem

    Hello all,
    I have the problem that umlaut like ä, ü,ö are didn´t shown in the Browser. In the JSP Page I included the charset=iso-8859-1. I used the Web Application Server 6.4 SP12. If I used this charset ín a normal HTML Site it works fine. Could anybody help me to solve the Problem?
    Kind regard
    Axel

    Hi Axel,
    try to use charset UTF-8, which also is the default workbench editor setting on NWDS. At least, the portal's JSP engine (which is different from the WAS') needs that to work properly.
    Hope it helps
    Detlev

  • Decoding-problems on subject

    Hello all,
    as far as I observed javamail does an automatic decoding of an eMail-subject for me. So a
    Subject: =?iso-8859-1?B?QW1hem9uLmRl?=
    automaticly becomes
    Subject: Amazon.de
    Now I get a message with the subject:
    Subject: openBC:=?UTF-8?Q?=20Ingo=20Gr=C3=BCneberg=20hat=20?= =?UTF-8?Q?Sie=20als=20Kontakt=20best?==?UTF-8?Q?=C3=A4tigt?=
    which will not be decoded by javamail. I tried to work around the problem and forced my application to decode the subject one more time - no result:
    System.out.println(MimeUtility.decodeText("openBC:=?UTF-8?Q?=20Ingo=20Gr=C3=BCneberg=20hat=20?= Sie als Kontakt best=?UTF-8?Q?=C3=A4tigt?="));
    -> openBC:=?UTF-8?Q?=20Ingo=20Gr=C3=BCneberg=20hat=20?= Sie als Kontakt best=?UTF-8?Q?=C3=A4tigt?=
    Then I thought the string would be the problem, but Thunderbird decodes the subject right!??
    Any sugestions? Thanks a lot in advance!
    Stephan
    Message was edited by:
    lotk

    First of all,i want to show you my code:
    package orlab.test;
    import java.io.File;
    import java.io.FileInputStream;
    import javax.mail.internet.MimeMessage;
    public class Program {
    * @param args
    * @throws Exception
    * @throws
    public static void main(String[] args) throws Exception {
    System.setProperty("mail.mime.decodetext.strict", "false");
    File dir = new File("c:/Mail");
    File[] files = dir.listFiles();
    for (int i = 0; i < files.length && i < 4; i++) {
    File f = files;
    if (!f.isFile()) {
    continue;
    FileInputStream fis = new FileInputStream(f);
    MimeMessage mm = new MimeMessage(null, fis);
    String rowHeader = mm.getHeader("Subject")[0];
    // System.out.println(MimeUtility.decodeText(mm.getSubject()));
    if (!rowHeader.equals(mm.getSubject())) {
    // continue;
    System.out.println("File\t\t:" + f.getName());
    System.out.println("Raw\t\t:" + rowHeader);
    System.out.println("Subject\t\t:" + mm.getSubject());
    fis.close();
    System.out.println("_______________");
    the raw mail data like this:
    _*Message-ID: <[email protected]>*_
    _*Date: Fri, 6 Jun 2008 19:06:47 +0900 (JST)*_
    _*Subject: SOME=?ISO-2022-JP?B?GyRCTU0wRjdvJUElJyVDJS8lNyE8JUgbKEI=?=*_
    this is the code which can decode "SOME=?ISO-2022-JP?B?GyRCTU0wRjdvJUElJyVDJS8lNyE8JUgbKEI=?=
    "to"SOME&#27096;&#26696;&#20214;&#12481;&#12455;&#12483;&#12463;&#12471;&#12540;&#12488;
    ", when i using gnu javamail.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Charset conversation problem.

    Hi!
    I wanted to transform a ISO-8559-15 byte-Array into a valid Java String using
    byte[] data = ...;
    Charset iso_8559_15 = Charset.forName("ISO-8559-15");
    String s = iso_8559_15.decode(ByteBuffer.wrap(data)).toString();s inclodes stranges byte-set which are neighter of UTF-8 nor ISO-8559-15 origin when writing them to a file using FileWriter.
    It works perfectly well using
    byte[] data = ...;
    String s = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(data))).readLine();Can you tell me whats wrong with using Charset/CharsetDecoder?

    Probably you mean ISO-8859-15.
    Check System.getProperty("file.encoding") - this is the default encoding.
    I suppose it is different than ISO-8859-15 (if your second approach gives different results).
    The simple way to convert byte array to string with desired charset is:
    String str = new String(data, "ISO-8859-15");If you still do not achieve readable strings, check your input data.
    Probably you have not-printable chars - for ISO-8859-15 in range 120-160 or most of these bellow 32.
    (simple description and chars table can be found here: http://en.wikipedia.org/wiki/ISO_8859-15).

  • Payload decoding problem

    Hi
    Im using 10.1.2.3 b2b with mlr#7. In edi 841 transaction im encoding a .jpeg(image) file in to base64 format and attaching it to the binary data section.The output raw edi data has the decoded jpeg file but it was corrupted.I donno how to get my original .jpeg(image) file.Same thing happens for .pdf format.Kindly help in resolving this issue.
    Regards
    venkat

    Hi Venkat,
    No there is no such rule and B2B will decode it in the same format.
    If you have applied MLR#7 successfully then it should work.
    Anyways, take the attachment content from the wiremessage and decod it using base 64 encoding manually and save it as a jpeg, and try to open. If then also you are not able to open then decode it twice and now save it as jpeg and try to open. I am asking this because prior to MLR#7 there was problem of attachments getting encoded twice.
    You may consider forwarding wire message and b2b log in debug mode to my id (in my profile).
    Regards,
    Anuj

  • Charset definition problem

    Hi,
    I've a strange problem with my website html pages. My pages have charset defined in the page's header as "windows-1255" but sometimes explorer browsers take utf8 encoding. Then People see a white page because the browser can't display the page correctly. I tryed to add to the server in international support the alias charset cp1255 but is not defined by the server. i think that sometime explorer browsers fail to read the correct charset from the html page then it take the default explorer charset utf8 because the server send none default charset in HTTP header request. How can correct this problem? how can i define cp1255 as default encoding in my server?
    thanks

    SunOne 6.1 sp5 on SunFire server with solaris 9.

  • c:import character encoding problem (utf-8)

    Aloha @ all,
    I am currently importing a file using the <c:import> functionallity (<c:import url="module/item.jsp" charEncoding="UTF-8">) but it seems that the returned data is not encoded with utf-8 and hence not displayed correctly. The overall file header is:
    HTTP/1.1 200 OK
    Server: Apache-Coyote/1.1
    Set-Cookie: JSESSIONID=E67F9DAF44C7F96C0725652BEA1713D8;
    Content-Type: text/html;charset=UTF-8
    Content-Length: 6861
    Date: Thu, 05 Jul 2007 04:18:39 GMT
    Connection: close
    I've set the file-encoding on all pages to :
    <%@ page contentType="text/html;charset=UTF-8" %>
    <%@ page pageEncoding="UTF-8"%>
    but the error remains... is this a known bug and is there a workaround?

    Partially, yes. It turns out that I created the documents in eclipse with a different character encoding. Hence the entire document was actually not UTF-encoded...
    So I changed each document encoding in Eclipse to UTF and got it working just fine...

  • Decode problem

    Hi,
    I have a problem with a decode function.
    I try to execute this select:
    select (DECODE(:CU_IES, 'D', (DECODE(:P_FISC, 1, a.flag1, 0, a.flag2) in (2,3,4)), (DECODE(:P_FISC, 1, a.flag1, 0, a.flag2) in (2,3,4,6))))
    from flag a
    and a get this error ORA-00907: missing right parenthesis.
    I try to this in Report Builder 6.0.8.11.3.
    I want to do this: when :cu_ies is 'D' to bring me flags 2,3,4 and if not 'D' to bring me flags 2,3,4,6. (All flags are from 0 to 6)
    What I have done wrong?
    Anyone can help me?

    Try using case instead of decode
    SELECT SUM(CASE :p_fisc,
                 WHEN 1 THEN
                  nvl(a.val_int, 0) + nvl(a.val_mod, 0) + nvl(a.val_dep_int, 0)
                 WHEN 0 THEN
                  nvl(a.val_int_int, 0) + nvl(a.val_mod_int, 0) +
                  nvl(a.val_dep_int, 0) + nvl(a.prov_dez_val, 0)
               END) val_inv1,
           0 val_inv2,
           a.cod_cat
      FROM flag a, MJ M
    WHERE a.identif_a = M.identif_a
       AND (CASE :P_FISC WHEN 1 THEN a.flag1 WHEN 0 THEN a.flag2
            END IN (2, 3, 4) OR :cu_ies = 'D')
    GROUP BY a.cod_cat
    UNION ALL
    SELECT 0 val_inventar1,
           SUM(CASE :p_fisc
                 WHEN 1 THEN
                  nvl(a.val_int, 0) + nvl(a.val_mod, 0) + nvl(a.val_dep_int, 0),
                 WHEN 0 THEN
                  nvl(a.val_int_int, 0) + nvl(a.val_mod_int, 0) +
                  nvl(a.val_dep_int, 0) + nvl(a.prov_dez_val, 0
               END)) val_inv2,
           a.cod_cat
      FROM flag a, MJ M
    WHERE a.identif_a = M.identif_a
       AND (CASE :P_FISC WHEN 1 THEN a.flag1 WHEN 0 THEN a.flag2
            END = 5 OR :cu_ies = 'D')
    GROUP BY a.cod_catHTH
    SS

  • XML data - charset encoding problem

    Hello all,
      I am facing an issue on charset encoding. My requirement is to send an XML and read the the output XML to display the output. The output XML is encoded in "ISO-8859-1" and we are retrieving/reading it in "UTF-8". But some special characteres in the output XML are appearing as it is.
      Could some one let me know on how to obtain the desired characters.
    Code snippet while reading the XML:
    BufferedReader inStream = null;
    BufferedWriter outStream = new BufferedWriter(new OutputStreamWriter(connection.getOutputStream(),"UTF-8"));
    inStream =
         new BufferedReader(new InputStreamReader(inputStream,"UTF-8"));
    Thanks & regards,
    Sharath

    Hi Sharath,
    To read the XML file use the following. Don’t mention the character set during reading it.I hope it will help you.
    XML file(emp.xml)
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <Emp>
    <EmpDetails>
           <firstname>Sarbari</firstname>
           <lastname>Saha</lastname>
      </EmpDetails>
      <EmpDetails>
           <firstname>Tumpa</firstname>
           <lastname>Hazra</lastname>
      </EmpDetails>
    </Emp>
    Java File
    import java.io.*;
    import javax.xml.parsers.*;
    import org.w3c.dom.*;
    import org.xml.sax.SAXException;
    import org.w3c.dom.NamedNodeMap;
    class ReadXML
         public static void main(String args[])
              try
                   String fileName="emp.xml";
                   DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
                   DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
                   Document doc = docBuilder.parse (fileName);
                   NodeList nodeList = doc.getChildNodes();
                   int nodeSize = nodeList.getLength();
                   for (int i=0;i<nodeSize;i++)
                        Node node = nodeList.item(i);
                        Element elm = (Element) node;
                        NodeList EmpDetailsList=elm.getElementsByTagName("EmpDetails");
                        int stNodeSize = EmpDetailsList.getLength();
                        System.out.println("NodeSize =  "+stNodeSize );
                        for(int j=0;j<stNodeSize;j++)
                                  Node nodeEmpdtl = EmpDetailsList.item(j);
                                  Element elmDetails = (Element) nodeEmpdtl;
                                  NodeList firstnameList=elmDetails.getElementsByTagName("firstname");
                                  NodeList lastnameList=elmDetails.getElementsByTagName("lastname");
                                  Node fnameNode=firstnameList.item(0);
                                  System.out.print("Node : " + fnameNode.getNodeName());
                                  System.out.println ("  Value : "+((Element)fnameNode).getChildNodes().item(0).getNodeValue());
                                  int lastnameNodeSize = lastnameList.getLength();
                                  Node lnameNode=lastnameList.item(0);
                                  System.out.print("Node : " + lnameNode.getNodeName());
                                  System.out.println("  Value : "+((Element)lnameNode).getChildNodes().item(0).getNodeValue());
              catch(ParserConfigurationException pce)
                   System.out.println("Inside ParserConfigurationException Exception");
              catch(SAXException se)
                   System.out.println("Inside SAXException Exception");
              catch(IOException ioe)
                   System.out.println("Inside IOException Exception");
    Regards,
    Mithu

  • Request parameters not decoded in UTF-8 format

    Hi All,
    I've a spring mvc application hosted in tomcat.But when I make a get request to this application giving japanese characters as parameters , the servlet decodes it in ISO-8859-1 fomat, due to which a search functionality is failing.
    Is there any way to specify the servlet for decoding the request parameters in UTF-8 format?
    I Tried adding the URIEncoding="UTF-8" attribute in Connector tag in server.xml of the tomcat server where my application is hosted, but still -ve results.
    Any help?

    This link may help you:
    http://wiki.apache.org/tomcat/FAQ/CharacterEncoding
    The change you made is indeed documented:
    http://tomcat.apache.org/tomcat-7.0-doc/config/http.html
    so if that doesn't work, you'll have to direct your question to a Tomcat forum.

  • CharSet EE8BS2000 problem (BS2000/OSD)

    Dear All!
    We are now trying our new Oracle Server (version 8.0.4.2.10) on platform BS2000/OSD, but we have problem with accented Hungarian letters and character sets...
    Our "Server for Siemens BS2000 User's Guide" (Z25550-01) says that character set EE8BS2000 is equal to Siemens EBCDIC.DF.04-2 (EDF042),
    but experiments showed that in reality it is Siemens EBCDIC.EHC.L2 (EEHCL2)
    (both server an client side affected).
    We would use the first one (EDF042), which seems to be the new standard of BS2000.
    (Notes:
    1.When we select charset WE8BS2000 instead EE8BS2000 almost everything is OK, except for double-acuted Hungarian characters (o" and u") which are not shown/can not be entered from SQL*Plus on Win.
    2.Hungarian texts in "ORALOAD.LIB" use character codes from EDF042. (Little hope for us))
    An other question is that remote clients (eg SQL*Plus on Windows) does not support
    EE8BS2000 character set (yet (?)), so we would set the server to perform the conversion between EBCDIC (EDF042) and ASCII (ISO-8859-2).
    Can someone please give us some hint ?
    Appendix:
    Character EEHCL2 EDF042
    a' x'71' x'45'
    e' x'72' x'51'
    i' x'73' x'55'
    o' x'74' x'ce'
    o: x'75' x'cc'
    o" x'76' x'cf'
    u' x'77' x'de'
    u: x'78' x'dc'
    u" x'79' x'db'
    more information about Siemens character sets can be found in http://manuals.mchp.siemens.de/servers/bs2_man/man_us/dcam/v14_0/xhcs.pdf
    null

    I wrote earlier:
    "Hungarian texts in "ORALOAD.LIB" use character codes from EDF042. (Little hope for us)"
    Well... not exactly... eg:
    module "MNNMSHU" uses codetable EEHCL2
    module "MNNCXHU" uses codetable EDF042
    so the situation is worst that we thought...

  • Sorting: ORDER BY DECODE Problem on Pagination Query

    Hi,
    I've been searching around the easiest way to perform a dynamic "ORDER BY" clause and the "DECODE()" clause solution seem to be exactly what I am looking for. Unfortunately, It seems the DECODE function is not returning a correct column name value (I think it is returning NULL) since I'm receive the result set as if there was no ORDER BY clause.
    I need some help to get through this!
    Here the version with DECODE (not working)
    It is a Procedure with frstRow, nbRows and var_order as parameters
    The output returns the rows as if no ORDER BY was used
    SELECT c1, c2
    FROM
    SELECT ROWNUM rn, arv.*
    FROM A_AWA_AR arv
    WHERE ROWNUM < (frstRow + nbRows - 1) -- show only some rows determined by procedure
    ORDER BY DECODE(var_order, 1, c1, 2, c2, c1) -- sort by var_order
    WHERE rn BETWEEN frstRow AND (frstRow + nbRows)
    AND ROWNUM <= nbRows
    Here the version without DECODE (working)
    The output returns the rows as expected - ordered by c2 column
    SELECT c1, c2
    FROM
    SELECT ROWNUM rn, arv.*
    FROM A_AWA_AR arv
    WHERE ROWNUM < (frstRow + nbRows - 1) -- show only some rows determined by procedure
    ORDER BY c2 -- sort by var_order
    WHERE rn BETWEEN frstRow AND (frstRow + nbRows)
    AND ROWNUM <= nbRows
    -----

    Here are some results I've been getting... I will try the best I can to explain my problem.
    And by the way the table A_AWA_AR is a VIEW maybe this can help.
    My problem -- I think -- is that I don't understand how DECODE works. I should be a conditional IF-ELSE-THEN-like function but its behavior is not returning what I'm expecting.
    I need a solution where I will be able to sort the first lets say 10 rows using ROWNUM to tag row position (in sub-query) then the main query should only show the rows from 3rd postion to 7th position in the main query (as an example) with RN BETWEEN 3 AND 7. My solution does not work when I use decode but works when i pass the column name directly.
    Here is a simple query returning the values in the order they are found in the view:
    SELECT ROWNUM rn, ROW_ID, SR_NUM
    FROM A_AWA_AR
    WHERE ROWNUM < 10 Results:
    RN                                     ROW_ID          SR_NUM                                                         
    1                                      1-100876        1-60476802                                                     
    2                                      1-10087G        1-60476812                                                     
    3                                      1-10087Q        1-60476822                                                     
    4                                      1-10088A        1-60476842                                                     
    5                                      1-10088K        1-60476852                                                     
    6                                      1-10088U        1-60476862                                                     
    7                                      1-100894        1-60476872                                                     
    8                                      1-10089E        1-60476882                                                     
    9                                      1-10089O        1-60476892                                                      Now this is the query & result I would like to obtain (this is done pretty fast since it returns as soon as it reaches 9 sorted rows):
    SELECT ROWNUM rn, ROW_ID, SR_NUM
    FROM A_AWA_AR
    WHERE ROWNUM < 10
    ORDER BY SR_NUMResults:
    RN                                     ROW_ID          SR_NUM                                                         
    1                                      1-1RV9J7        1-107274499                                                    
    2                                      1-1RVXIF        1-107305575                                                    
    3                                      1-1SHY65        1-108332861                                                    
    4                                      1-22FOSR        1-125023563                                                    
    5                                      1-236F3X        1-126270717                                                    
    6                                      1-28P5EB        1-135542675                                                    
    7                                      1-29P2VY        1-137219038                                                    
    8                                      1-29ZNFH        1-137712221                                                    
    9                                      1-2BLWQR        1-140430339                                                     But with decode even a simple pseudo decode:
    SELECT ROWNUM rn, ROW_ID, SR_NUM
    FROM A_AWA_AR
    WHERE ROWNUM < 10
    ORDER BY DECODE(1,1,SR_NUM)Results:
    RN                                     ROW_ID          SR_NUM                                                         
    1                                      1-100876        1-60476802                                                     
    2                                      1-10087G        1-60476812                                                     
    3                                      1-10087Q        1-60476822                                                     
    4                                      1-10088A        1-60476842                                                     
    5                                      1-10088K        1-60476852                                                     
    6                                      1-10088U        1-60476862                                                     
    7                                      1-100894        1-60476872                                                     
    8                                      1-10089E        1-60476882                                                     
    9                                      1-10089O        1-60476892                                                      Here is the structure I'm trying to get and works when passing a column name:
    SELECT *
    FROM
        SELECT ROWNUM rn, ROW_ID, SR_NUM
        FROM A_AWA_AR
        WHERE ROWNUM < 10
        ORDER BY SR_NUM
    WHERE rn BETWEEN 3 AND 7Results:
    RN                                     ROW_ID          SR_NUM                                                         
    3                                      1-1SHY65        1-108332861                                                    
    4                                      1-22FOSR        1-125023563                                                    
    5                                      1-236F3X        1-126270717                                                    
    6                                      1-28P5EB        1-135542675                                                    
    7                                      1-29P2VY        1-137219038                                                     Now with decode (not working):
    SELECT *
    FROM
        SELECT ROWNUM rn, ROW_ID, SR_NUM
        FROM A_AWA_AR
        WHERE ROWNUM < 10
        ORDER BY DECODE(1,1,SR_NUM)
    WHERE rn BETWEEN 3 AND 7Results:
    RN                                     ROW_ID          SR_NUM                                                         
    3                                      1-10087Q        1-60476822                                                     
    4                                      1-10088A        1-60476842                                                     
    5                                      1-10088K        1-60476852                                                     
    6                                      1-10088U        1-60476862                                                     
    7                                      1-100894        1-60476872                                                      Thanks for the support!

Maybe you are looking for

  • Camera calibration in Camera Raw 6.7 VS 7.0*

    Hi again! I noticed that in cameraw raw 7.0, under camera calibration, my only choice is Adobe standard. I get the same for me Fuji X100. In the 6.7 version witn CS6, for my Canon 5d Mark III (same with the Mark II), I had the full array: Standard, F

  • Not playing back in DVD player

    Hello all, I made a DVD in DVD Studio Pro, and it played back perfectly in the DVD player on my mac. Then I went to play it in 2 other DVD players, and it wouldn't recognize the media. I also couldn't play it on a PC player. I have no idea why. Any i

  • Calling images in report

    i am using reports 6i, i want to read images of employee from file according to empno. which method should i use, kindly describe me step by step. thanks in advance

  • Will there ever be an upgrade for Lightroom 3 that will work with Nikon d800 NEF files?

    Will there ever be an upgrade to Lightroom 3 that will work with Nikon D800 NEF files?

  • No rotate tool with the Macbook Pro dual screen

    I have hooked up a 2nd screen (22" monitor) to my Macbook pro (OS 10.6.6, 2.4 GHz i5, 4 gb rom) wanting to have the working graphics on the 22" monitor and the photoshop tools on the macbook. While in Photoshop CS5, I attempted to use the rotate tool