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

DB2 insert query.


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

New User


Joined: 21 Sep 2007
Posts: 35
Location: kolkata

PostPosted: Wed Jul 23, 2008 10:23 pm
Reply with quote

Suppose i have a table which has a 4 digit column called Telephone number(for eg 1234,1111,etc).If i want to add 9 infront of the number.How can we do it thru a SQl query.Like after the execution of the query the telephone number will be like(91234,91111).
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Wed Jul 23, 2008 10:34 pm
Reply with quote

If its a 4 digit column then it can't contain an 8 digit value so you wouldn't be able to insert a '9' anyways. What is the definition of this column?
Back to top
View user's profile Send private message
saubhik

New User


Joined: 21 Sep 2007
Posts: 35
Location: kolkata

PostPosted: Wed Jul 23, 2008 10:43 pm
Reply with quote

suppose you have changed the column definition so that it can accomodate 5 digit number.Then also how can we insert 9 before that 4 digit number.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Wed Jul 23, 2008 10:53 pm
Reply with quote

I'm no DB2 expert, but can't you do something like
Code:
UPDATE TABLE SET TELEPHONENUMBER = TELEPHONENUMBER + 90000 WHERE TELEPHONENUMBER > 1000
Back to top
View user's profile Send private message
saubhik

New User


Joined: 21 Sep 2007
Posts: 35
Location: kolkata

PostPosted: Wed Jul 23, 2008 11:17 pm
Reply with quote

Thanks man!!i think it will work.
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1436
Location: Bangalore,India

PostPosted: Thu Jul 24, 2008 8:32 am
Reply with quote

Saubhik,

Quote:
i think it will work.

What happend? Did it work.
Back to top
View user's profile Send private message
vasanthkumarhb

Active User


Joined: 06 Sep 2007
Posts: 275
Location: Bang,iflex

PostPosted: Thu Jul 24, 2008 11:54 am
Reply with quote

Murali,


It should work!!!
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Thu Jul 24, 2008 12:11 pm
Reply with quote

if telephone no is char (or varchar), it will not work.

but then we do not know the datatype of the column in question.
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 RC query -Time column CA Products 3
No new posts Dynamically pass table name to a sele... DB2 2
No new posts Query on edit primary command CLIST & REXX 5
No new posts Query on edit primary command CLIST & REXX 1
No new posts Insert header record with record coun... DFSORT/ICETOOL 14
Search our Forums:

Back to Top