Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » DBISAM Technical Support » Support Forums » DBISAM SQL » View Thread |
Messages 11 to 20 of 23 total |
Problems updating table with sql.. |
Wed, Jun 4 2008 1:34 PM | Permanent Link |
"Hüseyin Aliz" | Yes, you are right, i have changed the field to be default 0
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 >> 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 AM | Permanent Link |
Roy Lambert NLH Associates 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 AM | Permanent Link |
Fernando Dias 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 -- Fernando Dias [Team Elevate] |
Thu, Jun 5 2008 9:10 AM | Permanent 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 > 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 PM | Permanent Link |
"Hüseyin Aliz" | Hi Fernando,
Saldo means balance in danish also so 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 > > -- > Fernando Dias > [Team Elevate] > |
Thu, Jun 5 2008 12:57 PM | Permanent Link |
Fernando Dias Team Elevate | Robert,
> As I said, "unless there is a specific reason". That's like the half-empty or the half-full glass question 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 PM | Permanent Link |
Fernando Dias Team Elevate | Hüseyin,
> Saldo means balance in danish also so from the beginning it should have > default 0 as value. So, it seems I know the meaning of exactly an only *one* Danish word In exchange, I know what "Embarcadero" means, eh, eh -- Fernando Dias [Team Elevate] |
Thu, Jun 5 2008 2:16 PM | Permanent 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 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 PM | Permanent Link |
"Hüseyin Aliz" | And it means?
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 so from the beginning it should >> have default 0 as value. > > So, it seems I know the meaning of exactly an only *one* Danish word > In exchange, I know what "Embarcadero" means, eh, eh > > -- > Fernando Dias > [Team Elevate] |
Fri, Jun 6 2008 6:40 AM | Permanent Link |
Fernando Dias 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 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 Page | Page 2 of 3 | Next Page » |
Jump to Page: 1 2 3 |
This web page was last updated on Wednesday, May 15, 2024 at 08:40 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |