plpgsql string concatanation

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Martin Marques

    plpgsql string concatanation

    Is it posible to do string concatanation in plpgsql?

    Somthing like:

    sec := ''some string here'' . NEW.id;

    Is there a way to do this? I need te value of that new string for things that
    come after, and couldn't find much in the PL documentation.

    --
    09:01:02 up 2 days, 15:25, 1 user, load average: 0.17, 0.20, 0.19
    -----------------------------------------------------------------
    Martín Marqués | select 'mmarques' || '@' || 'unl.edu.ar'
    Centro de Telematica | DBA, Programador, Administrador
    Universidad Nacional
    del Litoral
    -----------------------------------------------------------------


    ---------------------------(end of broadcast)---------------------------
    TIP 6: Have you searched our list archives?



  • Doug McNaught

    #2
    Re: plpgsql string concatanation

    Martin Marques <martin@bugs.un l.edu.ar> writes:
    [color=blue]
    > Is it posible to do string concatanation in plpgsql?
    >
    > Somthing like:
    >
    > sec := ''some string here'' . NEW.id;
    >
    > Is there a way to do this? I need te value of that new string for things that
    > come after, and couldn't find much in the PL documentation.[/color]

    Oddly enough, your signature holds the key!
    [color=blue]
    > --
    > 09:01:02 up 2 days, 15:25, 1 user, load average: 0.17, 0.20, 0.19
    > -----------------------------------------------------------------
    > Martín Marqués | select 'mmarques' || '@' || 'unl.edu.ar'[/color]

    -Doug

    ---------------------------(end of broadcast)---------------------------
    TIP 5: Have you checked our extensive FAQ?



    Comment

    • Martin Marques

      #3
      Re: plpgsql string concatanation

      El Vie 28 Nov 2003 09:04, escribió:[color=blue]
      > Is it posible to do string concatanation in plpgsql?
      >
      > Somthing like:
      >
      > sec := ''some string here'' . NEW.id;
      >
      > Is there a way to do this? I need te value of that new string for things
      > that come after, and couldn't find much in the PL documentation.[/color]

      Sorry for the stupid question. I got it, and it was always on MY FACE. :-(

      CONCATENATION, why can't I think simple. ;-)

      --
      09:41:02 up 2 days, 16:05, 1 user, load average: 0.87, 1.19, 0.98
      -----------------------------------------------------------------
      Martín Marqués | select 'mmarques' || '@' || 'unl.edu.ar'
      Centro de Telematica | DBA, Programador, Administrador
      Universidad Nacional
      del Litoral
      -----------------------------------------------------------------


      ---------------------------(end of broadcast)---------------------------
      TIP 9: the planner will ignore your desire to choose an index scan if your
      joining column's datatypes do not match

      Comment

      • Martin Marques

        #4
        Re: plpgsql string concatanation

        El Vie 28 Nov 2003 09:44, Doug McNaught escribió:[color=blue]
        > Martin Marques <martin@bugs.un l.edu.ar> writes:[color=green]
        > > Is it posible to do string concatanation in plpgsql?
        > >
        > > Somthing like:
        > >
        > > sec := ''some string here'' . NEW.id;
        > >
        > > Is there a way to do this? I need te value of that new string for things
        > > that come after, and couldn't find much in the PL documentation.[/color]
        >
        > Oddly enough, your signature holds the key![/color]

        Exactly!!!!
        That makes me fill even worst! :-(

        As I said, it was in front of me, and the tree didn't let me see the
        forest. :-)

        --
        09:43:01 up 2 days, 16:07, 1 user, load average: 1.14, 1.34, 1.07
        -----------------------------------------------------------------
        Martín Marqués | select 'mmarques' || '@' || 'unl.edu.ar'
        Centro de Telematica | DBA, Programador, Administrador
        Universidad Nacional
        del Litoral
        -----------------------------------------------------------------


        ---------------------------(end of broadcast)---------------------------
        TIP 7: don't forget to increase your free space map settings

        Comment

        • Joerg Erdmenger

          #5
          Re: plpgsql string concatanation

          [color=blue]
          > Is it posible to do string concatanation in plpgsql?
          >
          > Somthing like:
          >
          > sec := ''some string here'' . NEW.id;
          >
          > Is there a way to do this? I need te value of that new string for things
          > that come after, and couldn't find much in the PL documentation.[/color]
          String concatenation is done via the '||' operator see
          9.4.&nbsp;String Functions and Operators # 9.4.1. format This section describes functions and operators for examining and manipulating string values. Strings …


          Joerg


          ---------------------------(end of broadcast)---------------------------
          TIP 3: if posting/reading through Usenet, please send an appropriate
          subscribe-nomail command to majordomo@postg resql.org so that your
          message can get through to the mailing list cleanly

          Comment

          • Chris Travers

            #6
            Re: plpgsql string concatanation

            One thing that I always have to remind myself of is this:

            string || NULL is NULL.
            It is usually a good idea to use coalesce() unless you want this to happen.

            Best wishes,
            CHris Travers
            ----- Original Message -----
            From: "Martin Marques" <martin@bugs.un l.edu.ar>

            As I said, it was in front of me, and the tree didn't let me see the
            forest. :-)

            --
            09:43:01 up 2 days, 16:07, 1 user, load average: 1.14, 1.34, 1.07
            -----------------------------------------------------------------
            Martín Marqués | select 'mmarques' || '@' || 'unl.edu.ar'
            Centro de Telematica | DBA, Programador, Administrador
            Universidad Nacional
            del Litoral
            -----------------------------------------------------------------


            ---------------------------(end of broadcast)---------------------------
            TIP 7: don't forget to increase your free space map settings




            ---------------------------(end of broadcast)---------------------------
            TIP 7: don't forget to increase your free space map settings

            Comment

            • btober@seaworthysys.com

              #7
              Re: plpgsql string concatanation

              [color=blue]
              > One thing that I always have to remind myself of is this:
              >
              > string || NULL is NULL.
              > It is usually a good idea to use coalesce() unless you want this to
              > happen.
              >[/color]

              See my recent post at



              (and in general, everyone here who hasn't looked at

              should review all the great goodies posted there).

              ~Berend Tober




              ---------------------------(end of broadcast)---------------------------
              TIP 1: subscribe and unsubscribe commands go to majordomo@postg resql.org

              Comment

              • Martin Marques

                #8
                Re: plpgsql string concatanation

                El Vie 28 Nov 2003 10:38, Chris Travers escribió:[color=blue]
                > One thing that I always have to remind myself of is this:
                >
                > string || NULL is NULL.
                > It is usually a good idea to use coalesce() unless you want this to happen.[/color]

                Pretty nice. :-)
                Even though I don't have that problem, becuase the value comes from a PK
                field.

                --
                11:24:01 up 2 days, 17:48, 1 user, load average: 0.56, 0.62, 0.63
                -----------------------------------------------------------------
                Martín Marqués | select 'mmarques' || '@' || 'unl.edu.ar'
                Centro de Telematica | DBA, Programador, Administrador
                Universidad Nacional
                del Litoral
                -----------------------------------------------------------------


                ---------------------------(end of broadcast)---------------------------
                TIP 5: Have you checked our extensive FAQ?



                Comment

                Working...