If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Check for column extistance

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-16-06, 10:22
NiallMulhare NiallMulhare is offline
Registered User
 
Join Date: Nov 2006
Posts: 13
Check for column extistance

Hey All,

I'm hoping you might be able to help me out with a problem I'm having.
I was wondering if there is syntax for checking if a column exist. I have to do migration e.g.
Code:
insert into TBLone(
a
,b
,c
,d
,e
,F
)
select
a
,b
,c
,d
,e
,F
From TBLtwo!
My problem is that in "TBLtwo" the column "f" may not exist, so I would want to do the migration if it does exist but if it doest not skip it e.g

Code:
if column F exists
   migrate data from TBLtwo.F into TBLone.F
else
   Skip migration of that column
Anyone got any suggestions or if I didn't explain that well just shout
Thanks.
Reply With Quote
  #2 (permalink)  
Old 11-16-06, 21:17
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
The column definitions for every table is contained in the DB2 Catalog. See SQL Reference, Vol 1, Appendix D, Catalog Views.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #3 (permalink)  
Old 11-17-06, 08:43
NiallMulhare NiallMulhare is offline
Registered User
 
Join Date: Nov 2006
Posts: 13
Excellent thanks for the info
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On