I am currently dynamically building a SQL command in my C code like that executes SQL statement like:
INSERT INTO t (c1,c2,c3,c4,c5) VALUES (‘abc’, 1, DEFAULT, 9, 3);
I execute the command using PQexec() of libpq.
The application logic determines when to use the default values for several columns.
The first two columns do not default values so they must always be specified.
I was looking for a to use a prepared statement for this operation.
PREPARE myinsert AS “INSERT INTO t ( c1, c2, c3, c4, c5) VALUES ( $1, $2, $3, $4, $5);
Now I want to execute this prepared statement something like:
EXECUTE myinsert ( ‘abc’, 1, DEFAULT, 9, 3);
Is there any way to specify the column’s default value as a parameter value?
Doesn’t look like I can do this using the PQexecPrepared() function of libpq.
Doesn’t look like I can do this using PQexecParams() as well.
I am using version 8.4 of PostgreSQL.
Thanks,
Pete Rothermel