Re: PL/PGSQL + inserts+updates+limit - Postgres 9.3
От | Patrick Baker |
---|---|
Тема | Re: PL/PGSQL + inserts+updates+limit - Postgres 9.3 |
Дата | |
Msg-id | CAJNY3iu-h430JWpiz0xLxhtY0fEKtM_dQj3WXdXhFYw=Ny4vvA@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: PL/PGSQL + inserts+updates+limit - Postgres 9.3 (Patrick Baker <patrickbakerbr@gmail.com>) |
Ответы |
Re: PL/PGSQL + inserts+updates+limit - Postgres 9.3
|
Список | pgsql-general |
I did:
CREATE or REPLACE FUNCTION function_1_data()RETURNS INTEGER AS $$declarerow record;BEGIN-- copying the data to the backup table (not the blobs)FOR row IN EXECUTE 'SELECTt1.file_idFROMtable1_n_b t1JOINtable3_n_b t3 ON t3.file_id = t1. file_id ORDER BY 1 LIMIT 3' LOOP-- Creating the backup table with the essential dataEXECUTE 'INSERT INTO table2_y_b (note_id, size, file_id, full_path)(SELECTt1.note_id,t1.size,t1.file_id,t1.full_pathFROMtable1_n_b t1JOINtable3_n_b t3 ON t3.file_id = t1.file_id) ';-- copying the blobs to the table aboveEXECUTE 'UPDATE table2_y_b t2 SET data =(SELECTo1.dataFROMoriginal_table1_b o1JOINtable3_n_b t3 ON t3.file_id = o1.file_idWHEREt3.migrated = 0ANDt2.file_id = o1.file_id)WHERE t2.file_id = row.file_id ';-- updating the migrated column from 0 to 1EXECUTE 'UPDATEtable2_y_b t2SETmigrated = 1WHEREt2.file_id = row.file_idANDmigrated = 0 ';-- setting the blob as nullEXECUTE 'UPDATEoriginal_table1_b o1SETdata = NULLWHEREo1.file_id = row.file_id ';END LOOP;return row.file_id;END$$ language 'plpgsql';
And I'm getting the error:
missing FROM-clause entry for table "row"
WHERE t2.st_ino = row.st_ino
Why does that happen?
В списке pgsql-general по дате отправления: