SQL Error

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
iwin
Premium Member
Premium Member
Posts: 99
Joined: Mon Apr 11, 2005 9:20 pm

SQL Error

Post by iwin »

Hi,
I am trying to concatenate three columns of same data type (3,3,4) into one column of same data type (12) by giving the following statement, but i am getting an error.

Select
(PHONE.area_code || PHONE.prefix || PHONE.number) as Ph_nbr AS CHAR(12) from abc;

Please guide me where i am going wrong.
pnchowdary
Participant
Posts: 232
Joined: Sat May 07, 2005 2:49 pm
Location: USA

Post by pnchowdary »

Hi Iwin,

Why dont you read the values as individual columns using SQL and then merge all the three columns into one big column in a transformer?
Thanks,
Naveen
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

Cast individual cols before concat.
snassimr
Premium Member
Premium Member
Posts: 281
Joined: Tue May 17, 2005 5:27 am

Post by snassimr »

Use

PHONE.area_code : PHONE.prefix : PHONE.number
logic
Participant
Posts: 115
Joined: Thu Feb 24, 2005 10:48 am

Post by logic »

Use ":" if doing in trans else use"||"
Try the following

Code: Select all

SELECT (t.area_code || t.prefix || t.number)  as ph_nbr  FROM abc t
cheers,
ash.
iwin
Premium Member
Premium Member
Posts: 99
Joined: Mon Apr 11, 2005 9:20 pm

Post by iwin »

Hi,
Thanks guys, it finally worked.
aartlett
Charter Member
Charter Member
Posts: 152
Joined: Fri Apr 23, 2004 6:44 pm
Location: Australia

Post by aartlett »

[quote="iwin"]Hi,
Thanks guys, it finally worked.[/quote]

And what was it that finally worked? Ash's idea?
Andrew

Think outside the Datastage you work in.

There is no True Way, but there are true ways.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You can't do "AS CHAR(12)". It's not legal as an alias. You use a CAST specification (if necessary) to change data type temporarily. The result of concatenation is necessarily string, so it's probably not necessary in that case.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply