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
 

 

Bulk Insert Query with decimal datatype

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

New User


Joined: 09 Apr 2008
Posts: 83
Location: Chennai

PostPosted: Wed Apr 29, 2009 1:22 pm    Post subject: Bulk Insert Query with decimal datatype
Reply with quote

When i am trying to generate bulk insert query using SELECT statement (for few specified columns) from a table, the query is not working if the columns have the following datatypes
1. DATE
2. NUMBER
3. packed decimal

Ex:
SELECT 'INSERT INTO <tb1> VALUES(' || <col1> || ',' ||
col2
|| ')'|| ';'
FROM <tab1> WHERE TIN_NUM = <Tin num>

The col2 column in the above query has packed decimal datatype.
Back to top
View user's profile Send private message

anandinmainframe

Active User


Joined: 31 May 2007
Posts: 171
Location: India

PostPosted: Wed Apr 29, 2009 1:49 pm    Post subject: Reply to: Bulk Insert Query
Reply with quote

Rahuindo,
Please post(ERRORS or SQLCODES) when you try to insert.
Back to top
View user's profile Send private message
sushanth bobby

Senior Member


Joined: 29 Jul 2008
Posts: 1013
Location: India

PostPosted: Wed Apr 29, 2009 3:52 pm    Post subject:
Reply with quote

Hi rahuindo,

TRY something like this,

Code:
   SELECT 'INSERT INTO <tb1> VALUES('
   || <col1>
   || ','
   || CHAR(col2)
   || ')'
   || ';'
   FROM <tab1>
   WHERE TIN_NUM = <Tin num>


If you get an error, post the ERROR along with column definations.

Thank You,
Sushanth
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Wed Apr 29, 2009 3:59 pm    Post subject:
Reply with quote

It would be a good idea to provide your sql, not the paraphrased in your first post as well as column definitions from ddl.
Back to top
View user's profile Send private message
sushanth bobby

Senior Member


Joined: 29 Jul 2008
Posts: 1013
Location: India

PostPosted: Wed Apr 29, 2009 4:27 pm    Post subject:
Reply with quote

Hello,

My Table details
Code:
Table : Country
ID                              INTEGER
NAME                            CHAR
DESCRIPTION                     CHAR


I tried like this one

Code:
SELECT 'INSERT INTO BOBT1.COUNTRY VALUES('     
||CHAR(ID +1)                                   
||');'                                         
FROM BOBT1.COUNTRY;   


Resulted like
Code:
INSERT INTO BOBT1.COUNTRY VALUES(2          ); 
INSERT INTO BOBT1.COUNTRY VALUES(4          ); 
INSERT INTO BOBT1.COUNTRY VALUES(5          ); 
INSERT INTO BOBT1.COUNTRY VALUES(6          ); 
INSERT INTO BOBT1.COUNTRY VALUES(102        ); 


Thank You,
Sushanth
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Wed Apr 29, 2009 4:31 pm    Post subject:
Reply with quote

Sorry Sushanth,

I posted while you were posting.

my comment was directed to rahuindo.

with luck, you have answered rahuindo's question.
Back to top
View user's profile Send private message
sushanth bobby

Senior Member


Joined: 29 Jul 2008
Posts: 1013
Location: India

PostPosted: Wed Apr 29, 2009 4:37 pm    Post subject:
Reply with quote

Happy to help DINO
Back to top
View user's profile Send private message
rahuindo

New User


Joined: 09 Apr 2008
Posts: 83
Location: Chennai

PostPosted: Thu Apr 30, 2009 1:11 pm    Post subject:
Reply with quote

Thanks to all your advice. The query worked with charm as provided with Susanth.
As adviced, i will write the complete query from next time. Thanks!!
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 Join in SQL Query vickey_dw DB2 1 Tue Jan 17, 2017 12:15 am
This topic is locked: you cannot edit posts or make replies. MQ setup query mohitsaini Java & MQSeries 4 Sun Jan 08, 2017 1:53 am
No new posts DB2 query Using Recursion, Converting... smilewithashu2 DB2 1 Tue Jan 03, 2017 12:50 pm
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am
This topic is locked: you cannot edit posts or make replies. Db2 SQL query to convert rows into co... subratarec DB2 5 Thu Nov 17, 2016 4:51 pm


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