Loading ...
Sorry, an error occurred while loading the content.

DECODE function

Expand Messages
  • Luiz Ribeiro
    Hi all. Is there a function in Postgres SQL that results the same DECODE Oracle function? Thanks. Luiz [Non-text portions of this message have been removed]
    Message 1 of 3 , Nov 5, 2008
    • 0 Attachment
      Hi all.

      Is there a function in Postgres SQL that results the same DECODE Oracle
      function?

      Thanks.

      Luiz



      [Non-text portions of this message have been removed]
    • Max Parmenter
      I am not experienced with Postgre SQL but as far as I am aware you need to write your own Instr function - check the documentation at www.
      Message 2 of 3 , Nov 5, 2008
      • 0 Attachment
        I am not experienced with Postgre SQL but as far as I am aware you need to
        write your own Instr function - check the documentation at www.
        <http://www.postgresql.org> postgresql.org

        Good luck!

        _____

        From: SQLQueriesNoCode@yahoogroups.com
        [mailto:SQLQueriesNoCode@yahoogroups.com] On Behalf Of Luiz Ribeiro
        Sent: 05 November 2008 15:06
        To: SQLQueriesNoCode@yahoogroups.com
        Subject: [SQLQueriesNoCode] DECODE function



        Hi all.

        Is there a function in Postgres SQL that results the same DECODE Oracle
        function?

        Thanks.

        Luiz


        [Non-text portions of this message have been removed]






        [Non-text portions of this message have been removed]
      • peternilsson42
        ... DECODE is just shorthand for CASE,[1] which Postgress supports.[2] So, just replace things like... decode(status_fl, C , C , O ) ...with... case when
        Message 3 of 3 , Nov 5, 2008
        • 0 Attachment
          "Luiz Ribeiro" <luiz.ribeiro@...> wrote:
          >
          > Hi all.
          >
          > Is there a function in Postgres SQL that results the
          > same DECODE Oracle function?

          DECODE is just shorthand for CASE,[1] which Postgress
          supports.[2]

          So, just replace things like...

          decode(status_fl, 'C', 'C', 'O')

          ...with...

          case when status_fl = 'C' then 'C' else 'O' end

          [1] Similarly NVL is just shorthand for COALESCE.

          [2] <http://www.postgresql.org/docs/8.2/interactive/functions-
          conditional.html>

          --
          Peter
        Your message has been successfully submitted and would be delivered to recipients shortly.