ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Check table exists SQL

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Check table exists SQL

    Hi

    Does anybody know how to check the existance of a table before deleting it?

    I am using RUNSQLSTM and I would like to do something like:

    if table qtemp/temp exists then drop table qtemp/temp;

    Thanks

  • #2
    Re: Check table exists SQL

    With RUNSQLSTM there is no way to add conditions or to conditionally execute commands.l

    If there is only one or several delete statements, you may set the Error Level to 21. (If you try to delete a not exiting object you'll get error level 20).
    After execution check the log if there are other errors with level 20.

    PHP Code:
    RUNSQLSTM SRCFILE(MYLIB/QSQLSRCSRCMBR(MyMbrERRLVL(21
    Birgitta

    Comment


    • #3
      Re: Check table exists SQL

      Thanks Birgitta, that works fine now.

      Cheers.

      Comment

      Working...
      X