472,342 Members | 1,321 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,342 software developers and data experts.

CONCAT function

Hello,
As I'm in the middle of the migration process form mysql to pg I found
that there is no CONCAT function which is available in mysql. Can
anybody tell me how to implement this function using plPERL or plPGSQL
language ?
Best wishes,
ML


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

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

Nov 11 '05 #1
12 57304
On Tuesday 16 September 2003 13:45, Marek Lewczuk wrote:
Hello,
As I'm in the middle of the migration process form mysql to pg I found
that there is no CONCAT function which is available in mysql. Can
anybody tell me how to implement this function using plPERL or plPGSQL
language ?


You want to use the || operator, e.g. 'hello' || ' ' || 'world'

Full details of operators and functions can be found in the "data types"
section of the documentation.

--
Richard Huxton
Archonet Ltd

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 11 '05 #2
>
You want to use the || operator, e.g. 'hello' || ' ' || 'world'


I know that, but in my application (which is working on MySQL now) I
have many querys which use CONCAT function, so I need to implement this
function is PG - there is no possibility to replace (in short time) all
of my querys.


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

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

Nov 11 '05 #3
On 16 Sep 2003 at 14:36, Marek Lewczuk wrote:

You want to use the || operator, e.g. 'hello' || ' ' || 'world'


I know that, but in my application (which is working on MySQL now) I
have many querys which use CONCAT function, so I need to implement this
function is PG - there is no possibility to replace (in short time) all
of my querys.


Write your own function..

something like

text concat(text,text)

return text1 || text2

Check up the syntax but you got the idea..

Bye
Shridhar

--
Friends, n.: People who borrow your books and set wet glasses on them. People
who know you well, but like you anyway.
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)

Nov 11 '05 #4
>
text concat(text,text)

return text1 || text2


If it would be so simple I would not write to this group. You see,
CONCAT function doesn't have any arguments limitations, so there could
be one, two or more arguments. And this is my problem, how to write
function without given arguments number.


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

Nov 11 '05 #5
In the last exciting episode, ne***@lewczuk.com ("Marek Lewczuk") wrote:
You want to use the || operator, e.g. 'hello' || ' ' || 'world'


I know that, but in my application (which is working on MySQL now) I
have many querys which use CONCAT function, so I need to implement this
function is PG - there is no possibility to replace (in short time) all
of my querys.


Well, then you might implement "CONCAT" in plpgsql.

It will presumably take two values (possibly text, possibly generic),
use ||, inside the function, to catenate them, and then return a text
value.

That should be quite straightforward.
--
wm(X,Y):-write(X),write('@'),write(Y). wm('cbbrowne','ntlug.org').
http://cbbrowne.com/info/lisp.html
Rules of the Evil Overlord #220. "Whatever my one vulnerability is, I
will fake a different one. For example, ordering all mirrors removed
from the palace, screaming and flinching whenever someone accidentally
holds up a mirror, etc. In the climax when the hero whips out a mirror
and thrusts it at my face, my reaction will be ``Hmm...I think I need
a shave.''" <http://www.eviloverlord.com/>
Nov 11 '05 #6
Search the recent archives for "DECODE" and "NVL" (those are Oracle
functions, but people had he same problems with them as you with
CONCAT).
The basic idea is that in postgres you can overload functions, so you
can create more versions of the function with different parameter
counts/types. Just make sure you implement all the variations you use in
your code.

Cheers,
Csaba.
On Tue, 2003-09-16 at 15:50, Marek Lewczuk wrote:

text concat(text,text)

return text1 || text2


If it would be so simple I would not write to this group. You see,
CONCAT function doesn't have any arguments limitations, so there could
be one, two or more arguments. And this is my problem, how to write
function without given arguments number.


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


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

Nov 11 '05 #7
On Tue, 16 Sep 2003, Marek Lewczuk wrote:
Hello,
As I'm in the middle of the migration process form mysql to pg I found
that there is no CONCAT function which is available in mysql. Can
anybody tell me how to implement this function using plPERL or plPGSQL
language ?


What's wrong with using the SQL spec || operator?
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

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

Nov 11 '05 #8
On Tuesday 16 September 2003 14:35, scott.marlowe wrote:
On Tue, 16 Sep 2003, Marek Lewczuk wrote:
Hello,
As I'm in the middle of the migration process form mysql to pg I found
that there is no CONCAT function which is available in mysql. Can
anybody tell me how to implement this function using plPERL or plPGSQL
language ?


What's wrong with using the SQL spec || operator?


Because in mysql, SELECT 'a' || 'b' is treated as 'a' OR 'b' and you end up
with a return value of 0. Ho hum.

If I had to choose between coding concat() for PG or the standard operator for
mysql, I think I'd do the same.

--
Richard Huxton
Archonet Ltd

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)

