Solved

How to drop invalid views in DB2?

Posted on 2014-01-13
2
1,057 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 24

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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 (you can use 'recursive' and 'SQL' in the same sentence) A growing number of database queries lend themselves to recursive solutions.  It's not always easy to spot when recursion is called for, especially for people una…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

707 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now