Update table with if statement PS/SQL

Posted by Matt on Stack Overflow See other posts from Stack Overflow or by Matt
Published on 2010-12-23T18:51:56Z Indexed on 2010/12/23 18:53 UTC
Read the original article Hit count: 173

Filed under:
|
|
|

I am trying to do something like this but am having trouble putting it into oracle coding.

BEGIN
IF ((SELECT complete_date FROM task_table WHERE task_id = 1) IS NULL)
THEN
 UPDATE task_table SET complete_date = //somedate WHERE task_id = 1;
ELSE
 UPDATE task_table SET complete_date = NULL;
END IF;
END;

But this does not work i also tried

IF EXISTS(SELECT complete_date FROM task_table WHERE task_id = 1)

with no luck

© Stack Overflow or respective owner

Related posts about Oracle

Related posts about update