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

Inserting Data Into DB2 table


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

New User


Joined: 15 Jun 2007
Posts: 92
Location: bangalore

PostPosted: Wed May 30, 2012 4:27 pm
Reply with quote

I want to insert data in to my DB2 table from my input file. This can be done easily using DB2 load utilities. But my problem is i want to add some more constant while loading the table.

let me give more details on the problem what i am facing. I have one table with say some 5 columns, But in my input file i have only data for 3 columns. The new two columns in a table are current timestamp and come constant. So i wanted to load these two columns with current timestamp and some other constant value. I guess we can do this Insert statement, But i don't have full JCL with me. Could anyone pass the JCL for this?? I checked all the manuals but couldn't able to find.

Thanks.
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Wed May 30, 2012 4:40 pm
Reply with quote

JCL won't do it, of course; you'll also need a LOAD utility deck.

Depending on how the target table's columns are defined, you may be able to do what you want with the LOAD utility alone, or you may have to do some actual programming.
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Wed May 30, 2012 4:43 pm
Reply with quote

Why not use a program to achieve the same ? rather approaching the problem in circumloqutory manner??

Is there any sepecif reason it needs to be done using DB2 utility only
Back to top
View user's profile Send private message
chandracdac

New User


Joined: 15 Jun 2007
Posts: 92
Location: bangalore

PostPosted: Wed May 30, 2012 4:46 pm
Reply with quote

JCL won't do it, of course; you'll also need a LOAD utility deck.

yes i meant this only..


I want to insert current time stamp and some constant value while loading the data. i can modify the file before loading and then i can load. But i dnt want this. i want the current stamp value while loading the table.
Back to top
View user's profile Send private message
chandracdac

New User


Joined: 15 Jun 2007
Posts: 92
Location: bangalore

PostPosted: Wed May 30, 2012 4:48 pm
Reply with quote

Pandora-Box
i feel using JCL is the right option to do this. writing a program is not touch but it needs lot of other things like program name creation,approval etc etc in my installation.

Thanks
Back to top
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 792
Location: Pennsylvania

PostPosted: Wed May 30, 2012 4:54 pm
Reply with quote

Quote:
Why not use a program to achieve the same ? rather approaching the problem in circumloqutory manner??


The reasons to use a db2 utility are:
Loading data are what the are designed to do
Easier to write than an entire program
Easier to execute than a program
More efficient, especially for large amounts of data

Note: I could not find the word circumloqutory in the dictionary. Please explain the meaning.
Back to top
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 792
Location: Pennsylvania

PostPosted: Wed May 30, 2012 5:07 pm
Reply with quote

chandracdac,

If you use utility DSNUTLIB:
You can do an Unload of the data one time. The purpose of this is to create the load cards which are written to DD SYSPRINT as part of the process.

You can then modify these load cards to use the current timestamp and a literal value for your desired columns.

You can then use your modified load cards to load your data.

Surely there is an example of PGM=DSNUTLIB somewhere on your system. Search there as it will be closest to what you will need.
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Wed May 30, 2012 5:19 pm
Reply with quote

daveporcelan wrote:
Quote:
Quote:
Why not use a program to achieve the same ? rather approaching the problem in circumloqutory manner??



The reasons to use a db2 utility are:
Loading data are what the are designed to do
Easier to write than an entire program
Easier to execute than a program
More efficient, especially for large amounts of data

Note: I could not find the word circumloqutory in the dictionary. Please explain the meaning.



I misspelled circumlocutory

Thanks and I have some knowledge the utility was trying to understand as TS would need the timestamp while load time which would be easier using a program and I am not sure if values could be passed against the fields in UTILITY LOAD like CURRENT TIMESTAMP
Back to top
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 792
Location: Pennsylvania

PostPosted: Wed May 30, 2012 6:09 pm
Reply with quote

Pandora-Box,

Inserting a timestamp can be done with a load utility.

For everyone: circumlocutory - a roundabout or indirect way of speaking; the use of more words than necessary to express an idea.

Ironically enough, writting a program to load data is the circumlocutory
method in my opinion. In fact the word is the defination of itself.
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Wed May 30, 2012 6:42 pm
Reply with quote

ok thanks Dave :-)
Back to top
View user's profile Send private message
chandracdac

New User


Joined: 15 Jun 2007
Posts: 92
Location: bangalore

PostPosted: Mon Jun 04, 2012 10:16 am
Reply with quote

daveporcelan
Thanks for the solution... will try this.. i didn't get this idea.

Thanks
Chandra
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 Load new table with Old unload - DB2 DB2 6
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Data set Rec-Cnt and Byte-Cnt Testing & Performance 2
No new posts SCOPE PENDING option -check data DB2 2
No new posts Multiple table unload using INZUTILB DB2 2
Search our Forums:

Back to Top