samedi 25 avril 2015

How can I update a table based on a plpgsql instruction loop on PostgreSQL 8.3.16?


I got a problem I not sure how to solve it so far...

I have two tables that are related to each other with a 1 x n relation. I will try to describe the more importants fields below:

Table One - company:id PK,companyname varchar;
Table Two - training: course varchar,companyid bigint FK,id PK;

The problem is: I would like to update the information on course field of the table training because there are many courses with the same name. My idea is use something like

for s in 1..n loop 
update training set course = course || s;
end loop;


Aucun commentaire:

Enregistrer un commentaire