i have a table abonnement
with a column topic
and other column. i want to update the value of the column topic
. But before updating, i want to verify if this column exist or not to use this script with other developers in my team. If exist, I do update, else, i must to create this column and after do update.
Here is my script :
IF EXISTS (select topic from abonnement)
then
update abonnement set topic ='valeurTopic';
else
ALTER TABLE abonnement ADD COLUMN topic character varying;
update abonnement set topic= 'valeurTopic';
end if;
I had an error:
ERREUR: erreur de syntaxe sur ou près de « IF »
LINE 1: IF EXISTS (SELECT topic
^
Any solution please ?