我有以下功能:
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;
我该如何放弃这样的功能?
我尝试了以下内容:
# DROP FUNCTION updateStat(void);
ERROR: function updatestat(void) does not exist
# DROP FUNCTION updateStat();
ERROR: function updatestat() does not exist
答案 0 :(得分:4)
DROP FUNCTION "updateStat"(timestamp without time zone, integer, integer);
您可能需要考虑在创建脚本中使用CREATE OR REPLACE FUNCTION...
,这样您就可以重新定义它,而无需每次都删除它。