Decode Clarification

Is it true that Decode function used only inside of SQL Statement '
declare
i number;
--cursor dept_cursor is select * from dept;
begin
select deptno into i from dept where deptno=10;
-- dbms_output.Put_line();
dbms_output.put_line('Hi'||decode(sql%rowcount,1,'Found','Notfound'));
end;
Should it work or not?

Error Message Description:
PLS-00204 function or pseudo-column 'string' may be used inside a SQL statement only
Cause: A pseudocolumn or proscribed function was used in a procedural statement. The SQL pseudocolumns (CURRVAL, LEVEL, NEXTVAL, ROWID, ROWNUM) can be used only in SQL statements. Likewise, certain functions
such as DECODE, DUMP, and VSIZE and the SQL group functions (AVG, MIN, MAX, COUNT, SUM, STDDEV, VARIANCE) can be used only in SQL statements.
Action: Remove the pseudocolumn reference or function call from the procedural statement. Or, replace the procedural statement with a SELECT INTO statement; for example, replace:
Regards
Imran

Similar Messages

  • Diff between decode and case

    Hi
    I need small clarification about difference between decode and case
    Thanks who visit my thread

    And for those people who can't be ar$ed to follow links...
    Decode allows for conditional output where the conditions are straightforward matches between values.
    Case allows for regular conditions to be used such as greater than, less than etc.
    Some of the things done by case can be achieved through decode as well but in a more convoluted manner than simply using case.
    ;)

  • NEED A FUNCTION WHICH CAN DECODE THE URL

    Hi all,
    I am trying to decode the URL which appears in the address link.
    Please read the following for more clarification:
    On some search engine, I type the search item.
    Say Google is the search engine
    The search criteria that i gave is
    Case 1
    "Human Resources"
    Resulting URL
    "http://www.google.com/search?biw=1003&hl=en&q=Human+Resources"
    Expected result after decoding the URL is
    Human Resource
    Case 2
    Seaechitem http:// oracle
    Result
    http://www.google.com/search?hl=en&lr=&biw=1003&q=http%3A+%2F%2F+oracle
    Expected Result after decoding the URL:
    http:// oracle
    Can anybody suggest me how to achieve this goal using Oracle?
    Is there any function/procedure or any utility available to do it?
    Thanks in advance.
    Himanshu

    Hi,
    You lucky guy... I did something really close to what you need. I modified the code a bit (there might be some glitches) to match your requirements:DECLARE
         ref1 VARCHAR2(1000 CHAR) := 'http://www.google.fr/search?hl=fr\&biw=1280\&q=http%3A+%2F%2F+oracle\&btnG=Rechercher\&meta=';
         ref2 VARCHAR2(1000 CHAR) := 'http://www.google.fr/search?hl=fr\&biw=1280\&q=Human+Resources\&btnG=Rechercher\&meta=';
         FUNCTION hextodec( h IN VARCHAR ) RETURN NUMBER
         AS
              h2 VARCHAR2( 10 );
              i NUMBER( 10 );
              j NUMBER( 2 );
              d NUMBER;
         BEGIN
              h2 := LTRIM( h, '0' );
              d := 0;
              FOR i IN 1 .. LENGTH( h2 )
              LOOP
                   SELECT DECODE( SUBSTR( h2, i, 1 )
                        , '0', 0, '1', 1, '2', 2, '3', 3, '4', 4, '5', 5
                        , '6', 6, '7', 7, '8', 8, '9', 9, 'A', 10
                        , 'B', 11, 'C', 12, 'D', 13, 'E', 14, 'F', 15 )
                        INTO j
                        FROM DUAL;
                   d := 16 * d + j;
              END LOOP;
              RETURN d;
         END hextodec;
         FUNCTION strip(samplevalue IN VARCHAR2) RETURN VARCHAR2
         AS
              finalvalue VARCHAR2(1000 CHAR) := samplevalue;
              decimalvalue NUMBER(2);
              pospct NUMBER;
              extract VARCHAR2(2 CHAR);
         BEGIN
              finalvalue := SUBSTR(finalvalue ,INSTR(finalvalue ,'\&q='));
              finalvalue := SUBSTR(finalvalue ,4);
              finalvalue := SUBSTR(finalvalue ,1,INSTR(finalvalue ,'\&')-1);
              finalvalue := REPLACE(finalvalue ,'+',' ');
              LOOP
                   pospct := INSTR(finalvalue ,'%');
                   EXIT WHEN pospct = 0;
                   extract := SUBSTR(finalvalue ,pospct+1,2);
                   finalvalue  := SUBSTR(finalvalue ,1,pospct-1) || chr(hextodec(extract)) || SUBSTR(finalvalue ,pospct+3);
              END LOOP;
              RETURN finalvalue;
         END;
    BEGIN
         DBMS_OUTPUT.PUT_LINE(strip(ref1));
         DBMS_OUTPUT.PUT_LINE(strip(ref2));
    END;
    /Warning: ESCAPE must be ON in order to do that under SQL*Plus (because of the '&').
    Regards,
    Yoann.

  • Empty row using decode

    when I use the decode function I always get extra empty rows in my results. Why is this? Is it because I don't use a default value?
    I always have to use a where statement to eliminate those empty rows, like in the following statement.
    select
    decode(table.field1,'field1value','output')
    from
    table
    where
    table.field1='field1value'

    Let me try to explain using your example:
    SQL> create table mytable
      2  as
      3  select 'Weight' field1, '2' field2 from dual union all
      4  select 'Colour', 'red' from dual union all
      5  select 'Size', 'L' from dual
      6  /
    Tabel is aangemaakt.So, the table has three rows.
    SQL> select decode(Field1,'Weight',Field2)
      2    from mytable
      3  /
    DEC
    2
    3 rijen zijn geselecteerd.Since you don't have a where clause, you don't restrict the number of rows returned. The row appears empty because of the decode function, which says: "if field1 is equal to 'Weight' then display field2 else display nothing".
    SQL> select field1
      2       , field2
      3       , decode(Field1,'Weight',Field2)
      4       , decode(Field1,'Weight',Field2, field1)
      5    from mytable
      6  /
    FIELD1 FIE DEC DECODE
    Weight 2   2   2
    Colour red     Colour
    Size   L       Size
    3 rijen zijn geselecteerd.This shows that the rows are not empty, only the third column is. The fourth column is a similar decode function but with a fourth argument that additionally says "if field1 is not equal to 'Weight' then show me field1 instead of field2"
    But I guess you really want one row, the row containing 'Weight', which can be easily achieved by a where clause:
    SQL> select field2
      2    from mytable
      3   where field1 = 'Weight'
      4  /
    FIE
    2
    1 rij is geselecteerd.Hope this clarifies.
    Regards,
    Rob.

  • IoEO - Conceptual Clarifications

    Hi All,
    I need few clarifications and perception of everyone who reads this thread.
    I need to understand the significance or the importance of EO. Per my observation there are very less EOs created actually. The VOs are most of the times built on PL/SQL query.
    When everything can be done without the presence of EO, then why should one have it. Is there a specific scenario where the application cannot do without it?
    For DML operations, we normally use :OraclePreparedStatements and OracleCallableStatements in the COs directly.
    Any quick response will be greatly appreciated.

    Hi,
    1. It would depend on the factors prevailing at the moment. May be when the forms were developed Oracle preferred to reuse the existing PLSQL APIs created for forms and avoid the effort to replicate all the logic and validations in the EO. But that is one of my guesses and frankly I dont know why Oracle did so.
    2. You can definitely write Joins and Decode statements in the VO (based on EOs) but remember that the calculated column (decode columns) can only fetch data. If you associate a field to one of the calculated attributes, your values would not be saved into the database. You would be able to save only those values which are directly based on the EO attributes which in further have one-on-one mapping with the Database table.
    Hope that clarifies.
    Regards
    Sumit

  • Does the X-Fi Champion Series do Digital decodi

    I am looking for a new soundcard, and the XFi Platinum Fatalty Champion Series is on the top of my list.However, after searching every specification site I could find, and browsing/searching through this forum, I still am not completely sure if the soundcard does Digital Decoding by itself or not. (if I were to plug a digital input in the optical, will I be able to listen to this through my analoge 7. speakerset?)?Many thanks in advance, any clarification on the subject is appreciated.Message Edited by eelco on 07-24-20070:34 PM

    Or would the software be able to decode the digital input, even not when playing a movie?Else I see no use for digital input on the I/O box...
    No, the software does not decode from the digital input.Digital input on that card can be used for stereo PCM signals. Search the net for hacked drivers.. who knows

  • Logical Operations in SQL decode function ?

    Hi,
    Is it possible to do Logical Operations in SQL decode function
    like
    '>'
    '<'
    '>='
    '<='
    '<>'
    not in
    in
    not null
    is null
    eg...
    select col1 ,order_by,decode ( col1 , > 10 , 0 , 1)
    from tab;
    select col1 ,order_by,decode ( col1 , <> 10 , 0 , 1)
    from tab;
    select col1 ,order_by,decode ( col1 , not in (10,11,12) , 0 , 1)
    from tab;
    select col1 ,order_by,decode ( col1 ,is null , 0 , 1)
    from tab;
    Regards,
    infan
    Edited by: user780731 on Apr 30, 2009 12:07 AM
    Edited by: user780731 on Apr 30, 2009 12:07 AM
    Edited by: user780731 on Apr 30, 2009 12:08 AM
    Edited by: user780731 on Apr 30, 2009 12:08 AM
    Edited by: user780731 on Apr 30, 2009 12:09 AM

    example:
    select col1 ,order_by,case when col1 > 10 then 0 else 1 end
    from tab;
    select col1 ,order_by,case when col1 &lt;&gt; 10 then 0 else 1 end
    from tab;
    select col1 ,order_by,case when col1 not in (10,11,12) then 0 else 1 end
    from tab;As for testing for null, decode handles that by default anyway so you can have decode or case easily..
    select col1 ,order_by,decode (col1, null , 0 , 1)
    from tab;
    select col1 ,order_by,case when col1 is null then 0 else 1 end
    from tab;

  • USING NULL AND SELECT ALL IN DECODE

    COL1 has the following values:
    COL1
    ====
    A
    B
    C
    A
    B
    C
    A
    D
    D
    SELECT COL1 FROM TABLE1 WHERE COL1 =
    DECODE(:VAL1, 'A', 'AA', 'B', 'BB', 'C', 'CC', 'D', 'DD')
    1. what about the null values ? how can I add to the above statements when I enter null for the parameter :VAL1
    2. what about all the values in COL1, what shall I enter for :VAL1 ?
    THANKS.

    SELECT COL1 FROM TABLE1
    WHERE nvl(COL1,0) = DECODE(:VAL1, 'A', 'AA', 'B', 'BB', 'C', 'CC', 'D', 'DD',null,0)
    Can we use in this way?
    Shishu Paul
    Chandigarh-India

  • Clearing values from request in decode method

    I am using a custom table paginator. In its ‘decode’ method I have the next code to control whether ‘next’ link is clicked:
    String pLink = (String)requestMap.get("pLink" + clientId);
    if ((pLink != null) && (!pLink.equals(""))) {
         if (pLink.equals("next")) {     
         } else if (pLink.equals("previous")) {
    }But the next sequence produces some problems:
    1.     Initial page load.
    2.     Click on ‘next’ link.
    3.     Table navigates ok to next page.
    4.     Reload page (push F5).
    5.     The previous click still remains in the request, so decode method think ‘next’ link is pressed again.
    6.     Application abnormal behaviour arises.
    So, I am trying to clear the ‘next_link’ key from the request, but next code throws an UnsupportedOperationException:
    String pLink = (String)requestMap.get("pLink" + clientId);
    if ((pLink != null) && (!pLink.equals(""))) {
         if (pLink.equals("next")) {     
         } else if (pLink.equals("previous")) {
         requestMap.put("pLink" + clientId, "");
    }Do any of you have some ideas?

    Hey, where are you RaymondDeCampo, rLubke, BalusC ... the masters of JSF Universe?
    ;-)

  • GIF decoding

    This works on WinXP but not Linux. Why? It takes the first frame of an animated gif and writes a thumbnail.
                GifDecoder d = new GifDecoder();    
                try {
                    fis = new FileInputStream(file);          
                    bis = new BufferedInputStream(fis);            
                    log.debug("reading gif");
                    d.read(bis);
                    log.debug("reading framecount");
                    int n = d.getFrameCount();
                    log.debug("read framecount" + n);
                    for (int i = 0; i < 1; i++) {
                        BufferedImage frame = d.getFrame(i);  // frame i
                        int t = d.getDelay(i);  // display duration of frame in milliseconds
                        log.debug("resizing frame");
                            File gifoutputfile = new File("gif" + i + outputthumbFilename);
                        BufferedImage bdest = new BufferedImage(60, 60, BufferedImage.TYPE_INT_RGB);
                        Graphics2D g = bdest.createGraphics();
                        AffineTransform at = AffineTransform.getScaleInstance((double) 60 / frame.getWidth(), (double) 60 / frame.getHeight());
                        g.drawRenderedImage(frame, at);
                        ImageIO.setUseCache(false);
                        ImageIO.write(bdest, "GIF", new File(outputthumbFilename));           
                } catch (FileNotFoundException e) {
                    e.printStackTrace();
                } catch (IOException e) {
                    e.printStackTrace();
    import java.awt.AlphaComposite;
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.Graphics2D;
    import java.awt.Rectangle;
    import java.awt.image.BufferedImage;
    import java.awt.image.DataBufferInt;
    import java.io.BufferedInputStream;
    import java.io.FileInputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.net.URL;
    import java.util.ArrayList;
    * Class GifDecoder - Decodes a GIF file into one or more frames. <br>
    * <pre>
    *  Example:
    *     GifDecoder d = new GifDecoder();
    *     d.read("sample.gif");
    *     int n = d.getFrameCount();
    *     for (int i = 0; i < n; i++) {
    *        BufferedImage frame = d.getFrame(i);  // frame i
    *        int t = d.getDelay(i);  // display duration of frame in milliseconds
    *        // do something with frame
    * </pre>
    * No copyright asserted on the source code of this class. May be used for any
    * purpose, however, refer to the Unisys LZW patent for any additional
    * restrictions. Please forward any corrections to [email protected].
    * @author Kevin Weiner, FM Software; LZW decoder adapted from John Cristy's
    *         ImageMagick.
    * @version 1.03 November 2003
    public class GifDecoder {
       * File read status: No errors.
      public static final int STATUS_OK = 0;
       * File read status: Error decoding file (may be partially decoded)
      public static final int STATUS_FORMAT_ERROR = 1;
       * File read status: Unable to open source.
      public static final int STATUS_OPEN_ERROR = 2;
      protected BufferedInputStream in;
      protected int status;
      protected int width; // full image width
      protected int height; // full image height
      protected boolean gctFlag; // global color table used
      protected int gctSize; // size of global color table
      protected int loopCount = 1; // iterations; 0 = repeat forever
      protected int[] gct; // global color table
      protected int[] lct; // local color table
      protected int[] act; // active color table
      protected int bgIndex; // background color index
      protected int bgColor; // background color
      protected int lastBgColor; // previous bg color
      protected int pixelAspect; // pixel aspect ratio
      protected boolean lctFlag; // local color table flag
      protected boolean interlace; // interlace flag
      protected int lctSize; // local color table size
      protected int ix, iy, iw, ih; // current image rectangle
      protected Rectangle lastRect; // last image rect
      protected BufferedImage image; // current frame
      protected BufferedImage lastImage; // previous frame
      protected byte[] block = new byte[256]; // current data block
      protected int blockSize = 0; // block size
      // last graphic control extension info
      protected int dispose = 0;
      // 0=no action; 1=leave in place; 2=restore to bg; 3=restore to prev
      protected int lastDispose = 0;
      protected boolean transparency = false; // use transparent color
      protected int delay = 0; // delay in milliseconds
      protected int transIndex; // transparent color index
      protected static final int MaxStackSize = 4096;
      // max decoder pixel stack size
      // LZW decoder working arrays
      protected short[] prefix;
      protected byte[] suffix;
      protected byte[] pixelStack;
      protected byte[] pixels;
      protected ArrayList frames; // frames read from current file
      protected int frameCount;
      static class GifFrame {
        public GifFrame(BufferedImage im, int del) {
          image = im;
          delay = del;
        public BufferedImage image;
        public int delay;
       * Gets display duration for specified frame.
       * @param n
       *          int index of frame
       * @return delay in milliseconds
      public int getDelay(int n) {
        delay = -1;
        if ((n >= 0) && (n < frameCount)) {
          delay = ((GifFrame) frames.get(n)).delay;
        return delay;
       * Gets the number of frames read from file.
       * @return frame count
      public int getFrameCount() {
        return frameCount;
       * Gets the first (or only) image read.
       * @return BufferedImage containing first frame, or null if none.
      public BufferedImage getImage() {
        return getFrame(0);
       * Gets the "Netscape" iteration count, if any. A count of 0 means repeat
       * indefinitiely.
       * @return iteration count if one was specified, else 1.
      public int getLoopCount() {
        return loopCount;
       * Creates new frame image from current data (and previous frames as specified
       * by their disposition codes).
      protected void setPixels() {
        // expose destination image's pixels as int array
        int[] dest = ((DataBufferInt) image.getRaster().getDataBuffer()).getData();
        // fill in starting image contents based on last image's dispose code
        if (lastDispose > 0) {
          if (lastDispose == 3) {
            // use image before last
            int n = frameCount - 2;
            if (n > 0) {
              lastImage = getFrame(n - 1);
            } else {
              lastImage = null;
          if (lastImage != null) {
            int[] prev = ((DataBufferInt) lastImage.getRaster().getDataBuffer()).getData();
            System.arraycopy(prev, 0, dest, 0, width * height);
            // copy pixels
            if (lastDispose == 2) {
              // fill last image rect area with background color
              Graphics2D g = image.createGraphics();
              Color c = null;
              if (transparency) {
                c = new Color(0, 0, 0, 0); // assume background is transparent
              } else {
                c = new Color(lastBgColor); // use given background color
              g.setColor(c);
              g.setComposite(AlphaComposite.Src); // replace area
              g.fill(lastRect);
              g.dispose();
        // copy each source line to the appropriate place in the destination
        int pass = 1;
        int inc = 8;
        int iline = 0;
        for (int i = 0; i < ih; i++) {
          int line = i;
          if (interlace) {
            if (iline >= ih) {
              pass++;
              switch (pass) {
              case 2:
                iline = 4;
                break;
              case 3:
                iline = 2;
                inc = 4;
                break;
              case 4:
                iline = 1;
                inc = 2;
            line = iline;
            iline += inc;
          line += iy;
          if (line < height) {
            int k = line * width;
            int dx = k + ix; // start of line in dest
            int dlim = dx + iw; // end of dest line
            if ((k + width) < dlim) {
              dlim = k + width; // past dest edge
            int sx = i * iw; // start of line in source
            while (dx < dlim) {
              // map color and insert in destination
              int index = ((int) pixels[sx++]) & 0xff;
              int c = act[index];
              if (c != 0) {
                dest[dx] = c;
              dx++;
       * Gets the image contents of frame n.
       * @return BufferedImage representation of frame, or null if n is invalid.
      public BufferedImage getFrame(int n) {
        BufferedImage im = null;
        if ((n >= 0) && (n < frameCount)) {
          im = ((GifFrame) frames.get(n)).image;
        return im;
       * Gets image size.
       * @return GIF image dimensions
      public Dimension getFrameSize() {
        return new Dimension(width, height);
       * Reads GIF image from stream
       * @param BufferedInputStream
       *          containing GIF file.
       * @return read status code (0 = no errors)
      public int read(BufferedInputStream is) {
        init();
        if (is != null) {
          in = is;
          readHeader();
          if (!err()) {
            readContents();
            if (frameCount < 0) {
              status = STATUS_FORMAT_ERROR;
        } else {
          status = STATUS_OPEN_ERROR;
        try {
          is.close();
        } catch (IOException e) {
        return status;
       * Reads GIF image from stream
       * @param InputStream
       *          containing GIF file.
       * @return read status code (0 = no errors)
      public int read(InputStream is) {
        init();
        if (is != null) {
          if (!(is instanceof BufferedInputStream))
            is = new BufferedInputStream(is);
          in = (BufferedInputStream) is;
          readHeader();
          if (!err()) {
            readContents();
            if (frameCount < 0) {
              status = STATUS_FORMAT_ERROR;
        } else {
          status = STATUS_OPEN_ERROR;
        try {
          is.close();
        } catch (IOException e) {
        return status;
       * Reads GIF file from specified file/URL source (URL assumed if name contains
       * ":/" or "file:")
       * @param name
       *          String containing source
       * @return read status code (0 = no errors)
      public int read(String name) {
        status = STATUS_OK;
        try {
          name = name.trim().toLowerCase();
          if ((name.indexOf("file:") >= 0) || (name.indexOf(":/") > 0)) {
            URL url = new URL(name);
            in = new BufferedInputStream(url.openStream());
          } else {
            in = new BufferedInputStream(new FileInputStream(name));
          status = read(in);
        } catch (IOException e) {
          status = STATUS_OPEN_ERROR;
        return status;
       * Decodes LZW image data into pixel array. Adapted from John Cristy's
       * ImageMagick.
      protected void decodeImageData() {
        int NullCode = -1;
        int npix = iw * ih;
        int available, clear, code_mask, code_size, end_of_information, in_code, old_code, bits, code, count, i, datum, data_size, first, top, bi, pi;
        if ((pixels == null) || (pixels.length < npix)) {
          pixels = new byte[npix]; // allocate new pixel array
        if (prefix == null)
          prefix = new short[MaxStackSize];
        if (suffix == null)
          suffix = new byte[MaxStackSize];
        if (pixelStack == null)
          pixelStack = new byte[MaxStackSize + 1];
        // Initialize GIF data stream decoder.
        data_size = read();
        clear = 1 << data_size;
        end_of_information = clear + 1;
        available = clear + 2;
        old_code = NullCode;
        code_size = data_size + 1;
        code_mask = (1 << code_size) - 1;
        for (code = 0; code < clear; code++) {
          prefix[code] = 0;
          suffix[code] = (byte) code;
        // Decode GIF pixel stream.
        datum = bits = count = first = top = pi = bi = 0;
        for (i = 0; i < npix;) {
          if (top == 0) {
            if (bits < code_size) {
              // Load bytes until there are enough bits for a code.
              if (count == 0) {
                // Read a new data block.
                count = readBlock();
                if (count <= 0)
                  break;
                bi = 0;
              datum += (((int) block[bi]) & 0xff) << bits;
              bits += 8;
              bi++;
              count--;
              continue;
            // Get the next code.
            code = datum & code_mask;
            datum >>= code_size;
            bits -= code_size;
            // Interpret the code
            if ((code > available) || (code == end_of_information))
              break;
            if (code == clear) {
              // Reset decoder.
              code_size = data_size + 1;
              code_mask = (1 << code_size) - 1;
              available = clear + 2;
              old_code = NullCode;
              continue;
            if (old_code == NullCode) {
              pixelStack[top++] = suffix[code];
              old_code = code;
              first = code;
              continue;
            in_code = code;
            if (code == available) {
              pixelStack[top++] = (byte) first;
              code = old_code;
            while (code > clear) {
              pixelStack[top++] = suffix[code];
              code = prefix[code];
            first = ((int) suffix[code]) & 0xff;
            // Add a new string to the string table,
            if (available >= MaxStackSize)
              break;
            pixelStack[top++] = (byte) first;
            prefix[available] = (short) old_code;
            suffix[available] = (byte) first;
            available++;
            if (((available & code_mask) == 0) && (available < MaxStackSize)) {
              code_size++;
              code_mask += available;
            old_code = in_code;
          // Pop a pixel off the pixel stack.
          top--;
          pixels[pi++] = pixelStack[top];
          i++;
        for (i = pi; i < npix; i++) {
          pixels[i] = 0; // clear missing pixels
       * Returns true if an error was encountered during reading/decoding
      protected boolean err() {
        return status != STATUS_OK;
       * Initializes or re-initializes reader
      protected void init() {
        status = STATUS_OK;
        frameCount = 0;
        frames = new ArrayList();
        gct = null;
        lct = null;
       * Reads a single byte from the input stream.
      protected int read() {
        int curByte = 0;
        try {
          curByte = in.read();
        } catch (IOException e) {
          status = STATUS_FORMAT_ERROR;
        return curByte;
       * Reads next variable length block from input.
       * @return number of bytes stored in "buffer"
      protected int readBlock() {
        blockSize = read();
        int n = 0;
        if (blockSize > 0) {
          try {
            int count = 0;
            while (n < blockSize) {
              count = in.read(block, n, blockSize - n);
              if (count == -1)
                break;
              n += count;
          } catch (IOException e) {
          if (n < blockSize) {
            status = STATUS_FORMAT_ERROR;
        return n;
       * Reads color table as 256 RGB integer values
       * @param ncolors
       *          int number of colors to read
       * @return int array containing 256 colors (packed ARGB with full alpha)
      protected int[] readColorTable(int ncolors) {
        int nbytes = 3 * ncolors;
        int[] tab = null;
        byte[] c = new byte[nbytes];
        int n = 0;
        try {
          n = in.read(c);
        } catch (IOException e) {
        if (n < nbytes) {
          status = STATUS_FORMAT_ERROR;
        } else {
          tab = new int[256]; // max size to avoid bounds checks
          int i = 0;
          int j = 0;
          while (i < ncolors) {
            int r = ((int) c[j++]) & 0xff;
            int g = ((int) c[j++]) & 0xff;
            int b = ((int) c[j++]) & 0xff;
            tab[i++] = 0xff000000 | (r << 16) | (g << 8) | b;
        return tab;
       * Main file parser. Reads GIF content blocks.
      protected void readContents() {
        // read GIF file content blocks
        boolean done = false;
        while (!(done || err())) {
          int code = read();
          switch (code) {
          case 0x2C: // image separator
            readImage();
            break;
          case 0x21: // extension
            code = read();
            switch (code) {
            case 0xf9: // graphics control extension
              readGraphicControlExt();
              break;
            case 0xff: // application extension
              readBlock();
              String app = "";
              for (int i = 0; i < 11; i++) {
                app += (char) block;
    if (app.equals("NETSCAPE2.0")) {
    readNetscapeExt();
    } else
    skip(); // don't care
    break;
    default: // uninteresting extension
    skip();
    break;
    case 0x3b: // terminator
    done = true;
    break;
    case 0x00: // bad byte, but keep going and see what happens
    break;
    default:
    status = STATUS_FORMAT_ERROR;
    * Reads Graphics Control Extension values
    protected void readGraphicControlExt() {
    read(); // block size
    int packed = read(); // packed fields
    dispose = (packed & 0x1c) >> 2; // disposal method
    if (dispose == 0) {
    dispose = 1; // elect to keep old image if discretionary
    transparency = (packed & 1) != 0;
    delay = readShort() * 10; // delay in milliseconds
    transIndex = read(); // transparent color index
    read(); // block terminator
    * Reads GIF file header information.
    protected void readHeader() {
    String id = "";
    for (int i = 0; i < 6; i++) {
    id += (char) read();
    if (!id.startsWith("GIF")) {
    status = STATUS_FORMAT_ERROR;
    return;
    readLSD();
    if (gctFlag && !err()) {
    gct = readColorTable(gctSize);
    bgColor = gct[bgIndex];
    * Reads next frame image
    protected void readImage() {
    ix = readShort(); // (sub)image position & size
    iy = readShort();
    iw = readShort();
    ih = readShort();
    int packed = read();
    lctFlag = (packed & 0x80) != 0; // 1 - local color table flag
    interlace = (packed & 0x40) != 0; // 2 - interlace flag
    // 3 - sort flag
    // 4-5 - reserved
    lctSize = 2 << (packed & 7); // 6-8 - local color table size
    if (lctFlag) {
    lct = readColorTable(lctSize); // read table
    act = lct; // make local table active
    } else {
    act = gct; // make global table active
    if (bgIndex == transIndex)
    bgColor = 0;
    int save = 0;
    if (transparency) {
    save = act[transIndex];
    act[transIndex] = 0; // set transparent color if specified
    if (act == null) {
    status = STATUS_FORMAT_ERROR; // no color table defined
    if (err())
    return;
    decodeImageData(); // decode pixel data
    skip();
    if (err())
    return;
    frameCount++;
    // create new image to receive frame data
    image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB_PRE);
    setPixels(); // transfer pixel data to image
    frames.add(new GifFrame(image, delay)); // add image to frame list
    if (transparency) {
    act[transIndex] = save;
    resetFrame();
    * Reads Logical Screen Descriptor
    protected void readLSD() {
    // logical screen size
    width = readShort();
    height = readShort();
    // packed fields
    int packed = read();
    gctFlag = (packed & 0x80) != 0; // 1 : global color table flag
    // 2-4 : color resolution
    // 5 : gct sort flag
    gctSize = 2 << (packed & 7); // 6-8 : gct size
    bgIndex = read(); // background color index
    pixelAspect = read(); // pixel aspect ratio
    * Reads Netscape extenstion to obtain iteration count
    protected void readNetscapeExt() {
    do {
    readBlock();
    if (block[0] == 1) {
    // loop count sub-block
    int b1 = ((int) block[1]) & 0xff;
    int b2 = ((int) block[2]) & 0xff;
    loopCount = (b2 << 8) | b1;
    } while ((blockSize > 0) && !err());
    * Reads next 16-bit value, LSB first
    protected int readShort() {
    // read 16-bit value, LSB first
    return read() | (read() << 8);
    * Resets frame state for reading next image.
    protected void resetFrame() {
    lastDispose = dispose;
    lastRect = new Rectangle(ix, iy, iw, ih);
    lastImage = image;
    lastBgColor = bgColor;
    int dispose = 0;
    boolean transparency = false;
    int delay = 0;
    lct = null;
    * Skips variable length blocks up to and including next zero length block.
    protected void skip() {
    do {
    readBlock();
    } while ((blockSize > 0) && !err());
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     

    Niklas wrote:
    This works on WinXP but not Linux. Why? Please don't just post reams of code without providing more context and information.
    How is it failing on Linux? Wrong results? What are they? Error messages? What do they say? You need to give us some place to start looking.

  • Domain Guideance and Clarification using SVN and an Export suggestion

    Hello Oracle SQL Data Modeler Support,
    Apologies if this has been documented somehwere and I have missed reading it, but have gone through the User Guide and cannot find the clarification I want regarding domains.
    1) WHAT IS BEST PRACTICE TO SAVE WHEN USING SVN
    From the forum I have picked up that the domains file is in the following directory:
    ~\datamodeler\datamodeler\types
    File name is 'defaultdomains.xml'
    When I come to save the file using SVN I get 'Choose versioned folder for storing system types'
    I assume this is where the domains file is stored.
    I require the Domains to be avialable centrally to all Designs I create, what should I do?
    a) Set the folder to ~\datamodeler\datamodeler\types
    b) Create a design called 'Domains' and store it in this folder
    c) Any thing you may suggest
    2) EXPORT OF DOMAIN FILE SUGGESTION
    This should be a quick win for you, can you please add an Export Domains function, seems this needs to do no more than make a copy of the defaultdomains.xml file and create it in a specified export directory.
    Will avoid having to go through the forum to pick up that the defaultdomains.xml file needs to be copied and transfered over for new SQL Data Modeler installations.

    Hello,
    I require the Domains to be avialable centrally to all Designs I create, what should I do?Default location is fine if SVN is not used and if all designs are used only on that computer.
    If versioning is used then it's better to have separate directory for domains and this directory shouldn't be part of any design's directory - i.e. for designs you can have directories c:\des_1, c:\des_2 ...c:\des_n - one directory per each design and that directory will contain design DMD file and design folder. For domains you can have directory c:\DM_Sys_types and you need to set this directory in "Tools>Preferences>Data Modeler>system types directory" - logical types, RDBMS sites and scripts also will be stored there.
    Philip

  • Who can decode this who ever can I will give 4 dukes cause thats all i have

    who ever is the first to decode this and tell me what it says I will give you 4 duke dollars since that is all I have here it is
    vs.vo.~

    seeing something
    vszz}.vss

  • SQL Expression in decode function or case statement?

    Can I put SQL expressions in decode function or case statement?
    For example,
    select le.profile, decode( select count(1) from profile_data where NAME= 'XXXX_AFTER' and object_id = le.profile, 0, 'N', 'Y')
    from element le;
    or
    select le.profile, case WHEN ( select count(1) from profile_data where NAME= 'XXXX_AFTER' and object_id = le.profile) = 0 THEN 'N'
    ELSE 'Y'
    from element le;
    None of the above work.
    Can anyone tell me how to make it work?
    Is there any workaround?
    Thanks,
    J

    You simply needed and END to your CASE statement;
    SQL> with profile_data as (
       select 'XXXX_AFTER' name, 1 object_id from dual),
         element as (
       select 1 profile from dual union all
       select 2 from dual)
    select le.profile,
       case WHEN ( select count(1) from profile_data where NAME= 'XXXX_AFTER' and object_id = le.profile) = 0
       THEN 'N'
       ELSE 'Y'
       END new_col
    from element le
       PROFILE N
             1 Y
             2 N

  • Decode help in SQL function

    Hi,
    I'm writing an HTMLDB application that we will be using to track the number of hours that we put into a project (all projects), and I've got a routine that returns the number of hours that are possible within a given month M-F 8 hours a day. I use this value returned to indicate how many hours have been enterered.
    SELECT null link, 'Still Unrecorded' itsrdescr,trueworkdays(:P80_START,:P80_END)*8-(select sum(hoursworked) ihoursworked from workdetail wd, breakdowns b
    WHERE wd.workdetailid = b.itsrnum and b.oid = upper(:P80_DEVELOPER) and dateworked between :P80_START and :P80_END) hoursworked
    from dual
    UNION
    SELECT null link, wd.itsrdescr,sum(b.hoursworked) hoursworked
    FROM workdetail wd, breakdowns b
    WHERE wd.workdetailid = b.itsrnum and b.oid = upper(:P80_DEVELOPER) and dateworked between :P80_START and :P80_END
    GROUP by wd.itsrdescr
    ORDER by hoursworked desc
    What I'm wanting is something along the lines of this:
    SELECT null link, 'Still Unrecorded' itsrdescr,decode((trueworkdays(:P80_START,:P80_END)*8-(select sum(hoursworked) ihoursworked from workdetail wd, breakdowns b
    WHERE wd.workdetailid = b.itsrnum and b.oid = upper(:P80_DEVELOPER) and dateworked between :P80_START and :P80_END)),<0,0,?????????) hoursworked
    from dual
    UNION
    SELECT null link, wd.itsrdescr,sum(b.hoursworked) hoursworked
    FROM workdetail wd, breakdowns b
    WHERE wd.workdetailid = b.itsrnum and b.oid = upper(:P80_DEVELOPER) and dateworked between :P80_START and :P80_END
    GROUP by wd.itsrdescr
    ORDER by hoursworked desc
    which will include a decode statement to let me know when the value getting returned into hoursworked on that first column is less than zero which throws off the chart. In this particular case, it has a value of -6 which makes all my percentages go haywire. How would one code this statement to include a decode statement to find out if that sum is returning a negative number?
    Hope this made sense,
    TIA,
    cliff

    Hey Tyler,
    Actually.... It kinda killed the server. I'm trying to figure out a way to get the following functionality in a different way. Here is the way that the query turned out using the case statement.
    SELECT null link, '<b><font color="red">Still Unrecorded</font></b>' itsrdescr,
    (case
    when (trueworkdays(:P80_START,:P80_END)*8-(select sum(hoursworked) ihoursworked from workdetail wd, breakdowns b
    WHERE wd.workdetailid = b.itsrnum and b.oid = upper(:P80_DEVELOPER) and dateworked between :P80_START and :P80_END)) < 0 then 0
    else
    (trueworkdays(:P80_START,:P80_END)*8-(select sum(hoursworked) ihoursworked from workdetail wd, breakdowns b
    WHERE wd.workdetailid = b.itsrnum and b.oid = upper(:P80_DEVELOPER) and dateworked between :P80_START and :P80_END))
    end) hoursworked
    from dual
    UNION
    SELECT null link, wd.itsrdescr,sum(b.hoursworked) hoursworked
    FROM workdetail wd, breakdowns b
    WHERE wd.workdetailid = b.itsrnum and b.oid = upper(:P80_DEVELOPER) and dateworked between :P80_START and :P80_END
    GROUP by wd.itsrdescr
    ORDER by hoursworked desc
    Any tips on what I could do to get the above functionality without killing my server.
    Thx for the input
    cliff

  • SQL DECODE function

    Oracle version: 9.2.0.1.0
    Procob version: 9.2.0.1.0
    Cobol version: 3.1.11
    O.S. version: Windows XP
    We have a pro*cobol file with the next conversion rule into a select defined with a cursor.
    NVL(TO_CHAR(A.F_ALTA,'YYYYMMDD'),' '),     
    NVL(TO_CHAR(A.F_ESTADO,'YYYYMMDD'),' '),
    we store the result data through a fetch of the cursor into two variables (W-F-ALTA and W-F-ESTADO) When the program executes an insert of these two values in a target table, we define the next conversion rule:
    TO_DATE(DECODE(:W-F-ALTA,' ',NULL,:W-F-ALTA),'YYYYMMDD'),
    TO_DATE(DECODE(:W-F-ESTADO,' ',NULL,:W-F-ESTADO),'YYYYMMDD')
    Pro*Cobol and Cobol does not have errors when we precompile and compile the program but, when we execute the generated exe file, Oracle displays the next error:
    ORA-01841 (full) year must be between -4713 and +9999, and not be 0
    We think that the DECODE function is not understood by the cobol or pro*cobol interpreter. If we execute the same code without the DECODE function (only with TO_DATE function) there is no errors in the execution of the program
    somebody knows if there are reported problems with this DECODE function in Pro*Cobol or Cobol and how to solve them?
    Thanks

    TO_DATE(DECODE(:W-F-ALTA,' ',NULL,:W-F-ALTA),'YYYYMMDD'),
    TO_DATE(DECODE(:W-F-ESTADO,' ',NULL,:W-F-ESTADO),'YYYYMMDD')The problem is with the input values of :W-F-ALTA and :W-F-ESTADO. Using the first line as an example, what you are saying is if :W-F-ALTA is ' ', substitute it with NULL, any other value should be :W-F-ALTA, then output the TO_DATE value of whatever the result is.
    So if the value of :W-F-ALTA is the wrong charater or in the wrong input format, TO_DATE function does not understand it.
    See examples of success and failures below with your Bind variables substituted with typical values.
    SQL> select TO_DATE(DECODE(' ',' ',NULL,'20060830'),'YYYYMMDD') from dual;
    TO_DATE(D
    SQL> select TO_DATE(DECODE('1999-01-01',' ','NULL','20060830'),'YYYYMMDD') from dual;
    TO_DATE(D
    30-AUG-06
    SQL> select TO_DATE(DECODE('SHOULD_ERROR',' ','NULL','SHOULD_ERROR'),'YYYYMMDD') from dual;
    select TO_DATE(DECODE('SHOULD_ERROR',' ','NULL','SHOULD_ERROR'),'YYYYMMDD') from dual
    ERROR at line 1:
    ORA-01841: (full) year must be between -4713 and +9999, and not be 0
    SQL> select TO_DATE(DECODE('20060830',' ','NULL','20060830'),'YYYYMMDD') from dual;
    TO_DATE(D
    30-AUG-06
    SQL> select TO_DATE(DECODE('12345678',' ','NULL','12345678'),'YYYYMMDD') from dual;
    select TO_DATE(DECODE('12345678',' ','NULL','12345678'),'YYYYMMDD') from dual
    ERROR at line 1:
    ORA-01843: not a valid month
    SQL>

Maybe you are looking for