Re: Deleting rows from a table in SQL



In DB2 if you try to 'DELETE FROM T1' and T1 is empty you will get:

SQL0100W No row was found for FETCH, UPDATE or DELETE; or the result
of a
query is an empty table. SQLSTATE=02000

Which of course is what the issue is. If you tried this in a SQL PL
stored procedure for example you would need to declare a CONTINUE
CONDITION HANDLER for SQL0100W. It's not exactly an error, rather a
warning is it not ? If your able to interrogate sql error or state and
interpret result as above.

Alternatively, re-create the table with 'NOT LOGGED INITIALLY'
statement.

Then when you want to empty it:

'ALTER TABLE T1 ACTIVATE NOT LOGGED INITIALLY WITH EMPTY TABLE'

This will empty the table completely without logging the individual
records being deleted.

.



Relevant Pages

  • Re: Splitting file
    ... No row was found for FETCH, UPDATE or DELETE; ... query is an empty table. ... UPDATE TABLE1 SET ... ...
    (comp.unix.shell)
  • Re: Question about SqlCe Parameters usage
    ... but how can I make a Query in qhich I specify the range of index ... you create an empty table and fill it with a SQL query which only ... > done a query which specified the range of index to fetch, ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Splitting file
    ... UPDATE TABLE1 SET ... ... No row was found for FETCH, UPDATE or DELETE; ... query is an empty table. ...
    (comp.unix.shell)
  • Splitting file
    ... UPDATE TABLE1 SET ... ... No row was found for FETCH, UPDATE or DELETE; ... query is an empty table. ...
    (comp.unix.shell)
  • Cant resolve aol.com anymore.. but can other domains
    ... 12 Flags A = Authoritative Answer ... OPCODE 0 (QUERY) ... RCODE 0 (NOERROR) ...
    (microsoft.public.windows.server.dns)