From jfradkin@wazagua.com Tue Apr 19 14:06:02 2005 X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7EA2A53429 for ; Tue, 19 Apr 2005 11:06:02 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 90725-02 for ; Tue, 19 Apr 2005 14:05:57 +0000 (GMT) Received: from vms046pub.verizon.net (vms046pub.verizon.net [206.46.252.46]) by svr1.postgresql.org (Postfix) with ESMTP id 13E0D5343C for ; Tue, 19 Apr 2005 11:05:56 -0300 (ADT) Received: from jfradkin ([63.162.100.127]) by vms046.mailsrvcs.net (Sun Java System Messaging Server 6.2 HotFix 0.04 (built Dec 24 2004)) with ESMTPA id <0IF700ITY5U0FRAB@vms046.mailsrvcs.net> for pgsql-sql@postgresql.org; Tue, 19 Apr 2005 09:06:00 -0500 (CDT) Date: Tue, 19 Apr 2005 10:06:07 -0400 From: "Joel Fradkin" Subject: trying to do an update a bit confused. To: Message-id: <000001c544e8$ef28d820$797ba8c0@jfradkin> MIME-version: 1.0 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-Mailer: Microsoft Outlook, Build 10.0.6626 Content-type: multipart/alternative; boundary="----=_NextPart_000_0001_01C544C7.68173820" Importance: Normal X-Priority: 3 (Normal) X-MSMail-priority: Normal X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=AWL, HTML_MESSAGE X-Spam-Level: X-Archive-Number: 200504/287 X-Sequence-Number: 21180 This is a multi-part message in MIME format. ------=_NextPart_000_0001_01C544C7.68173820 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit update tblcase set merchandisetotal = ( COALESCE(( SELECT sum(m.quantity::numeric * m.amount) AS merchandiseamount FROM tblmerchandise m WHERE m.caseid = tblcase.caseid AND m.clientnum::text = tblcase.clientnum::text), 0.0) ) I tried running the above and it wants to do a sum on all the records in tblcase instead of just the one being updated, what am I doing wrong? Joel Fradkin ------=_NextPart_000_0001_01C544C7.68173820 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

update tblcase  set merchandisetotal =3D =

(

COALESCE(( SELECT sum(m.quantity::numeric * m.amount) = AS merchandiseamount

         =   FROM tblmerchandise m

         = WHERE m.caseid =3D tblcase.caseid AND m.clientnum::text =3D tblcase.clientnum::text), 0.0)

)

 

I tried running the above and it wants to do a sum on = all the records in tblcase instead of just the one being updated, what am I = doing wrong?

 

Joel Fradkin

 

 

 

------=_NextPart_000_0001_01C544C7.68173820-- From robert.koepferl@sonorys.at Tue Apr 19 14:43:45 2005 X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7CEE4533B7 for ; Tue, 19 Apr 2005 11:43:45 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 05345-08 for ; Tue, 19 Apr 2005 14:43:40 +0000 (GMT) Received: from mx-00.sil.at (mx-00.sil.at [62.116.68.196]) by svr1.postgresql.org (Postfix) with ESMTP id 8AEF053486 for ; Tue, 19 Apr 2005 11:43:38 -0300 (ADT) Received: (qmail-ldap/ctrl 28092 invoked from network); 19 Apr 2005 14:43:40 -0000 Received: from unknown (HELO jupiter.sonorys.at) ([213.235.243.42]) (envelope-sender ) by mx-00.sil.at (qmail-ldap-1.03) with SMTP for ; 19 Apr 2005 14:43:40 -0000 Received: from neptun.sonorys.at (neptun.sonorys.at [172.24.1.17]) by jupiter.sonorys.at (8.11.7+Sun/8.11.7) with ESMTP id j3JEhg119596 for ; Tue, 19 Apr 2005 16:43:42 +0200 (MEST) Received: by neptun.sonorys.at with Internet Mail Service (5.5.2653.19) id <2JD5W279>; Tue, 19 Apr 2005 16:43:42 +0200 Message-ID: From: =?ISO-8859-1?Q?K=D6PFERL_Robert?= To: pgsql-sql@postgresql.org Subject: Re: trying to do an update a bit confused. Date: Tue, 19 Apr 2005 16:43:41 +0200 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C544EE.2DDA3EB0" X-Virus-Scanned: by amavisd-new at hub.org X-Archive-Number: 200504/292 X-Sequence-Number: 21185 This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_001_01C544EE.2DDA3EB0 Content-Type: text/plain; charset="ISO-8859-1" You're most probably missing a Where clause after the parentensis. see: -----Original Message----- From: Joel Fradkin [mailto:jfradkin@wazagua.com] Sent: Dienstag, 19. April 2005 16:06 To: pgsql-sql@postgresql.org Subject: [SQL] trying to do an update a bit confused. update tblcase set merchandisetotal = ( COALESCE(( SELECT sum(m.quantity::numeric * m.amount) AS merchandiseamount FROM tblmerchandise m WHERE m.caseid = tblcase.caseid AND m.clientnum::text = tblcase.clientnum::text), 0.0) ) WHERE ; I tried running the above and it wants to do a sum on all the records in tblcase instead of just the one being updated, what am I doing wrong? Joel Fradkin ------_=_NextPart_001_01C544EE.2DDA3EB0 Content-Type: text/html; charset="ISO-8859-1"
You're most probably missing a Where clause after the parentensis. see:
-----Original Message-----
From: Joel Fradkin [mailto:jfradkin@wazagua.com]
Sent: Dienstag, 19. April 2005 16:06
To: pgsql-sql@postgresql.org
Subject: [SQL] trying to do an update a bit confused.

