drop function if exists sp_delete_article( p_article_id integer );
create or replace function sp_delete_article( p_article_id integer ) returns integer as $$
declare
	retval integer;
begin
	retval:=0;
	select count(*) into retval from articles where article_id=p_article_id;
	delete from larticles where article_id=p_article_id;
	delete from articles where article_id=p_article_id;
	return retval;
end;
$$language plpgsql;

comment on function sp_delete_article( p_article_id integer ) is 'delete article';
