Re: referencing other INSERT VALUES columns inside the insert - Mailing list pgsql-general

From Jim Nasby
Subject Re: referencing other INSERT VALUES columns inside the insert
Date
Msg-id 564B5407.9090407@BlueTreble.com
Whole thread Raw
In response to Re: referencing other INSERT VALUES columns inside the insert  (Geoff Winkless <pgsqladmin@geoff.dj>)
List pgsql-general
On 11/17/15 8:53 AM, Geoff Winkless wrote:
> It takes the column's default value, since it's not explicit in the
> first INSERT.

Not sure if it would help or not, but you can use pg_get_expr(adbin,
adrelid) against pg_attrdef to get the default for a column. That would
let you dynamically insert the expression that generates the default
value into the VALUES clause.

start psql with the -E option and do \d on a table with e default to see
this in action.
--
Jim Nasby, Data Architect, Blue Treble Consulting, Austin TX
Experts in Analytics, Data Architecture and PostgreSQL
Data in Trouble? Get it in Treble! http://BlueTreble.com


pgsql-general by date:

Previous
From: Jim Nasby
Date:
Subject: Re: Querying same lookup table with multiple columns based on another view
Next
From: Willy-Bas Loos
Date:
Subject: Re: database corrupt