In this article, we will discuss how to perform the update process with the help of variables in PostgreSQL.
I want to update the name in the parents table as ‘selcan’ and the e-mail address as ‘selcengül@gmail.com’.
1 2 3 4 5 6 7 |
DO $$ DECLARE isim VARCHAR(30) := 'selcan'; mail VARCHAR(150) := 'selcengül@gmail.com'; BEGIN UPDATE veliler SET email = mail WHERE adi= isim ; END $$; |
As seen above, by setting the ‘adi’ column equal to the ‘isim’ variable, we write the part whose name is selcan here.
In the Set section, I want to update the email address in the parents table with the data defined in the mail variable.