Re: How to insert default value with libpq?

Поиск
Список
Период
Сортировка
От Peter Eisentraut
Тема Re: How to insert default value with libpq?
Дата
Msg-id 4aad674b-64c1-61d4-42f1-0adb292ee989@2ndquadrant.com
обсуждение исходный текст
Ответ на How to insert default value with libpq?  (sanpi+postgersql@homecomputing.fr)
Ответы Re: How to insert default value with libpq?
Список pgsql-interfaces
On 2020-04-27 15:02, sanpi+postgersql@homecomputing.fr 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



В списке pgsql-interfaces по дате отправления:

Предыдущее
От: sanpi+postgersql@homecomputing.fr
Дата:
Сообщение: How to insert default value with libpq?
Следующее
От: "Greg Sabino Mullane"
Дата:
Сообщение: DBD::Pg version 3.11.1 released