CASE WHEN ((SELECT COUNT(id) FROM users) > 0) THEN
    BEGIN
       INSERT INTO users(username,password) VALUES('Moshe','Ahuva');
   END
ELSE 
    BEGIN
       INSERT INTO users(username,password) VALUES('Zvi','Idan');
    END
END

My aim is to save with a condition. but it fails and says: "Check the manual that correponds to the right syntax near ELSE BEGIN ....". please re-write it better.

Docs. CASE needs a value to inspect:

CASE (SELECT COUNT(id) FROM users)
    WHEN 0 THEN BEGIN END;
    ELSE BEGIN END;
END CASE;

Never tried this with inserts though. Is there a reason you are using CASE over IF?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.