I have written a simple PG SP as a proof of concept. However, I am getting an error mesage when I run the SP. Here is the SQL for the schema and the SP:
CREATE TABLE foobar
(
forename VARCHAR(255),
surname VARCHAR(32),
enrolement_ts TIMESTAMP,
age SMALLINT,
major VARCHAR(32),
user_id INTEGER
);
CREATE OR REPLACE FUNCTION insert_foobar (
forename VARCHAR(255),
surname VARCHAR(32),
age SMALLINT,
major VARCHAR(32) ) RETURNS VOID AS $$
INSERT INTO foobar VALUES (forename, surname, getdate(), age, major, user_id());
$$ LANGUAGE sql;
When I enter the function definition at the command line, I get the following error:
ERROR: column "forename" does not exist
LINE 6: INSERT INTO foobar VALUES (forename, surname,...
^
Can anyone spot/explain what is causing this error?. Clearly, the column forename exists in the table schema, so I don't understand the error message.