INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Exception Handling

Exception Handling

(OP)
Hello DB2 Gurus,

I need a favour. How can I handle exceptions in DB2, I am very new to the db2. I know about exception handling. but dont know how I can do it in db2. I want to drop the primary key on a table. I dont want to fail the stored_proc if the primary key doesnt not exist.

Oracle code:
begin
alter table table_a drop primary key;
exception
when others then
  ----print something
end;

How can i do the same in db2. Please help.

Regards
G

RE: Exception Handling

If you explain why you want to drop the primary key, someone may have a suggestion. This is ususally (always) done in a maintenance window and is not a part of "processing".

Once the primary key is dropped, what then?

If the drop fails, seems like this would be critical. . .

Obviously, there is something i misunderstand.

RE: Exception Handling

(OP)
This is for re-bulking the big volume of data, I want to drop all the constraints on the table before inserting bulk data. I got millions of data so I dont want to keep all the indexes. I can check for particular constraint name on a table if i know the constraint name, but these constraints are generated automatically so system creates the primary key with system generated name. So I dont know the name of primary key constraint. I want to run this dropping constraint on pre-sql of my Informatica Job. Afater the end of load I will create the primary key.

Regards,
G

RE: Exception Handling

(OP)
Sorry for the confusion my main question is how to handle exceptions in DB2 like we have in Oracle. It doesnt have to be primary key dropping between begin and end block. let us take this example I want to create a constraint on a column but I dont know if that particular constrant already exist and the name is generated automatically so I will not know the constraint's name.

Regards,
G

RE: Exception Handling

When my people run a process that requires different action based on the result of an sql statement, this is run from within code. The code can be whatever is needed.

If you need to discover which keys exist for a table, this can be done reading the catalog tables.

I may be misunderstanding something. . .

RE: Exception Handling

(OP)
Sorry I am really confused now.

I am simply asking for some code sample which handles any error, irrespective of what number it is. like we have error handling in oracle. Please let me know if this is possible in db2.

Regards
G

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close