Don't know if this will get attached to the conversation, but here is how
I have dealt with this.
insert into names (name, created_date) values ($1, default);
update names n set created_date = coalesce($2, n.craeted_date) where name
= $1;
So basically insert all of your non-defaulted columns wi
On Tue, Sep 29, 2009 at 04:04:46AM -0700, Postgres User wrote:
> >> > I'm trying to write an INSERT INTO statement that will use a DEFAULT
> >> > value when an input parameter is null.
[ workaround given ]
> Again, this approach works for a simple example. But for a larger
> function with any n
>> >
>> > I'm trying to write an INSERT INTO statement that will use a DEFAULT
>> > value when an input parameter is null.
>> >
>> Neither of my 2 methods are pretty.
>> 1) Use a trigger.
>> 2) Grab and cast the default value from the information_schema.columns
>> view and plug it in.
>>
>> Another
Postgres User wrote:
>>> I'm trying to write an INSERT INTO statement that will use a DEFAULT
>>> value when an input parameter is null.
>>>
>> Neither of my 2 methods are pretty.
>> 1) Use a trigger.
>> 2) Grab and cast the default value from the information_schema.columns
>> view and plug it in.
In response to Sim Zacks :
> >
> > I'm trying to write an INSERT INTO statement that will use a DEFAULT
> > value when an input parameter is null.
> >
> Neither of my 2 methods are pretty.
> 1) Use a trigger.
> 2) Grab and cast the default value from the information_schema.columns
> view and plu
>> I'm trying to write an INSERT INTO statement that will use a DEFAULT
>> value when an input parameter is null.
>>
> Neither of my 2 methods are pretty.
> 1) Use a trigger.
> 2) Grab and cast the default value from the information_schema.columns
> view and plug it in.
>
> Another option is to bui
>
> I'm trying to write an INSERT INTO statement that will use a DEFAULT
> value when an input parameter is null.
>
Neither of my 2 methods are pretty.
1) Use a trigger.
2) Grab and cast the default value from the information_schema.columns
view and plug it in.
Another option is to build your i
Hi,
I'm trying to write an INSERT INTO statement that will use a DEFAULT
value when an input parameter is null.
Here's the function that fails to compile. I tried replacing Coalesce
with a Case statement but that fails as well. Note that if you
replace the condition with a simple 'Default' it c