If value is null then take the next higher value I have a function which requires 3 values and then uses these values to return a value from a table.
FUNCTION: odwh_data.annual_rental(connection_type,data_rate,date)

CREATE OR REPLACE FUNCTION odwh_data.ead_charge_annual_rental(
    &quot;connection_type$&quot; character,
    &quot;data_rate$&quot; integer,
    &quot;start_datetime$&quot; timestamp without time zone)
  RETURNS numeric AS
    
SELECT  
    annual_rental
FROM    
    odwh_system.ead_credit_charge
WHERE   
    connection_type = connection_type$
AND data_rate = data_rate$
AND start_datetime$::date BETWEEN COALESCE(valid_from,start_datetime$::date) AND COALESCE(valid_to,start_datetime$::date);

Below is an example of the odwh_system.ead_credit_charge table:

Currently is a data_rate is passed that is not in the list is will not return an annual_rental value. I would like to update this so if the value for data_rate is 30 it will take the next higher value e.g. 100 so annual_rental of £185.00 would be returned.
Currently is a data_rate is passed that is not in the list is will not return an annual_rental value. I would like to update this so if the value for data_rate is 30 it will take the next higher value e.g. 100 so annual_rental of £185.00 would be returned.

Maybe you need
SELECT  
    annual_rental
FROM    
    odwh_system.ead_credit_charge
WHERE   
    connection_type = connection_type$
AND data_rate &gt;= data_rate$
AND start_datetime$::date BETWEEN COALESCE(valid_from,start_datetime$::date) AND COALESCE(valid_to,start_datetime$::date)
ORDER BY data_rate LIMIT 1;

?