Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
DB2 Query to concatenate two strings

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
sakthivel_t100
Warnings : 1

New User


Joined: 03 Aug 2007
Posts: 10
Location: chennai

PostPosted: Wed Aug 22, 2007 10:43 pm    Post subject: DB2 Query to concatenate two strings
Reply with quote

Hi ALL,

I have one query. could you please answer for below query?

I have a emp table which column has value India Pakistan. I want result like IndiaPakistan. It should not be space between India and Pakistan. I need a query without using concentation fuction on DB2.

Thanks icon_mad.gif
Back to top
View user's profile Send private message

dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6968
Location: porcelain throne

PostPosted: Wed Aug 22, 2007 11:15 pm    Post subject:
Reply with quote

That requires a political and cultural answer. DB2 is only logical.
Back to top
View user's profile Send private message
stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

PostPosted: Wed Aug 22, 2007 11:18 pm    Post subject:
Reply with quote

So is the value in the column "India Pakistan" or are there 2 columns with values "India" and "Pakistan". And what is the reason for not using the concatenation function? It is there to be used.
Back to top
View user's profile Send private message
stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

PostPosted: Wed Aug 22, 2007 11:22 pm    Post subject:
Reply with quote

If it is 2 columns then

Code:

SELECT COLUMN A || COLUMN B
FROM empTable


It isn't use the concatenate function directly...
Back to top
View user's profile Send private message
stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

PostPosted: Wed Aug 22, 2007 11:22 pm    Post subject:
Reply with quote

dbzTHEdinosauer: Shouldn't Kashmir be wedged between them?

IndiaKasmirPakistan?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6968
Location: porcelain throne

PostPosted: Wed Aug 22, 2007 11:28 pm    Post subject:
Reply with quote

Steve, from what I understand, that is part of the problem. India thinks Kashmir is part of India and Pakistan also claims Kashmir as a province.

I think the OP has only one column. Judicious use of substring would probably solve the problem, but having concatenation ruled out, I don't really believe this was a query about programming.
Back to top
View user's profile Send private message
stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

PostPosted: Wed Aug 22, 2007 11:30 pm    Post subject:
Reply with quote

Without substring, isn't there a replace function that would kill all the spaces?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6968
Location: porcelain throne

PostPosted: Thu Aug 23, 2007 2:38 am    Post subject:
Reply with quote

Received two (2) PM's from sakthivel_t100.

He feels that I am trying to start trouble.

Well, first the restriction on the common sense use of the concatenation function.

Then, in his example he used the names of two nations that have political & cultural disagreements.

ok, i read too much into the question; not trying to start trouble. there is plenty of it around.

sakthivel_t100, don't send me any more of PM's.
Not please don't, just don't!
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Aug 23, 2007 3:13 am    Post subject:
Reply with quote

Hello,

Please explain the business reason for this "rule"
Quote:
I need a query without using concentation fuction on DB2.


If there is no business requirement for this, you might let us know that it is something from school/training, an interview, or just an experiment that you are trying.
Back to top
View user's profile Send private message
stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

PostPosted: Thu Aug 23, 2007 4:24 am    Post subject:
Reply with quote

Yeah I got a PM too. Oh well, it wasn't meant to be anything.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Create procedure issues -628 when add... chandraBE DB2 1 Mon Sep 18, 2017 12:16 pm
No new posts Can we limit length in concatenation ... balaji81_k DB2 7 Tue Aug 22, 2017 2:50 am
No new posts Need DB2 query to fetch previous row ! Chandan1993 DB2 10 Sat Jun 03, 2017 10:43 am
No new posts Occurrence of various strings within ... TS70363 JCL & VSAM 1 Thu Apr 27, 2017 8:18 pm
No new posts Strings with double quotes having pro... raja Arumugam All Other Mainframe Topics 11 Thu Mar 30, 2017 10:34 am

Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us