if exists

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • anusha1251
    New Member
    • Aug 2012
    • 1

    if exists

    I have an if exists statement

    if exists( SELECT EMAIL_ADDR FROM TABLE WHERE EMAIL_ADDR = 'kata@gmail.com ')
    THEN DELETE FROM TABLE WHERE EMAIL_ADDR = 'kata@gmail.com '
    Else
    INSERT INTO TABLE(EMAIL_ADD R) VALUES('katam@g mail.com')
    End if

    I tried different ways I always get the error

    ERROR [42601] [IBM][DB2] SQL0199N The use of the reserved word "IF" following "" is not valid. Expected tokens may include: "<ERR_STMT> <WNG_STMT> GET SQL SAVEPOINT HOLD FREE ASSOCIATE".
  • kadghar
    Recognized Expert Top Contributor
    • Apr 2007
    • 1302

    #2
    Use parenthesis:

    IF(Exists(...

    IF is a function for this matter.

    Comment

    Working...