update tblcase  set merchandisetotal =

(

COALESCE(( SELECT sum(m.quantity::numeric * m.amount) AS merchandiseamount

           FROM tblmerchandise m

          WHERE m.caseid = tblcase.caseid AND m.clientnum::text = tblcase.clientnum::text), 0.0)

) 

WHERE <condtion that selects one record>;

 

 

I tried running the above and it wants to do a sum on all the records in tblcase instead of just the one being updated, what am I doing wrong?

 

Joel Fradkin

 

 

 

------_=_NextPart_001_01C544EE.2DDA3EB0-- From jfradkin@wazagua.com Tue Apr 19 16:58:29 2005 X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C96EE533F4 for ; Tue, 19 Apr 2005 13:58:29 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 59949-10 for ; Tue, 19 Apr 2005 16:58:27 +0000 (GMT) Received: from vms044pub.verizon.net (vms044pub.verizon.net [206.46.252.44]) by svr1.postgresql.org (Postfix) with ESMTP id 0A3915321C for ; Tue, 19 Apr 2005 13:57:23 -0300 (ADT) Received: from jfradkin ([63.162.100.127]) by vms044.mailsrvcs.net (Sun Java System Messaging Server 6.2 HotFix 0.04 (built Dec 24 2004)) with ESMTPA id <0IF7002HIDRKAI10@vms044.mailsrvcs.net> for pgsql-sql@postgresql.org; Tue, 19 Apr 2005 11:57:22 -0500 (CDT) Date: Tue, 19 Apr 2005 12:57:28 -0400 From: "Joel Fradkin" Subject: Re: trying to do an update a bit confused. In-reply-to: To: =?iso-8859-1?Q?'K=D6PFERL_Robert'?= , Message-id: <000001c54500$df3c1360$797ba8c0@jfradkin> MIME-version: 1.0 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-Mailer: Microsoft Outlook, Build 10.0.6626 Content-type: multipart/alternative; boundary="----=_NextPart_000_0001_01C544DF.582A7360" Importance: Normal X-Priority: 3 (Normal) X-MSMail-priority: Normal X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=AWL, HTML_MESSAGE X-Spam-Level: X-Archive-Number: 200504/294 X-Sequence-Number: 21187 This is a multi-part message in MIME format. ------=_NextPart_000_0001_01C544DF.582A7360 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I am not updating 1 record. I have : WHERE m.caseid =3D tblcase.caseid AND m.clientnum::text =3D tblcase.clientnum::text) Which should do the aggregate on the record that is being updated (least = as I understood it). It should update all record in case with either 0 if there are no merchandise records or do a sum of the merch records for the case being updated. =20 Joel =20 I also never heard back on the merge join issue (why do I need to = specify them off on one machine and it runs faster on the other). I am guessing it is memory related and config related, but I am about to give up on postgres as I am just not getting all my views to run fast enough. You guys could say my views are bad SQL design etc, but they run fine in MSSQL. I don=92t mind visiting each one to make them better, but I am = just not able to increase the speed on all of them. The last one about assoc = finally did run in 3 secs with merge joins off which is pretty fast, but now I = have others that seem pretty simple to me and yet run very slow.=20 =20 =20 You're most probably missing a Where clause after the parentensis. see: -----Original Message----- From: Joel Fradkin [mailto:jfradkin@wazagua.com] Sent: Dienstag, 19. April 2005 16:06 To: pgsql-sql@postgresql.org Subject: [SQL] trying to do an update a bit confused. update tblcase set merchandisetotal =3D=20 ( COALESCE(( SELECT sum(m.quantity::numeric * m.amount) AS = merchandiseamount FROM tblmerchandise m WHERE m.caseid =3D tblcase.caseid AND m.clientnum::text =3D tblcase.clientnum::text), 0.0) )=20 WHERE ; =20 =20 I tried running the above and it wants to do a sum on all the records in tblcase instead of just the one being updated, what am I doing wrong? =20 Joel Fradkin =20 =20 =20 ------=_NextPart_000_0001_01C544DF.582A7360 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable

