Using DEFAULT as a parameter value with PQexecPrepare() - Mailing list pgsql-general

From EXT-Rothermel, Peter M
Subject Using DEFAULT as a parameter value with PQexecPrepare()
Date
Msg-id 135FBA69693F3B46A0BE8D4FF49D2D83494A55ACD0@XCH-NW-01V.nw.nos.boeing.com
Whole thread Raw
Responses Re: Using DEFAULT as a parameter value with PQexecPrepare()  ("Greg Sabino Mullane" <greg@turnstep.com>)
List pgsql-general

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

pgsql-general by date:

Previous
From: Ashesh Vashi
Date:
Subject: Re: EnterpriseDB install of Postgres on Ubuntu 10.04 library path issues - no version information available (required by /lib/libblkid.so.1)
Next
From: Adrian Klaver
Date:
Subject: Re: Hot synchron backup doesn't start