By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,809 Members | 1,997 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,809 IT Pros & Developers. It's quick & easy.

plpgsql string concatanation

P: n/a
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?

http://archives.postgresql.org

Nov 12 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Martin Marques <ma****@bugs.unl.edu.ar> writes:
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.
Oddly enough, your signature holds the key!
--
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'


-Doug

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

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 12 '05 #2

P: n/a
El Vie 28 Nov 2003 09:04, escribió:
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.


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

Nov 12 '05 #3

P: n/a
El Vie 28 Nov 2003 09:44, Doug McNaught escribió:
Martin Marques <ma****@bugs.unl.edu.ar> writes:
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.


Oddly enough, your signature holds the key!


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

Nov 12 '05 #4

P: n/a
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.

String concatenation is done via the '||' operator see
http://www.postgresql.org/docs/curre...ns-string.html

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

Nov 12 '05 #5

P: n/a
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" <ma****@bugs.unl.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

Nov 12 '05 #6

P: n/a
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.


See my recent post at

http://www.brasileiro.net/postgres/c...ecipe_id=24725

(and in general, everyone here who hasn't looked at
http://www.brasileiro.net/postgres/cookbook/
should review all the great goodies posted there).

~Berend Tober


---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 12 '05 #7

P: n/a
El Vie 28 Nov 2003 10:38, Chris Travers escribió:
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.


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?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 12 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.