Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to drop invalid views in DB2?

Posted on 2014-01-13
2
Medium Priority
?
1,131 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 46

Assisted Solution

by:Kent Olsen
Kent Olsen earned 1000 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 1000 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

Cloud Training Guides

FREE GUIDES: In-depth and hand-crafted Linux, AWS, OpenStack, DevOps, Azure, and Cloud training guides created by Linux Academy instructors and the community.

Question has a verified solution.

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

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…
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…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses

721 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