PostgreSQL 17.12Lab-verified · 2026-11-30

PostgreSQL 42809: wrong object type (is not a procedure, is not a table)

The command is meant for a different kind of object than the one you named.

PostgreSQL 17.12
42809: add_points(integer, integer) is not a procedure

Jump to a cause

  1. 01CALL on a function: add_points(integer, integer) is not a procedure
  2. 02SELECT on a procedure: close_month(unknown) is a procedure
  3. 03DROP TABLE on a view
  4. 04ALTER TABLE ... ADD COLUMN on a view

Lab-verifiedReproduced and fixed on PostgreSQL 17.12 · 2026-11-30 · container image postgres:17

SQLSTATE 42809 (wrong_object_type) means the object exists, but it is the wrong kind for the command: a function where a procedure is expected, or a view where a table is expected.

The message names the object, and the HINT or DETAIL line usually tells you which command to use instead. Below are four cases reproduced on PostgreSQL 17.

01CALL on a function: add_points(integer, integer) is not a procedure

add_points was created with CREATE FUNCTION, but it was invoked with CALL. In PostgreSQL, CALL is only for procedures. The HINT says it directly: To call a function, use SELECT.

Setup
Setuprun as lab_a
CREATE TABLE members (member_id int PRIMARY KEY, points int NOT NULL DEFAULT 0);
INSERT INTO members VALUES (1, 0);
CREATE FUNCTION add_points(p_member int, p_points int) RETURNS int
LANGUAGE sql AS $$
  UPDATE members SET points = points + p_points WHERE member_id = p_member RETURNING points;
$$;
OUTPUT
CREATE TABLE
INSERT 0 1
CREATE FUNCTION
Reproducerun as lab_a
CALL add_points(1, 10);
✕ ERROR
ERROR:  42809: add_points(integer, integer) is not a procedure
LINE 1: CALL add_points(1, 10);
             ^
HINT:  To call a function, use SELECT.
Checkrun as lab_a
SELECT proname, prokind, pg_get_function_result(oid) AS returns FROM pg_proc WHERE proname = 'add_points';
OUTPUT
  proname   | prokind | returns
------------+---------+---------
 add_points | f       | integer
(1 row)

pg_proc.prokind is f (function) and it returns integer. Calling it with SELECT add_points(1, 10) returned 10 and updated the row.

After the fixrun as lab_a
SELECT add_points(1, 10);
SELECT member_id, points FROM members;
✓ SUCCESS
 add_points
------------
         10
(1 row)

 member_id | points
-----------+--------
         1 |     10
(1 row)

02SELECT on a procedure: close_month(unknown) is a procedure

close_month is a procedure (CREATE PROCEDURE). Procedures cannot be used inside SELECT; the HINT says To call a procedure, use CALL.

Setup
Setuprun as lab_a
CREATE TABLE month_close (ym text PRIMARY KEY, closed_at timestamptz);
CREATE PROCEDURE close_month(p_ym text)
LANGUAGE sql AS $$
  INSERT INTO month_close VALUES (p_ym, now());
$$;
OUTPUT
CREATE TABLE
CREATE PROCEDURE
Reproducerun as lab_a
SELECT close_month('2026-11');
✕ ERROR
ERROR:  42809: close_month(unknown) is a procedure
LINE 1: SELECT close_month('2026-11');
               ^
HINT:  To call a procedure, use CALL.
Checkrun as lab_a
SELECT proname, prokind FROM pg_proc WHERE proname = 'close_month';
OUTPUT
   proname   | prokind
-------------+---------
 close_month | p
(1 row)

prokind is p (procedure). CALL close_month('2026-11') ran and the row was inserted.

After the fixrun as lab_a
CALL close_month('2026-11');
SELECT ym FROM month_close;
✓ SUCCESS
CALL
   ym
---------
 2026-11
(1 row)

03DROP TABLE on a view

sales_report is a view, so DROP TABLE refuses it with "sales_report" is not a table and the hint Use DROP VIEW to remove a view. This often happens in migration scripts after a table was replaced by a view.