I am not updating 1 = record.

I have = : WHERE m.caseid =3D tblcase.caseid AND m.clientnum::text =3D = tblcase.clientnum::text)

Which should do the aggregate on = the record that is being updated (least as I understood = it).

It should update all record in case = with either 0 if there are no merchandise records or do a sum of the merch = records for the case being updated.

 

Joel

 

I also never heard back on the = merge join issue (why do I need to specify them off on one machine and it runs = faster on the other).

I am guessing it is memory related = and config related, but I am about to give up on postgres as I am just not getting = all my views to run fast enough.

You guys could say my views are bad = SQL design etc, but they run fine in MSSQL. I don’t mind visiting each = one to make them better, but I am just not able to increase the speed on all of = them. The last one about assoc finally did run in 3 secs with merge joins off = which is pretty fast, but now I have others that seem pretty simple to me and = yet run very slow.

 

 

You're most = probably missing a Where clause after the parentensis. see:

-----Original Message-----
From: Joel Fradkin [mailto:jfradkin@wazagua.com]
Sent: Dienstag, 19. April = 2005 16:06
To: = pgsql-sql@postgresql.org
Subject: [SQL] trying to = do an update a bit confused.

update tblcase  set merchandisetotal =3D

(

COALESCE(( SELECT = sum(m.quantity::numeric * m.amount) AS merchandiseamount

    &nbs= p;      FROM tblmerchandise m

    &nbs= p;     WHERE m.caseid =3D tblcase.caseid AND m.clientnum::text =3D tblcase.clientnum::text), 0.0)

) 

WHERE = <condtion that selects one record>;

 

 

I tried running the above = and it wants to do a sum on all the records in tblcase instead of just the one = being updated, what am I doing wrong?

 

Joel = Fradkin

 

 

 

------=_NextPart_000_0001_01C544DF.582A7360-- From systemguards@gmail.com Tue Apr 19 23:03:39 2005 X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A4AA6535AA for ; Tue, 19 Apr 2005 20:03:39 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 35825-02 for ; Tue, 19 Apr 2005 23:03:36 +0000 (GMT) Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.198]) by svr1.postgresql.org (Postfix) with ESMTP id CF29853599 for ; Tue, 19 Apr 2005 20:03:32 -0300 (ADT) Received: by rproxy.gmail.com with SMTP id j1so25547rnf for ; Tue, 19 Apr 2005 16:03:35 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=mLv1/CY7mVhG1eBlA0gXwXF817myQudhKKGVbKddBqWK4m43kUTMGBT91XAdl11e7nXclsSnL3GkV6bJCClVJM52XgJ9BN6UNL2ZwSZ19hRcVdeQF56RqgaXWZv1Ck35cJH4yiHIvmlG+emjSrSQw4HBgKTHUZhJ0CwIpAqJzGQ= Received: by 10.38.15.7 with SMTP id 7mr169515rno; Tue, 19 Apr 2005 16:03:35 -0700 (PDT) Received: by 10.38.97.29 with HTTP; Tue, 19 Apr 2005 16:03:35 -0700 (PDT) Message-ID: Date: Tue, 19 Apr 2005 18:03:35 -0500 From: Jaime Casanova Reply-To: Jaime Casanova To: Joel Fradkin Subject: Re: trying to do an update a bit confused. Cc: pgsql-sql@postgresql.org In-Reply-To: <000001c544e8$ef28d820$797ba8c0@jfradkin> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <000001c544e8$ef28d820$797ba8c0@jfradkin> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.315 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200504/296 X-Sequence-Number: 21189 On 4/19/05, Joel Fradkin wrote: > =20 > =20 >=20 > update tblcase set merchandisetotal =3D=20 >=20 > (=20 >=20 > COALESCE(( SELECT sum(m.quantity::numeric * m.amount) AS merchandiseamoun= t=20 >=20 > FROM tblmerchandise m=20 >=20 > WHERE m.caseid =3D tblcase.caseid AND m.clientnum::text =3D > tblcase.clientnum::text), 0.0)=20 >=20 > )=20 >=20 > =20 Put the coalesce inside the select: update tblcase set merchandisetotal =3D =20 (SELECT COALESCE(sum(m.quantity::numeric * m.amount),0.0) AS merchandiseamount FROM tblmerchandise m=20 WHERE m.caseid =3D tblcase.caseid AND m.clientnum::text =3D tblcase.clientnum::text) --=20 Regards, DBA* Jaime Casanova (DBA: DataBase Aniquilator ;)