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 = "">WHEREo1.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_inoWhy does that happen?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
- Follow-Ups:
- Re: PL/PGSQL + inserts+updates+limit - Postgres 9.3
- From: Patrick Baker
- References:
- PL/PGSQL + inserts+updates+limit - Postgres 9.3
- From: Patrick Baker
- Re: PL/PGSQL + inserts+updates+limit - Postgres 9.3
- From: Adrian Klaver
- Re: PL/PGSQL + inserts+updates+limit - Postgres 9.3
- From: Patrick Baker
- Re: PL/PGSQL + inserts+updates+limit - Postgres 9.3
- From: David G. Johnston
- Re: PL/PGSQL + inserts+updates+limit - Postgres 9.3
- From: Patrick Baker
- Re: PL/PGSQL + inserts+updates+limit - Postgres 9.3
- From: Adrian Klaver
- Re: PL/PGSQL + inserts+updates+limit - Postgres 9.3
- From: Patrick Baker
- Prev by Date: Re: WAL's listing in pg_xlog by some sql query
- Next by Date: Re: WAL's listing in pg_xlog by some sql query
- Previous by thread: Re: PL/PGSQL + inserts+updates+limit - Postgres 9.3
- Next by thread: Re: PL/PGSQL + inserts+updates+limit - Postgres 9.3
- Index(es):
[Index of Archives] [Postgresql Jobs] [Postgresql Admin] [Postgresql Performance] [Linux Clusters] [PHP Home] [PHP on Windows] [Kernel Newbies] [PHP Classes] [PHP Books] [PHP Databases] [Postgresql & PHP] [Yosemite]