I have the following function:
CREATE FUNCTION "updateStat"(_request_date timestamp without time zone, _calls integer, _latency integer) RETURNS void AS $$
BEGIN
LOCK TABLE "statistics" IN SHARE ROW EXCLUSIVE MODE;
WITH upsert AS (UPDATE "statistics" set calls = calls + _calls, total_latency = total_latency + _latency WHERE request_date=_request_date RETURNING request_date)
INSERT INTO "statistics" ("request_date", "calls", "total_latency") SELECT _request_date, _calls, _latency WHERE NOT EXISTS (SELECT "request_date" FROM upsert);
END;
$$ LANGUAGE plpgsql;
How can I drop such function?
I have tried the following:
# DROP FUNCTION updateStat(void);
ERROR: function updatestat(void) does not exist
# DROP FUNCTION updateStat();
ERROR: function updatestat() does not exist
DROP FUNCTION "updateStat"(timestamp without time zone, integer, integer);
You might want to consider using CREATE OR REPLACE FUNCTION... in your create script, so you can redefine it without needing to drop it each time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With