Setup
Setuprun as lab_a
CREATE TABLE sales (sale_id int PRIMARY KEY, amount numeric);
CREATE VIEW sales_report AS SELECT count(*) AS cnt, sum(amount) AS total FROM sales;
OUTPUT
CREATE TABLE
CREATE VIEW
Reproducerun as lab_a
DROP TABLE sales_report;
✕ ERROR
ERROR:  42809: "sales_report" is not a table
HINT:  Use DROP VIEW to remove a view.
Check the causerun as lab_a
SELECT table_name, table_type FROM information_schema.tables WHERE table_schema = 'lab_a' ORDER BY table_name;
OUTPUT
  table_name  | table_type
--------------+------------
 sales        | BASE TABLE
 sales_report | VIEW
(2 rows)

In information_schema.tables, sales_report has table_type VIEW while sales is a BASE TABLE.

Fixrun as lab_a
DROP VIEW sales_report;
OUTPUT
DROP VIEW

DROP VIEW sales_report; removed it, and only the sales table remains.

After the fixrun as lab_a
SELECT table_name, table_type FROM information_schema.tables WHERE table_schema = 'lab_a' ORDER BY table_name;
✓ SUCCESS
 table_name | table_type
------------+------------
 sales      | BASE TABLE
(1 row)

04ALTER TABLE ... ADD COLUMN on a view

customer_v is a view. Columns cannot be added to a view with ALTER TABLE; the DETAIL line says This operation is not supported for views.

Setup
Setuprun as lab_a
CREATE TABLE customers (cust_id int PRIMARY KEY, name text);
INSERT INTO customers VALUES (1, 'Kim');
CREATE VIEW customer_v AS SELECT cust_id, name FROM customers;
OUTPUT
CREATE TABLE
INSERT 0 1
CREATE VIEW
Reproducerun as lab_a
ALTER TABLE customer_v ADD COLUMN phone text;
✕ ERROR
ERROR:  42809: ALTER action ADD COLUMN cannot be performed on relation "customer_v"
DETAIL:  This operation is not supported for views.
Check the causerun as lab_a
SELECT relname, relkind FROM pg_class WHERE relname IN ('customers', 'customer_v') ORDER BY relname;
OUTPUT
  relname   | relkind
------------+---------
 customer_v | v
 customers  | r
(2 rows)

In pg_class, relkind is v (view) for customer_v and r (ordinary table) for customers.

Fixrun as lab_a
ALTER TABLE customers ADD COLUMN phone text;
CREATE OR REPLACE VIEW customer_v AS SELECT cust_id, name, phone FROM customers;
OUTPUT
ALTER TABLE
CREATE VIEW

Add the column to the base table, then redefine the view with CREATE OR REPLACE VIEW including the new column. The view now shows phone.

After the fixrun as lab_a
UPDATE customers SET phone = '010-1234-5678' WHERE cust_id = 1;
SELECT cust_id, name, phone FROM customer_v;
✓ SUCCESS
UPDATE 1
 cust_id | name |     phone
---------+------+---------------
       1 | Kim  | 010-1234-5678
(1 row)

FAQ

What does "is not a procedure" mean in PostgreSQL?

You used CALL on a function. Functions are called with SELECT func(...); only objects created with CREATE PROCEDURE can be used with CALL.

How do I fix "is a procedure" / "To call a procedure, use CALL"?

Replace SELECT proc(...) with CALL proc(...). You can check the kind in pg_proc.prokind: f is a function, p is a procedure.

How do I drop or change a view that gives "is not a table"?

Use the view commands: DROP VIEW to remove it, and for new columns add them to the base table and run CREATE OR REPLACE VIEW.

How we verify

Each scenario starts from fresh database users. A script runs the setup, confirms the exact error code, applies the fix and runs the statement again. The output shown is what the database printed, saved by the script.

lab_a and lab_b are ordinary roles created for the test, each owning a schema of the same name; postgres is the superuser. PostgreSQL 17.12