Solved

How to drop invalid views in DB2?

Posted on 2014-01-13
2
1,079 Views
Last Modified: 2014-01-18
Can anyone assist with situation when DB2 view has "valid=N", so after issue 'drop' command?
-
DB21034E  The command was processed as an SQL statement because it was not a
valid Command Line Processor command.  During SQL processing it returned:
SQL0204N  "My_view.Name" is an undefined name.  SQLSTATE=42704.
Looking for the way that doesn't require recreate parent to this table.
Thank you
0
Comment
Question by:sevior
2 Comments
 
LVL 45

Assisted Solution

by:Kdo
Kdo earned 250 total points
ID: 39777886
Hi sevior,

Breaking this down:

DB21034E  The command was processed as an SQL statement because it was not a
valid Command Line Processor command.  During SQL processing it returned:


Just informative.  Nothing to read there.  :)


SQL0204N  "My_view.Name" is an undefined name.  SQLSTATE=42704.

In this message, "My_view" is actually the schema name (though case should not be an issue) and "Name" is the view name.  It sounds like you're expecting something else.


Kent
0
 
LVL 25

Accepted Solution

by:
Tomas Helgi Johannsson earned 250 total points
ID: 39790510
Hi!

This command will list all views that are invalid
db2 "select viewschema.viewname from syscat.views where valid = 'N'"

This command will drop all views that are invalid
db2 -x "select 'db2 -v drop view '|| rtrim(viewschema) || '.\' || '\"' || rtrim(viewname)|| '\' || '\"' ||'' from syscat.views where valid = 'N'"

Modify these commands to your needs (if you want to say drop a specific view ).

Regards,
    Tomas Helgi
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

November 2009 Recently, a question came up in the DB2 forum regarding the date format in DB2 UDB for AS/400.  Apparently in UDB LUW (Linux/Unix/Windows), the date format is a system-wide setting, and is not controlled at the session level.  I'm n…
Recursive SQL in UDB/LUW (it really isn't that hard to do) Recursive SQL is most often used to convert columns to rows or rows to columns.  A previous article described the process of converting rows to columns.  This article will build off of th…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question