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 > delete the data

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-05-07, 15:16
mandla.srinivas mandla.srinivas is offline
Registered User
 
Join Date: Jan 2007
Posts: 6
delete the data

I am trying to delete the data which is older than 2 years.
So I have written the following query.But it is not getting executed successfully.Could you please help me in correcting the following query.
INL_PPN_TMS is time stamp.

delete from ABC
where date(ABC.INL_PPN_TMS) < (select date (current date -2 year) from sysibm.sysdummy1)
Reply With Quote
  #2 (permalink)  
Old 01-05-07, 16:23
jayecarter jayecarter is offline
Registered User
 
Join Date: Aug 2002
Location: St. Louis
Posts: 16
What is the error you recieve?
Reply With Quote
  #3 (permalink)  
Old 01-05-07, 17:31
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Quote:
Originally Posted by William of Occam
One should not increase, beyond what is necessary, the number of entities required to explain anything.
Code:
delete from ABC
where date(ABC.INL_PPN_TMS) < current date -2 years
Reply With Quote
  #4 (permalink)  
Old 01-05-07, 17:39
jayecarter jayecarter is offline
Registered User
 
Join Date: Aug 2002
Location: St. Louis
Posts: 16
So how do you know this didn't execute successfully? What sqlcode or sqlstate was returned?
Reply With Quote
  #5 (permalink)  
Old 01-06-07, 11:38
mandla.srinivas mandla.srinivas is offline
Registered User
 
Join Date: Jan 2007
Posts: 6
SQL0100W No row was found for FETCH, UPDATE or DELETE; or the result of a
query is an empty table. SQLSTATE=02000
------------------------------------------------------------------------
that particular query was giving the above message.So I thought this is an error.When it was not able to get the data which satisifies the delete statement condition it was above message.

I could run my informatica mapping success fully which is having this query.

Thank you very much for the response.
Reply With Quote
  #6 (permalink)  
Old 01-06-07, 12:48
jayecarter jayecarter is offline
Registered User
 
Join Date: Aug 2002
Location: St. Louis
Posts: 16
Is your issue resolved then?
Reply With Quote
  #7 (permalink)  
Old 01-07-07, 06:45
Peter.Vanroose Peter.Vanroose is offline
Registered User
 
Join Date: Sep 2004
Location: Belgium
Posts: 1,079
Quote:
Originally Posted by n_i
Code:
delete from ABC
where date(ABC.INL_PPN_TMS) < current date -2 years
Or most probably even better
Code:
delete
from  ABC
where INL_PPN_TMS < current date - 2 years
And indeed, an SQLCODE of 100 (or equivalently a "SQL0100W") is perfectly OK since it just means that no rows were older than 2 years.
__________________
--_Peter Vanroose,
__IBM Certified Database Administrator, DB2 9 for z/OS
__IBM Certified Application Developer
__ABIS Training and Consulting
__http://www.abis.be/
Reply With Quote
  #8 (permalink)  
Old 01-08-07, 00:55
grofaty grofaty is offline
Registered User
 
Join Date: Jan 2003
Posts: 1,570
mandla.srinivas,
SQL0100W - character W means warning. Character E means Error. So you got only warning, I can be everything ok, just to let you know no rows were deleted.
Reply With Quote
  #9 (permalink)  
Old 01-17-07, 05:36
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Try in your shell:
Code:
db2 "? SQL100W"
You can replace SQL100W with any error you receive from DB2. Actually, you can omit the trailing W, E, C, or I character, and you don't need the leading 0's in the number:
Code:
db2 "? sql100"
The only other thing to remember is how to get the message number based on the SQLCODE. You just remove the sign and prepend the string "sql".
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