I have a function defined as following in Greenplum postgres
CREATE OR REPLACE FUNCTION vin_temp_func(j text) RETURNS integer AS $$
Declare varx integer;
BEGIN
select count(*) into varx
from T_perf a
left join T_profile b on a.sr_number = b.sr_number where b.product_name like '%V1%' and
a.submit_date >= (('2013-02-01'::date - CAST(EXTRACT(DOW FROM '2013-02-01'::date) as int)) - 7)+'1 week'::interval and
a.submit_date <= ('2013-02-01'::date - CAST(EXTRACT(DOW FROM '2013-02-01'::date)+1 as int)) + '1 week'::interval+'23 hours'::interval+'59 minutes'::interval+'59 seconds'::interval
and b.product_name = j;
RETURN varx;
END;
$$ LANGUAGE plpgsql;
Table Defined like this
drop table if exists prod_week_A;
create table prod_week_A as (
select product_name
from T_profile where product_name like '%V1%' limit 100)
When I try to execute following I get the error "function cannot execute on segment because it accesses relation"
select product_name, vin_temp_func(product_name)
from prod_week_A limit 100;
Could some one help me out fix this . Thanks!