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 Usergroups Profile Log in to check your private messages Log in
 

 

DB2 insert query.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: DB2 insert query.
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    Post subject:
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    Post subject: Reply to: DB2 insert query.
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: 8086
Location: East Dubuque, Illinois, USA

PostPosted: Wed Jul 23, 2008 10:53 pm    Post subject:
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    Post subject: Reply to: DB2 insert query.
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: 1439
Location: Bangalore,India

PostPosted: Thu Jul 24, 2008 8:32 am    Post subject:
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: 276
Location: Bang,iflex

PostPosted: Thu Jul 24, 2008 11:54 am    Post subject:
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: 6967
Location: porcelain throne

PostPosted: Thu Jul 24, 2008 12:11 pm    Post subject:
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    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 Need DB2 query to fetch previous row ! Chandan1993 DB2 10 Sat Jun 03, 2017 10:43 am
No new posts JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm
No new posts Omegamon for DB2 query ashek15 DB2 0 Wed Feb 15, 2017 11:25 am
No new posts Query on DB2 WLM stored procedures ashek15 DB2 8 Sun Feb 12, 2017 11:13 pm


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