Search Postgresql Archives

Problem with UPDATE .. FROM syntax. please help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all,

I mess around with this request below.  Has is I get the following error.
2005-11-01 16:08:41 ERROR: JOIN/ON clause refers to "pd", which is not part of JOIN

The error came from the following line:
   INNER JOIN BD ON PD.PDBDNUM = BD.BDNUM AND PD.PDYPNUM = BD.BDYPNUM

But when I remove the PD. I get
ERROR:  column "pdypnum" does not exist.

If I try to add BD in the FROM clause I get a
ERROR:  table name "pd" specified more than once

So is there a way I can make it work ?!

Thanks for your help :-)
/David



UPDATE PD SET PDSTOT = ROUND(PDCOUTNET * COALESCE(PDQRECUI,0), 2),
PDTAXF = ROUND(((PDCOUTNET * COALESCE(PDQRECUI,0))::NUMERIC * ICTPS::INT * BO.BOTAUXF / 100), 2), PDTAXP = ROUND((((PDCOUTNET * COALESCE(PDQRECUI,0))::NUMERIC + ATP.ATCALC::INT * ROUND(((PDCOUTNET * COALESCE(PDQRECUI,0))::NUMERIC * ICTPS::INT * BO.BOTAUXF / 100), 2)) * COALESCE(IZ.IZTAXABLE, ICTPROV)::INT * BO.BOTAUXP / 100), 2)
   FROM PO
   INNER JOIN BD ON PD.PDBDNUM = BD.BDNUM AND PD.PDYPNUM = BD.BDYPNUM
   INNER JOIN BO ON BD.BDBONUM = BO.BONUM AND BD.BDYPNUM = BO.BOYPNUM
   INNER JOIN IC ON BD.BDICNUM = IC.ICNUM
   LEFT OUTER JOIN IZ ON PO.POAPNUMF = IZ.IZAPNUM AND IC.ICNUM = IZ.IZICNUM
   WHERE PDPONUM = PO.PONUM AND PDYPNUM = PO.POYPNUM
    AND PDPONUM = id AND PDYPNUM = companyId;





INNER JOIN BD ON PD.PDBDNUM = BD.BDNUM AND PD.PDYPNUM = BD.BDYPNUM


---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

              http://www.postgresql.org/docs/faq

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux