Icon View Thread

The following is the text of the current message along with any replies.
Messages 11 to 20 of 23 total
Thread Problems updating table with sql..
Wed, Jun 4 2008 1:34 PMPermanent Link

"Hüseyin Aliz"
Yes, you are right, i have changed the field to be default 0 Smile

Regards,
Hüseyin

"Robert" <ngsemail2005withoutthis@yahoo.com.ar> skrev i en meddelelse
news:8EC9C788-6ED6-4074-8E52-022BD8897669@news.elevatesoft.com...
>
> "Hüseyin Aliz" <haliz@consit.dk> wrote in message
> news:3C5467E1-8894-476B-A213-06C676694D9C@news.elevatesoft.com...
>> Hi Robert,
>>
>> You got a point there Smile
>> It was a problem adding to a null field, i've never used the saldo field
>> before, so the values were null.
>
> Unless there is a specific reason not to, all numeric fields should have a
> default of zero. That prevents this kind of problem.
>
> Robert
>
>

Thu, Jun 5 2008 1:05 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Robert

>Unless there is a specific reason not to, all numeric fields should have a
>default of zero. That prevents this kind of problem.

So would getting rid of the very concept of null <vbg>

Roy Lambert [null hater]
Thu, Jun 5 2008 6:57 AMPermanent Link

Fernando Dias

Team Elevate Team Elevate

Robert,

> Unless there is a specific reason not to, all numeric fields should have a
> default of zero. That prevents this kind of problem.

I have a different opinion. It prevents this kind of problems but can create
other problems.
You are correct in this specific case - at least in my language "Saldo"
means Balance,  so in general it makes sense for a balance to start with 0
however it's not always the case. If it was, for example, "Age" in a
custumers table, I would use a default of NULL meaning the "Age" is unknown
while 0 means the customer is very very young Smiley

--
Fernando Dias
[Team Elevate]

Thu, Jun 5 2008 9:10 AMPermanent Link

"Robert"

"Fernando Dias [Team Elevate]" <fernandodias.removthis@easygate.com.pt>
wrote in message
news:A1416031-8112-4A38-8277-56745F0D2285@news.elevatesoft.com...
> Robert,
>
>> Unless there is a specific reason not to, all numeric fields should have
>> a default of zero. That prevents this kind of problem.
>
> I have a different opinion. It prevents this kind of problems but can
> create other problems.
> You are correct in this specific case - at least in my language "Saldo"
> means Balance,  so in general it makes sense for a balance to start with 0
> however it's not always the case. If it was, for example, "Age" in a
> custumers table, I would use a default of NULL meaning the "Age" is
> unknown while 0 means the customer is very very young Smiley
>

As I said, "unless there is a specific reason". Null tells you this field
has never been updated. Sometimes you need to know that, but in most cases
you don't.

Robert


Thu, Jun 5 2008 12:53 PMPermanent Link

"Hüseyin Aliz"
Hi Fernando,

Saldo means balance in danish also Smileso from the beginning it should have
default 0 as value.

Regards,
Hüseyin

"Fernando Dias [Team Elevate]" <fernandodias.removthis@easygate.com.pt>
skrev i en meddelelse
news:A1416031-8112-4A38-8277-56745F0D2285@news.elevatesoft.com...
> Robert,
>
>> Unless there is a specific reason not to, all numeric fields should have
>> a default of zero. That prevents this kind of problem.
>
> I have a different opinion. It prevents this kind of problems but can
> create other problems.
> You are correct in this specific case - at least in my language "Saldo"
> means Balance,  so in general it makes sense for a balance to start with 0
> however it's not always the case. If it was, for example, "Age" in a
> custumers table, I would use a default of NULL meaning the "Age" is
> unknown while 0 means the customer is very very young Smiley
>
> --
> Fernando Dias
> [Team Elevate]
>

Thu, Jun 5 2008 12:57 PMPermanent Link

Fernando Dias

Team Elevate Team Elevate

