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

COBOL - DB2 Tables


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Chetan Kumar

New User


Joined: 03 Dec 2012
Posts: 46
Location: India

PostPosted: Fri Jul 10, 2015 9:11 pm
Reply with quote

Hi All,

Four Cobol-Db2 programs are accessing a Table EMP-TABLE. Later there was a requirement to add 2 new columns to the table to use it in the 5th new program.

Scenario-01: When new 2 columns added at the end of the table.

Do we need to recompile all the programs or only the 5th one? and why?

Scenario-02: When new 2 columns added in between the table?
Then do we need to recompile all the programs or only the 5th one? and why?
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Fri Jul 10, 2015 9:22 pm
Reply with quote

It's been a while since I've worked with DB2, but if I remember correctly, new columns only affect programs that access those columns. If the 1st 4 programs do not access the new columns, compile only program 5. If any of the 4 do a SELECT * (which is not recommended), those programs would have to be changed and recompiled. As to your 2nd question, it doesn't matter where the new columns appear in the table -- beginning, middle, or end.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Wed Jul 15, 2015 5:37 pm
Reply with quote

Well, you add columns to a row and not a table.
normally, and I apologize for exposing my ignorance here,
but how would one add new columns to the middle of a row?
Back to top
View user's profile Send private message
Chetan Kumar

New User


Joined: 03 Dec 2012
Posts: 46
Location: India

PostPosted: Wed Jul 15, 2015 7:50 pm
Reply with quote

I don't understand your point dbzTHEDinosauer, it's not row it's the column we add to the table. Suppose there is a requirement to add two new columns in the 3rd and 4th position of the table which has 10 columns already. Then we need to add columns based on the order of columns as per the requirement.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Thu Jul 16, 2015 3:13 am
Reply with quote

Columns belong to rows - you cannot have a column without a row. You cannot add columns 'between' other columns. You have to define a new table and probably write a program to migrate the data across.
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Thu Jul 16, 2015 7:56 pm
Reply with quote

I disagree on this with the two moderators about semantics : columns belong to tables.
you can have columns (defined) without rows. you can not have rows without columns.
You do not ALTER ROW ADD COLUMN.

But On Topic :
(automatic) rebinds should suffice unless there is a "select *" or (an "insert" and the new columns are defined not null without default).

Adding columns in between requires dropping and recreating the table, but above rule about rebinds also applies.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Fri Jul 17, 2015 1:40 am
Reply with quote

GuyC - I stand corrected but I was speaking from the data point of view - one cannot have actual data in a column without having a row - but I did not point it out as such.
Back to top
View user's profile Send private message
Mickeydusaor

Active User


Joined: 24 May 2006
Posts: 258
Location: Salem, Oregon

PostPosted: Fri Jul 17, 2015 2:21 am
Reply with quote

if you drop a table its a good time to do a runstats
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3051
Location: NYC,USA

PostPosted: Fri Jul 17, 2015 5:15 pm
Reply with quote

1. You don't. during the insert query if you have not listed the columns names then that will fail and then you got to change them.
2. Your DBA at first place won't allow to add columns in between as it does not make difference to a select or update or insert as to where is a new column being added and not recommended . And answer remains same as 1.
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 -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Generate random number from range of ... COBOL Programming 3
Search our Forums:

Back to Top