Re: Setting a field to default if blank value - Mailing list pgsql-general

From Dennis Gearon
Subject Re: Setting a field to default if blank value
Date
Msg-id 3EAD71AA.5090505@cvc.net
Whole thread Raw
In response to Re: Setting a field to default if blank value  ("Robert Fitzpatrick" <robert@webtent.com>)
List pgsql-general
just put '' in the insert statement, it will be a blank field, no big deal.

Robert Fitzpatrick wrote:
>>Robert Fitzpatrick wrote:
>>
>>>Looking for the best way of handling this, would like to do
>>
>>it in the
>>
>>>database and not in my apps. I set a field to 'Not Null', but if a
>>>blank value comes in, the field will accept it as just
>>
>>that, a blank
>>
>>>string. How can avoid this using a trigger or function? I thought
>>>about a function that would check the field and then place
>>
>>a trigger,
>>
>>>but that gets to be a lot of functions and triggers for different
>>>fields. Is there a way to pass a field name to the function? (in
>>>plpgsql)
>>>
>>>Or what is the best way to handle this for many different fields in
>>>many tables?
>
>
>>If you mean blank like '', then if the field is a string, it
>>would be normal behavior as is.
>>
>
>
> Yes, they are strings (varchar). Know the best way to handle it?
>
> --
> Robert
>
>
>


pgsql-general by date:

Previous
From: Dennis Gearon
Date:
Subject: Re: problems restoring 7.2.1 dump to 7.3.2
Next
From: Dennis Gearon
Date:
Subject: Re: Selecting the most recent date