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 > Need Help to create a query to eliminate data types

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-15-09, 13:59
swati malla swati malla is offline
Registered User
 
Join Date: Jul 2009
Posts: 26
Need Help to create a query to eliminate data types

Hello EveryOne,
I am struggling a lot for a simple query which i am unable to get it..
Currently i am using the following query to get the primary keys of a table..

"SELECT NAME FROM SYSIBM.SYSCOLUMNS WHERE TBNAME = ? AND TBCREATOR=? AND KEYSEQ > 0 ORDER BY KEYSEQ ASC";

But in the primary key i may have like many columns But i am trying to eliminate the "BLOB" data type....
I wanted to get the result with out any blob data types..

I am using other query which is simple ..
Select * from tablename;

In this query also i wanted to eliminate the blob data type..



how to eliminate the column which has a data type of "BLOB"...
I would really appreciate if some one can give me the query..

Thanks,
swati
Reply With Quote
  #2 (permalink)  
Old 09-15-09, 15:27
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
I do not understand your question. Try rephrasing it. Also supply your DB2 version and OS.

Andy
Reply With Quote
  #3 (permalink)  
Old 09-15-09, 16:04
mdx34 mdx34 is offline
Registered User
 
Join Date: Oct 2004
Posts: 238
Some one else may have a better one but try this.........Replace YourschemaName with the actual schema name unless you want them all.

db2 "SELECT substr(name, 1,30)as NAME, COLTYPE FROM SYSIBM.SYSCOLUMNS where TYPESCHEMA = 'YourschemaName' and coltype <> 'BLOB'order by name"
Reply With Quote
  #4 (permalink)  
Old 09-15-09, 16:40
swati malla swati malla is offline
Registered User
 
Join Date: Jul 2009
Posts: 26
Thanks for your quick response.
Sorry for the in convince...
My main goal of my task is ...I have to get all the rows of the table first .And then after some time again i have to get all the rows of the same table..and compare the resluts if any changes happened i have to report it.That is the mail task..

I have written my code everything was wokring fine i tested with only varchar data type of B2 was happy...

But when i started testing with a table where i have blob data type..There i got exceptions and have done some research ..I figured out some thing is we can not compare the blob data types..

"selct * from table name"
this is the query i am using to retrieve all the rows and columns of the table..
Which includes blob data type..

I wanted to get the result set which excludes the blob data type columns...

So it can be achived my a sql query only where we should be able to specify we dont need the blob data type..

To write a query in DB2 which will exclude all the blob data type columns and should return me the result with out blob data types..

Thats the question ...

Let me know if you still dont undestand the question..
Reply With Quote
  #5 (permalink)  
Old 09-16-09, 00:33
db2dummy1 db2dummy1 is offline
Registered User
 
Join Date: Feb 2009
Posts: 114
WOW!! How about excluding those columns whose data type you do not like from your select list
Reply With Quote
  #6 (permalink)  
Old 09-16-09, 01:09
swati malla swati malla is offline
Registered User
 
Join Date: Jul 2009
Posts: 26
Thanks a lot for your quick response...For excluding the columns whose data type i dont like it..What could be the query for that...

I would really appreciate if some one can tell the query .......
Reply With Quote
  #7 (permalink)  
Old 09-16-09, 08:10
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
Quote:
Originally Posted by swati malla
Thanks a lot for your quick response...For excluding the columns whose data type i dont like it..What could be the query for that...

I would really appreciate if some one can tell the query .......
Simple, instead of: select * from table
try: select col1,col2,col3,col4... from table

Andy
Reply With Quote
  #8 (permalink)  
Old 09-16-09, 08:34
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
Quote:
Originally Posted by ARWinner
Simple, instead of: select * from table
try: select col1,col2,col3,col4... from table

Andy
In Texas, DBA's are allowed to shoot programmers who use "select *".
__________________
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
  #9 (permalink)  
Old 09-16-09, 08:45
tonkuma tonkuma is offline
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,193
Quote:
DBA's are allowed to shoot programmers who use "select *".
Except "EXISTS(SELECT * ...)".

Last edited by tonkuma; 09-16-09 at 09:31.
Reply With Quote
  #10 (permalink)  
Old 09-16-09, 14:27
swati malla swati malla is offline
Registered User
 
Join Date: Jul 2009
Posts: 26
Thanks a lot guys for posting answers...
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