Robert,

> As I said, "unless there is a specific reason".
That's like the half-empty or the half-full glass question Smiley
I would say "unless there is a specific reason, all default values
should be null".

> Null tells you this field has never been updated.
NULL only tells me that the *current* value for the column is unknown -
it can't tell me if the value was updated before or not.

--
Fernando Dias
[Team Elevate]
Thu, Jun 5 2008 1:05 PMPermanent Link

Fernando Dias

Team Elevate Team Elevate

Hüseyin,
> Saldo means balance in danish also Smileso from the beginning it should have
> default 0 as value.

So, it seems I know the meaning of exactly an only *one* Danish word
Smiley In exchange, I know what "Embarcadero" means, eh, eh Smiley

--
Fernando Dias
[Team Elevate]
Thu, Jun 5 2008 2:16 PMPermanent Link

"Robert"

"Fernando Dias [Team Elevate]" <fernandodias.removthis@easygate.com.pt>
wrote in message
news:144007C9-3F56-45EC-8E9A-27E448607F62@news.elevatesoft.com...
> Robert,
>
>> As I said, "unless there is a specific reason".
> That's like the half-empty or the half-full glass question Smiley

No it is not. There are good reasons - just as the one that originated this
thread - to default numeric fields to zero. In most cases, there is no
reason NOT to.

> I would say "unless there is a specific reason, all default values should
> be null".
>

We are looking for a rule that applies in most cases unless you have a
reason for an exception to the rule,  and OP's problem is a darn good
example of why as a general rule it is useful to have defaults on most
fields. Not having to test for null every time you write SQL is reason
enough to use default 0. Especially since the error when it happens is not a
syntax error, that would be caught at run time, but a conceptual error that
will let your SQL run just fine, just give you unanticipated results. OP
found the error because he happened to be looking  at a specific row that
had "saldo" null. If most saldos are NOT null, he could well have looked at
a few rows, assumed that all was good, and released a report with incorrect
results.

>> Null tells you this field has never been updated.
> NULL only tells me that the *current* value for the column is unknown - it
> can't tell me if the value was updated before or not.
>

True enough. So to rephrase, unless you need an "unknown" state for the
field, then you should use defaults.

Robert


Thu, Jun 5 2008 6:17 PMPermanent Link

"Hüseyin Aliz"
And it means? Smile

Regards,
Hüseyin

"Fernando Dias [Team Elevate]" <fernandodias.removthis@easygate.com.pt>
skrev i en meddelelse
news:6A86144B-706B-4627-9EDE-20EECEB21F7C@news.elevatesoft.com...
> Hüseyin,
>> Saldo means balance in danish also Smileso from the beginning it should
>> have default 0 as value.
>
> So, it seems I know the meaning of exactly an only *one* Danish word Smiley
> In exchange, I know what "Embarcadero" means, eh, eh Smiley
>
> --
> Fernando Dias
> [Team Elevate]

Fri, Jun 6 2008 6:40 AMPermanent Link

Fernando Dias

Team Elevate Team Elevate

Robert

> No it is not. There are good reasons - just as the one that originated
> this thread - to default numeric fields to zero. In most cases, there is
> no reason NOT to.

I agree there are good reasons in this case, what I don't agree is with the
idea of defaulting all numeric columns to 0 as a general rule, and at least
in my experience, in most cases there in no reason TO.

> Not having to test for null every time you write SQL is reason enough to
> use default 0. Especially since the error when it happens is not a

Not having to test for 0 every time you write SQL is reason enought to use
default null Smiley
For example, I have a "Price" column in a "Products" table where the prices
are only inserted one or two months after the product is created, just about
a week before it starts selling. If the default value was 0, all the
following statements will produce wrong results:

select avg(price) from products
select min(price) from products
select price from products where price<10
update products set price=price+2

--
Fernando Dias
[Team Elevate]

« Previous PagePage 2 of 3Next Page »
Jump to Page:  1 2 3
Image