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
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;
$$;CREATE TABLE
INSERT 0 1
CREATE FUNCTIONCALL add_points(1, 10);ERROR: 42809: add_points(integer, integer) is not a procedure
LINE 1: CALL add_points(1, 10);
^
HINT: To call a function, use SELECT.SELECT proname, prokind, pg_get_function_result(oid) AS returns FROM pg_proc WHERE proname = 'add_points'; 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.
SELECT add_points(1, 10);
SELECT member_id, points FROM members; 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
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());
$$;CREATE TABLE
CREATE PROCEDURESELECT close_month('2026-11');ERROR: 42809: close_month(unknown) is a procedure
LINE 1: SELECT close_month('2026-11');
^
HINT: To call a procedure, use CALL.SELECT proname, prokind FROM pg_proc WHERE proname = 'close_month'; proname | prokind
-------------+---------
close_month | p
(1 row)prokind is p (procedure). CALL close_month('2026-11') ran and the row was inserted.
CALL close_month('2026-11');
SELECT ym FROM month_close;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
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;CREATE TABLE
CREATE VIEWDROP TABLE sales_report;ERROR: 42809: "sales_report" is not a table
HINT: Use DROP VIEW to remove a view.SELECT table_name, table_type FROM information_schema.tables WHERE table_schema = 'lab_a' ORDER BY table_name; 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.
DROP VIEW sales_report;DROP VIEWDROP VIEW sales_report; removed it, and only the sales table remains.
SELECT table_name, table_type FROM information_schema.tables WHERE table_schema = 'lab_a' ORDER BY table_name; 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
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;CREATE TABLE
INSERT 0 1
CREATE VIEWALTER TABLE customer_v ADD COLUMN phone text;ERROR: 42809: ALTER action ADD COLUMN cannot be performed on relation "customer_v"
DETAIL: This operation is not supported for views.SELECT relname, relkind FROM pg_class WHERE relname IN ('customers', 'customer_v') ORDER BY relname; 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.
ALTER TABLE customers ADD COLUMN phone text;
CREATE OR REPLACE VIEW customer_v AS SELECT cust_id, name, phone FROM customers;ALTER TABLE
CREATE VIEWAdd the column to the base table, then redefine the view with CREATE OR REPLACE VIEW including the new column. The view now shows phone.
UPDATE customers SET phone = '010-1234-5678' WHERE cust_id = 1;
SELECT cust_id, name, phone FROM customer_v;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