I'm trying to insert values into a database using prepared statements, but sometimes I need to insert for a certain value the literal 'DEFAULT', how do I do this?
CREATE TABLE test (id int, firstname text default 'john', lastname text default 'doe');
This is what I want to do, but then using a prepared statement:
insert into test (id, firstname, lastname) VALUES ('1', DEFAULT, DEFAULT);
But this is resulting in an error (for obvious reasons):
PREPARE testprep (integer, text, text) AS INSERT INTO test (id, firstname, lastname) VALUES ($1, $2, $3);
EXECUTE testprep('1',DEFAULT,DEFAULT);
The Error:
ERROR: syntax error at or near "DEFAULT"
Both examples I created using SQL-Fiddle: