A simple pg/plsql loop example?

You can use: UPDATE advertiser a SET partnerid = r. Partnerid FROM partner_advertiser r WHERE a. Id = r.

Advertiserid Generally, simple relational transformations like these will never need a loop. If you really need one, though, look at postgresql.org/docs/9.0/interactive/plpg... One extra note: any transformation will obviously lose data if advertiserid is not already unique, thus you should first run something like SELECT count(*), advertiserid FROM partner_advertiser GROUP BY advertiserid HAVING COUNT(*) > 1 If any rows get returned by that you will want to fix that manually.

Note that the update succeeds even if there are multiple tuples in partner_advertiser table for a single advertiser. – jmz Feb 25 at 7:02 it works. I never thought there is a simple command like that.

– ivanceras Feb 25 at 7:32.

This also works. Using a simple plsql. CREATE OR REPLACE FUNCTIOn migratePartnerAdvertiser() RETURNS int4 AS ' DECLARE r RECORD; BEGIN FOR r IN SELECT * from partner_advertiser LOOP UPDATE advertiser SET partnerId = r.

PartnerId WHERE id = r. AdvertiserId; END LOOP; return 1; END; ' LANGUAGE plpsql; SELECT migratePartnerAdvertiser() as output.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions