IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How to add character to the value


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
ashok_uddaraju

New User


Joined: 21 Feb 2007
Posts: 72
Location: US

PostPosted: Thu May 06, 2010 4:27 pm
Reply with quote

Hi,

While running an SQL query i have a situation where I took date(timestamp). Now i need to concatenate ';' and t the end of the value.

I tried char(date(timestamp))||char(';'), but showing -181 error.

can you plesae let me know hos to do this concatenation?
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Thu May 06, 2010 4:31 pm
Reply with quote

post your complete query... Have you looked as what is mean by SQLCODE you are getting?
And why date of timestamp why not just use current date?
Code:

SELECT (CHAR(CURRENT DATE) || ';') FROM SYSIBM.SYSDUMMY1;   
Back to top
View user's profile Send private message
ashok_uddaraju

New User


Joined: 21 Feb 2007
Posts: 72
Location: US

PostPosted: Thu May 06, 2010 4:39 pm
Reply with quote

select char(date(update_ts))||char(';') from xyz;

I want the output as 2010-05-06;(including ;)
Back to top
View user's profile Send private message
ashok_uddaraju

New User


Joined: 21 Feb 2007
Posts: 72
Location: US

PostPosted: Thu May 06, 2010 4:41 pm
Reply with quote

i am working on different date not just current date
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1208
Location: Bangalore,India

PostPosted: Thu May 06, 2010 5:06 pm
Reply with quote

Hi Ashok,

Quote:
i am working on different date not just current date


So whats the problem use ur column name and table name instead of current date and sysibm.sysdummy table.

Code:
select char(char(date(update_ts))|| ';') from xyz;


I would suggest you to read Db2
Back to top
View user's profile Send private message
ashok_uddaraju

New User


Joined: 21 Feb 2007
Posts: 72
Location: US

PostPosted: Thu May 06, 2010 5:09 pm
Reply with quote

it gives ma and error

---------+---------+---------+---------+---------+---------+---------+--------
DSNT408I SQLCODE = -171, ERROR: THE DATA TYPE, LENGTH, OR VALUE OF ARGUMENT 1
OF || IS INVALID
Back to top
View user's profile Send private message
ashok_uddaraju

New User


Joined: 21 Feb 2007
Posts: 72
Location: US

PostPosted: Thu May 06, 2010 5:12 pm
Reply with quote

sorry this is the error message

DSNT408I SQLCODE = -181, ERROR: THE STRING REPRESENTATION OF A DATETIME VALUE
IS NOT A VALID DATETIME VALUE
Back to top
View user's profile Send private message
skkp2006

New User


Joined: 14 Jul 2006
Posts: 93
Location: Chennai,India

PostPosted: Thu May 06, 2010 5:14 pm
Reply with quote

Ashok,

Post the SQL that you have used. We have no idea whats the actual query that you have used.


try this also..

Code:
SELECT CHAR(DATE(CURRENT TIMESTAMP))||CHAR(';')   
                 FROM SYSIBM.SYSDUMMY1;           




Syam
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1208
Location: Bangalore,India

PostPosted: Thu May 06, 2010 5:19 pm
Reply with quote

Hello Ashok,

I tried it and its working fine for me

Code:
SELECT CHAR(CHAR(DATE(UPDATE_TS))||';')
FROM  ABC         
FETCH FIRST ROW ONLY;       


Just check ur code and post the Sql u tried
Back to top
View user's profile Send private message
ashok_uddaraju

New User


Joined: 21 Feb 2007
Posts: 72
Location: US

PostPosted: Thu May 06, 2010 5:30 pm
Reply with quote

this is the orginal query with table names changed
select char(date(update_ts))||char(';') from xyz;

I had treied the query for sysdummy and it worked, but not working for the orginal query.Unfortunately i canot paste the original query

Mu origibla query works til select char(date(update_ts)), but when added the second part ||char(';') it fails with

DSNT408I SQLCODE = -181, ERROR: THE STRING REPRESENTATION OF A DATETIME VALUE
IS NOT A VALID DATETIME VALUE
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1208
Location: Bangalore,India

PostPosted: Thu May 06, 2010 5:32 pm
Reply with quote

Hello Ashok,

Did u compare ur query with the Query provided by me?

UR Query
Code:
select char(date(update_ts))||char(';') from xyz;



My Query
Code:
SELECT CHAR(CHAR(DATE(UPDATE_TS))||';')
FROM  ABC


Hope u get it now
Back to top
View user's profile Send private message
ashok_uddaraju

New User


Joined: 21 Feb 2007
Posts: 72
Location: US

PostPosted: Thu May 06, 2010 5:41 pm
Reply with quote

tried SELECT CHAR(CHAR(DATE(UPDATE_TS))||';')
FROM ABC
as well .... same error
Back to top
View user's profile Send private message
ashok_uddaraju

New User


Joined: 21 Feb 2007
Posts: 72
Location: US

PostPosted: Thu May 06, 2010 6:07 pm
Reply with quote

i got this......... thanks
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1208
Location: Bangalore,India

PostPosted: Thu May 06, 2010 6:08 pm
Reply with quote

Finally :-)
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Panvalet - 9 Character name - Issue c... CA Products 6
No new posts String has hex character need to conv... COBOL Programming 3
No new posts Output LREC based on specific character DFSORT/ICETOOL 22
No new posts Replacing character string in file th... JCL & VSAM 9
No new posts Problem while sending special charact... JCL & VSAM 4
Search our Forums:

Back to Top