When creating the following function in PostgreSQL, I get
ERROR: relation with OID 80424 does not exist CONTEXT: SQL function "test_update_icd_code" statement 7 SQL state: 42P01
So how do I create a table within a function?
(Note: the table will be deleted at the completion of the function.)
TIA
CREATE OR REPLACE FUNCTION test_update_icd_code()
RETURNS void
AS $$
-- Create a test table that references dx_log.
DROP TABLE IF EXISTS test;
CREATE TABLE test
(
recid serial PRIMARY KEY,
dx_log_recid integer NOT NULL,
CONSTRAINT test_dx_log_fk FOREIGN KEY (dx_log_recid)
REFERENCES dx_log (recid) MATCH SIMPLE
ON UPDATE CASCADE
ON DELETE RESTRICT
)
WITH (
OIDS = FALSE
);
-----------
$$ LANGUAGE 'sql' VOLATILE;
nova.testtotestand now it works OK. Have you tried removing thenovaqualifier? - ravioli