drop function if exists sp_get_user_id_from_oldid( p_oldid integer );
create function sp_get_user_id_from_oldid( p_oldid integer ) returns integer as $$
declare
	retval integer;
begin
	select user_id into retval from members where oldid=p_oldid;
	if retval is null then
		retval:=0;
	end if;
	return retval;
end;
$$language plpgsql;

comment on function sp_get_user_id_from_oldid( p_oldid integer ) is 'temporary function for migration - getting user_id on oldid';

drop function if exists sp_get_member_id_from_oldid( p_oldid integer );
create function sp_get_member_id_from_oldid( p_oldid integer ) returns integer as $$
declare
	retval integer;
begin
	select member_id into retval from members where oldid=p_oldid;
	if retval is null then
		retval:=0;
	end if;
	return retval;
end;
$$language plpgsql;

comment on function sp_get_member_id_from_oldid( p_oldid integer ) is 'temporary function for migration - getting member_id on oldid';
