Re: [SQL] Query performance problem

2005-03-18 Thread PFC
DEFAULT applies to INSERTs, NOT NULL applies to UPDATEs too. In MySQL it applies to both (ie. if you UPDATE to an invalid value, it sets it to 'something'). NOT NULL without default is useful when you want to be sure you'll never forget to put a value in that column, when there is no meanin

Re: [SQL] Query performance problem

2005-03-18 Thread Stephan Szabo
On Fri, 18 Mar 2005, Kenneth Gonsalves wrote: > On Thursday 17 Mar 2005 7:35 pm, Richard Huxton wrote: > > > Not necessarily. NOT NULL here helps to ensure you can add values > > together without the risk of a null result. There are plenty of > > "amount" columns that should be not-null (total spe

Re: [SQL] Query performance problem

2005-03-18 Thread George Weaver
Only specifying a default value does not prevent a NULL from being entered either through accident or ignorance: jan28-05=# create table test (foo text, foo1 int4 default(0)); CREATE TABLE jan28-05=# insert into test values('a',1); INSERT 98685 1 jan28-05=# insert into test values('b',4); INSERT

[SQL] best way to swap two records (computer details)

2005-03-18 Thread Gary Stainburn
Hi folks. I have a table called pieces which contain every piece of hardware and software within my company. Each piece has an owner attribute which points to another piece which - funnily enough - owns it. For example records for CPU, motherboard, HDD, O/S, and applications will all be owned

Re: [SQL] best way to swap two records (computer details)

2005-03-18 Thread Greg Patnude
How about a user defined function ??? CREATE OR REPLACE FUNCTION harwareupdate(integer, integer) RETURNS BOOLEAN AS ' update pieces set p_name = \'LSALES1\', p_location = \'Mike Haley\', p_site = \'L\' where p_id = $1; update pieces set p_name = \'SPARE\', p_location = \'spare\', p_

[SQL] Trigger with parameters

2005-03-18 Thread lucas
Hi, I am building a generic database in postgresql. And I am having a lot of problem Yes, I am just studing and learning about postgres. Lets go: My database have two schemas: 1 - The MAIN schema 2 - The System schema. I created the system schema that contains the table_fields register for th

Re: [SQL] best way to swap two records (computer details)

2005-03-18 Thread PFC
My question is what's the best way to swap settings between the two computer records and swap any software installed? Ideally I'd like it in the form of a function where I can pass the two p_id's and return a boolean reflecting success (true) or fail (false). I'd say something like that

Re: [SQL] Consecutive row count query

2005-03-18 Thread Leon Stringer
> I wondered if anyone could answer the following question: Thanks for your responses, I think I'll just add the extra column in as Greg suggests. (BTW: I mean "unnecessary *denormalization*" which I hope is less odd!). Leon... ---(end of broadcast)-