In this article, we will talk about how to perform the insert operation in PostgreSQL with the help of variables.
1 2 3 4 5 6 7 8 | DO $$ DECLARE isim VARCHAR(30) := 'selcan'; soyisim VARCHAR(30) := 'gül'; telefon BIGINT := '03322225110'; BEGIN insert into veliler(adi,soyadi, evtelefon) values (isim,soyisim, telefon); END $$; |
In the example above, we define our variables after the declare section.
We add the columns we want to add data to between the begin and end blocks (after the insert into clause), and we add our variables (in parentheses) in the values section.
Let’s check whether our data has been added to our table by doing select.