public inbox for [email protected]
help / color / mirror / Atom feedFrom: Peter Eisentraut <[email protected]>
To: [email protected]
To: [email protected]
Subject: Re: How to insert default value with libpq?
Date: Tue, 28 Apr 2020 16:25:48 +0200
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
On 2020-04-27 15:02, [email protected] wrote:
> I would like to insert the default value for a field with libpq, but
> inserting null or "default" doesn’t work.
You cannot represent that using query parameters (PQexecParams). Query
parameters always mean, use this rather than the default value.
To do what you want either write DEFAULT or leave off the column
altogether, for example
INSERT INTO test (id) VALUES (DEFAULT)
but this needs to be pasted into the query string, not passed as a
parameter.
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
view thread (3+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: How to insert default value with libpq?
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox