I have function that updates some fields, I developed in PostgresSql but I have problem that when I'm executing function the programs(Navicat or Pgadmin) asking me "Excuse! function returns <>! rollback or commit" screenshot of message attached message ! It's work when I pressing either commit or rollback! but I want to commit automatically and never ask me any question!! I tried to write BEGIN , End but still message!
Here is my code:
CREATE OR REPLACE FUNCTION "whis2011"."ComputeRtbAdPlaceCtr"() RETURNS "void"
AS $BODY$
BEGIN
UPDATE "whis2011"."RtbActiveSitePlaces"
SET "Ctr" = vl."ctr",
"AverageCpm" = vl."avcpm",
"AverageClickCost" = vl."avclickcost",
"IsCtrPredicted" = vl."isctrpredicted",
"ComputedBalance" = vl."balance"
FROM "whis2011"."RtbActiveSitePlaces" pl
JOIN "whis2011"."View_RtbActiveSitePlacesCtrWeekly" vl on pl."Id" = vl."Id";
END;
$BODY$
LANGUAGE plpgsql
COST 100
CALLED ON NULL INPUT
SECURITY INVOKER
VOLATILE;
FROM "whis2011"."RtbActiveSitePlaces" plYou should not include the target table in theFROM ...list in Postgres's SQL. (and you dont need, plpgsql for this simple update, plain SQL will do)BEGINandENDof the function withBEGINandCOMMITfor transaction handling in SQL? A Postgres function itself cannot be auto-committed - that is up to the calling SQL context.