Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2017
    Posts
    3
    Provided Answers: 1

    Question Answered: Multiple "DROP TABLE Table_Name" statement

    Hi All,
    I am new to IBM DB2, I am using it through Squirrel Client Version 3.7.1

    I have one requirement to run below multiple DROP TABLE statements.

    DROP TABLE Table1;
    DROP TABLE Table2;
    DROP TABLE Table2;

    If Table1 not exists in database it throws below error and cannot continue to run second and third statement even if the TABLE2 and TABLE3 exists in database.

    ERROR: "TRIDATA.TABLE1" is an undefined name.. SQLCODE=-204, SQLSTATE=42704, DRIVER=3.69.66 SQL Code: -204, SQL State: 42704
    Error occurred in:
    DROP TABLE Table1

    Can any one help me that how to achieve this requirement?
    Appreciate your help and support.

  2. Best Answer
    Posted by jpate06

    "
    Quote Originally Posted by mark.bb View Post
    Hi,

    Uncheck Session->Session Properties->SQL->"Abort on Error" in Squirrel.
    Thank you very much for your help.
    It is working in Squirrel.

    Now if in case, I have to execute same logic through external .sql file from shell script, Do I need to write any logic between below query statements?

    DROP TABLE Table1;
    DROP TABLE Table2;
    DROP TABLE Table2;"


  3. #2
    Join Date
    Jul 2016
    Location
    Moscow
    Posts
    299
    Provided Answers: 45
    Hi,

    Uncheck Session->Session Properties->SQL->"Abort on Error" in Squirrel.
    Regards,
    Mark.

  4. #3
    Join Date
    Jul 2017
    Posts
    3
    Provided Answers: 1

    Thumbs up

    Quote Originally Posted by mark.bb View Post
    Hi,

    Uncheck Session->Session Properties->SQL->"Abort on Error" in Squirrel.
    Thank you very much for your help.
    It is working in Squirrel.

    Now if in case, I have to execute same logic through external .sql file from shell script, Do I need to write any logic between below query statements?

    DROP TABLE Table1;
    DROP TABLE Table2;
    DROP TABLE Table2;
    Last edited by jpate06; 07-13-17 at 12:01. Reason: To modify comments

  5. #4
    Join Date
    Apr 2012
    Posts
    1,143
    Provided Answers: 27
    If you want to ignore DB2 errors when running a shell script you have two options
    (1) inside the script you can use
    update command options using s off;
    drop table ...
    update command options using s on;

    (2) Or a possibly more clean approach is to declare a continue handler to ignore the sqlstate for the condition object not found, then drop the table.

  6. #5
    Join Date
    Jul 2017
    Posts
    3
    Provided Answers: 1

    Thumbs up

    Thank you very much for your answer.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •