Postgres Stored Procedures
A better function to convert dollars to euros
create function euros(dollars numeric(10, 2)) returns numeric(10, 2) as $$
declare
to_euros_rate numeric(16, 6);
begin
select to_rate
into to_euros_rate
from conversion
where currency = 'euro';
return (dollars * to_euros_rate)::numeric(10, 2);
end
$$ language plpgsql;
|