3

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
2
  • What do you pass void as argument types list ? Commented Feb 20, 2015 at 14:37
  • Becouse I though that it needs the return type Commented Feb 20, 2015 at 14:38

1 Answer 1

7
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.

Sign up to request clarification or add additional context in comments.

4 Comments

thanks for your reply, but it doesnt work for me :(, this is returning ERROR: function updatestat(timestamp without time zone, integer, integer) does not exist. but when I do a \df in the CLI this is showing me the function as you describe: see this image
@lante even with the quotes ? I left those out of the first edit, sorry. They're necessary to get the mixed case name to work.
@lante: for details on why you need the quotes, please see the manual: postgresql.org/docs/current/static/… In general it's better to avoid quoted identifiers alltogether.
in my case, I created two functions with the same name, one with json param and one with 3 text params. To drop one, in psql (CLI), I typed DROP FUNCTION my_function( then I typed tab keyboard key and psql suggest json or text, text, text

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.