Re: [GENERAL] Using Insert - Default in a condition expression ??

2009-09-29 Thread brent_despain
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

Re: [GENERAL] Using Insert - Default in a condition expression ??

2009-09-29 Thread Sam Mason
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

Re: [GENERAL] Using Insert - Default in a condition expression ??

2009-09-29 Thread Postgres User
>> > >> > 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

Re: [GENERAL] Using Insert - Default in a condition expression ??

2009-09-29 Thread Richard Huxton
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.

Re: [GENERAL] Using Insert - Default in a condition expression ??

2009-09-28 Thread A. Kretschmer
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

Re: [GENERAL] Using Insert - Default in a condition expression ??

2009-09-28 Thread Postgres User
>> 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

Re: [GENERAL] Using Insert - Default in a condition expression ??

2009-09-28 Thread 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 plug it in. Another option is to build your i

[GENERAL] Using Insert - Default in a condition expression ??

2009-09-28 Thread Postgres User
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