I have a lookup table that contains a column of sources (from various hard-coded campaigns captured through the web services API I created) and the corresponding brands that should be associated with them. This means that I can give the brand records where the brand is zero, so that they can be greeted with a specific template using the marketing automation tool.
I, in the end, condemn this API and replace it with where the brand is needed, but at the same time I have to create a temporary solution until I give all my brands time to change their API calls.
I wrote this function:
CREATE OR REPLACE FUNCTION public.brand_lookup(IN i_brand TEXT ) RETURNS SETOF RECORD VOLATILE AS $$ BEGIN RETURN QUERY UPDATE subscriber SET brand = (SELECT brand FROM brand_translation WHERE source = subscriber.source); END; $$ LANGUAGE plpgsql;
And the trigger to start the function when inserting a record:
CREATE TRIGGER brand_translation AFTER INSERT ON subscriber FOR EACH ROW EXECUTE PROCEDURE public.brand_lookup();
But my trigger returns with the error that "ERROR: function public.brand_lookup () does not exist" (but it was created successfully). Besides the fact that my trigger does not see my function, what do I mean? I honestly noob in functions ( as you probably can tell).
source share