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 > DB2 Queries

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-01-12, 05:33
thiru_siva thiru_siva is offline
Registered User
 
Join Date: Oct 2009
Posts: 1
DB2 Queries

1) How can i see SQLERRD(3) ???

2) Can you please suggest the easiest way to fetch records from a table with a column having characters other than non-specified values ? For Example : I need a row which is having characters other than A, B and C ???
Input : ABC, AMC, BBC, TTG, KKK, LLL
Output should be : TTG, KKK, LLL

3) I need to update the values of a column in DB2 if the value is numeric ???
Ex : Input value is : 123, 145
Output should be : 00123 , 00145

4) There are three tables Current, History and archive. The contents of these tables are consolidated in one table called Full. I need to write a query in which i need to sum up the record count of Current, History and archive

For example
SELECT COUNT(*) AS C
FROM CURRENT
UNION
SELECT COUNT(*) AS H
FROM HISTORY
UNION
SELECT COUNT(*) AS A
FROM ARCHIVE;

Now i need to sum up the count values(c,h,a) in the same query.
Can anyone help me on this?

5) I need to fetch all the rows where spaces is a part of column value with some restriction ???

I/P is : UNITED STATES, INDIA, UK
O/P should be : UNITED STATES (as it is having spaces)
Reply With Quote
  #2 (permalink)  
Old 02-01-12, 06:35
tonkuma tonkuma is online now
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,193
2), 5)
Please see LOCATE function
LOCATE - IBM DB2 9.7 for Linux, UNIX, and Windows

For example, to find a string having 'A'.
LOCATE('A' , string) > 0


3)
3-1) What is the datatype of the column?

3-2) How to do for those data?
'01 23'
'012 '


4)
Try...
Code:
SELECT c
     , h
     , a
     , c + h + a AS sum
 FROM  (
       SELECT COUNT(*) AS C 
        FROM  CURRENT
       ) c
     , (
       SELECT COUNT(*) AS H 
        FROM  HISTORY 
       ) h
     , (
       SELECT COUNT(*) AS A 
        FROM  ARCHIVE
       ) a
;

Last edited by tonkuma; 02-01-12 at 06:39.
Reply With Quote
  #3 (permalink)  
Old 02-01-12, 07:11
przytula_guy przytula_guy is offline
Registered User
 
Join Date: Apr 2006
Location: Belgium
Posts: 1,159
SQLERRD(3) : see get diagnostics
__________________
Best Regards, Guy Przytula
Database Software Consultant
DB2 UDB LUW Certified V7-V8-V9-V9.7 DB Admin - Dprop..
Information Server Datastage Certified
http://www.infocura.be
Reply With Quote
  #4 (permalink)  
Old 02-01-12, 07:42
tonkuma tonkuma is online now
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,193
2)
Quote:
... a row which is having characters other than A, B and C ???
Input : ABC, AMC, BBC, TTG, KKK, LLL
Output should be : TTG, KKK, LLL
If specified characters supplied as a string like 'ABC',
then try...
Code:
...
 WHERE LENGTH( TRANSLATE(string , '' , 'ABC' , '') )
       = LENGTH(string)
...
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