Re: SET ENGINEBEHAVIOR 70?????
From: Chad (chad_at_teche.net)
Date: 07/29/04
- Next message: Dorian Chalom: "a Book Query"
- Previous message: Leonid: "Re: SET ENGINEBEHAVIOR 70?????"
- In reply to: Leonid: "Re: SET ENGINEBEHAVIOR 70?????"
- Next in thread: Leonid: "Re: SET ENGINEBEHAVIOR 70?????"
- Reply: Leonid: "Re: SET ENGINEBEHAVIOR 70?????"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 29 Jul 2004 07:59:03 -0500
Leonid,
One query is quicker to write (and sometimes process) than two queries,
but again, you are taking some things for granted due to an assumed
knowledge of the data. You are assuming that you don't have any two (or
more) rows in the parent table where the id field is the same and f1 -
f100 fields are the same and / or different. Granted, you probably assume
this because the id field is the primary key of the parent table. Just
remember, simply because something is easier, doesn't mean it's the right
way to do it. Even with the id field being the primary key, it is indeed
possible to get data corruption and have multiple rows with the same key
(I've seen it). And again, with the 70 behavior'd query, you'd never know,
but with the proper query you would.
HTH,
Chad
On Thu, 29 Jul 2004 11:57:07 +0300, Leonid <leonid@NOgradaSPAM.lv> wrote:
> While I absolutely agree with you concerning your example, there are
> examples where with ENGINEBEHAVIOR 70 you may use more simple SQL
> statement.
> Let's consider
>
> create table Parent (id I, f1 C(1), f2 C(1), ..., f100 C(1))
> create table Child (id I, id_parent I, amount N(10,2))
>
> Your task is to get table with all fields from the Parent and total
> amount
> from Child. With ENGINEBEHAVIOR 70 you may use
>
> select Parent.*, sum(Child.amount) as Total from Parent join Child on
> Parent.id=Child.id_parent group by Parent.id
>
> and in this case you are absolutely sure that you will get right f1, ...,
> f100. With ENGINEBEHAVIOR 80 you must write
>
> select Parent.*, sum(Child.amount) as Total from Parent join Child on
> Parent.id=Child.id_parent group by Parent.id, Parent.f1, ..., Parent.f100
>
> or at least
>
> select Parent.*, sum(Child.amount) as Total from Parent join Child on
> Parent.id=Child.id_parent group by 1, 2, ..., 101
>
> or use two SQL statement
>
> select Parent.id, sum(Child.amount) as Total from Parent join Child on
> Parent.id=Child.id_parent group by 1 into cursor C1
> select Parent.*, C1.total from Parent join C1 on Parent.id=C1.id
>
> Leonid
-- There are two types of people in this world: * Those who need closure
- Next message: Dorian Chalom: "a Book Query"
- Previous message: Leonid: "Re: SET ENGINEBEHAVIOR 70?????"
- In reply to: Leonid: "Re: SET ENGINEBEHAVIOR 70?????"
- Next in thread: Leonid: "Re: SET ENGINEBEHAVIOR 70?????"
- Reply: Leonid: "Re: SET ENGINEBEHAVIOR 70?????"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|