Nov 11 '05 #9
On Tue, 16 Sep 2003, Richard Huxton wrote:
On Tuesday 16 September 2003 14:35, scott.marlowe wrote:
On Tue, 16 Sep 2003, Marek Lewczuk wrote:
Hello,
As I'm in the middle of the migration process form mysql to pg I found
that there is no CONCAT function which is available in mysql. Can
anybody tell me how to implement this function using plPERL or plPGSQL
language ?


What's wrong with using the SQL spec || operator?


Because in mysql, SELECT 'a' || 'b' is treated as 'a' OR 'b' and you end up
with a return value of 0. Ho hum.

If I had to choose between coding concat() for PG or the standard operator for
mysql, I think I'd do the same.


there's a switch in MySQL that makes it behave properly.

Given the third choice, I'd throw the switch.
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

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

Nov 11 '05 #10
On Tue, 16 Sep 2003, scott.marlowe wrote:
On Tue, 16 Sep 2003, Marek Lewczuk wrote:
Hello,
As I'm in the middle of the migration process form mysql to pg I found
that there is no CONCAT function which is available in mysql. Can
anybody tell me how to implement this function using plPERL or plPGSQL
language ?


What's wrong with using the SQL spec || operator?


Having read the other bits of this thread now, it seems you'd like to
create a simple function (pl/sql is good enough to so it, no need for
pl/pgsql or what) to do this, but it needs to handle a variable number of
args.

While pgsql doesn't, to the best of my knowledge, support variable number
of arguments, it DOES support overloading. So, you can always create a
series of functions that hand 2, 3, 4, 5, 6, etc.., arguments until you
get enough to handle all the situations you need.

I still stand by my recommendation to start MySQL with the ansi
compatibility switch and use the SQL standard specified || operator for
portability, as the next database you want to port to after Postgresql may
not be flexible enough to do this.

Standards are nice, they improve portability, and while the default
behaviour of MySQL here is not spec, at least they do provide a switch to
make it work the right way.

Of course, if you've got other packaged apps using || as the OR operator,
you might have issues there. But, if the statements of MySQL are to be
taken seriously, i have the feeling that one day || may well be deprecated
as they try to get their database server more and more accepted for the
server room as a replacement for other databases, so you might as well be
ahead of the curve, and not caught by surprise when that happens.
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 11 '05 #11
In an attempt to throw the authorities off his trail, sc***********@ihs.com ("scott.marlowe") transmitted:
Given the third choice, I'd throw the switch.


Why is it that I think of something _completely_ different when you
use the phrase "throw the switch?"

:-)
--
let name="cbbrowne" and tld="acm.org" in name ^ "@" ^ tld;;
http://www3.sympatico.ca/cbbrowne/nonrdbms.html
"The world needs more people like us and fewer like them." -- Unknown
Nov 11 '05 #12
You're not from Texas, are you? :-)

Christopher Browne wrote:
In an attempt to throw the authorities off his trail, sc***********@ihs.com ("scott.marlowe") transmitted:

Given the third choice, I'd throw the switch.


Why is it that I think of something _completely_ different when you
use the phrase "throw the switch?"

:-)

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

Nov 11 '05 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Garrett Kajmowicz | last post by:
I'm needed to insert large BLOBs into a database. With the 1MB packet limit, sending larger amounts of data would be difficult, so I had a neat...
4
by: Gerald Aichholzer | last post by:
Hello, I need to specify the following attribute in an xhtml-file containing TAL templates: <div tal:attributes="onMouseOver...
3
by: lizayica | last post by:
I am using dynamic SQL in my Procedure that has one parameter named Dep_ID varchar(50). Inside procedure, I need one dynamic SQL to fulfill the...
3
by: Bryan Valencia | last post by:
Ok, I tried to use the concat function. It's in the Help, but it claims it can't find the namespace that contains 'concat'. You'd think there'd be...
8
by: Doug Stiers | last post by:
Is there a downside to using string.concat? Other than a little overhead? str1 = string.concat(str1,str2) vs. str1 &= str2 It seems to me...
4
by: Martin Fletcher | last post by:
I cant get the Concat function to work, please help. Here's some of my code. Module modTCP Public TCP_RECEIVED_DATA As String Private...
1
by: Najib Abi Fadel | last post by:
Hi i have an ordered table of dates let's say: 1/1/2004 8/1/2004 15/1/2004 29/1/2004 5/2/2004 12/2/2004
4
by: Martin Evans | last post by:
Hi, I'm getting: DBD::DB2::db do failed: SQL0440N No authorized routine named "CONCAT" of type "FUNCTION" having compatible arguments was...
1
by: Sharat Koya | last post by:
I have a the following xml node. <doc tag1="a" tag2="b" tag3="c" docTag1="d" docTag2="e"/> I would like to output "abc" I have the following...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.