PLPGSQL returning number of rows
От | Patrick B |
---|---|
Тема | PLPGSQL returning number of rows |
Дата | |
Msg-id | CAJNY3it+bP1QEYhxPkhms6RTv4Na7ERPfQjJSimV8g4OrGQ5cQ@mail.gmail.com обсуждение исходный текст |
Ответы |
Re: PLPGSQL returning number of rows
|
Список | pgsql-general |
Hi guys,
I'm writing a simple Plpgsql function to delete some data from different tables.
The function starts with a select, and then 2 deletes after that.
How can I return the number of rows that each delete performed?
CREATE or REPLACE FUNCTION delete_ids_clientid(account_id integer)RETURNS integer AS $$declarerow record;account_id integer;BEGINFOR row IN EXECUTE 'SELECTFROMpublic.table2 t2JOINWHEREt2.account_id = ' || account_id || ''LOOPDELETE FROM public.table1 WHERE id IN(SELECTidFROMpublic.table1 t1WHERE);DELETE FROM public.table2 WHERE billable_id IN(SELECTbillable_idFROMpublic.table2 t1WHERE);END LOOP;END$$ language 'plpgsql';
Cheers
В списке pgsql-general по дате отправления: