lante
lante

Reputation: 7336

Drop function in Postgres

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

Upvotes: 3

Views: 4363

Answers (1)

cms
cms

Reputation: 5982

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.

Upvotes: 7

Related Questions