pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stephan Szabo <sszabo@megazone.bigpanda.com>
To: Kaloyan Iliev <news1@faith.digsys.bg>
Cc: pgsql-sql@postgresql.org
Subject: Re: Problem with FOR UPDATE
Date: Thu, 7 Sep 2006 07:20:27 -0700 (PDT)
Message-ID: <20060907071820.P60412@megazone.bigpanda.com> (raw)
In-Reply-To: <44FFDFA6.4080600@faith.digsys.bg>
References: <44FFDFA6.4080600@faith.digsys.bg>


On Thu, 7 Sep 2006, Kaloyan Iliev wrote:

> Hi All,
> I have a query in which I want to SELECT FOR UPDATE same rows but only
> from one table.
> Firs I try just with SELECT FOR UPDATE but I receive an error
> because of the LEFT JOIN - "ERROR:  SELECT FOR UPDATE/SHARE cannot be
> applied to the nullable side of an outer join".
> So I decide to use SELECT FOR UPDATE OF <table name> but I then receive
> the error you can see.

I think you'd want to use DD not debts_desc as you've renamed the from
list entry.

> Can anyone help me with this query?
>
> Thanks in advance.
>
>   Regards,
>     Kaloyan Iliev
>
> rsr=# SELECT
> rsr-#        DD.*
> rsr-#                                         ( SELECT sum(-amount *
> saldo_sign(credit))
> rsr(#                                                   FROM acc_debts ACD1
> rsr(#                                                   WHERE
> ACD1.debtid = DD.debtid ) AS saldo,
> rsr-#                                                 C.custid,
> rsr-#                                                 S.descr_bg
> rsr-#                                FROM debts_desc DD LEFT JOIN config
> C ON (DD.conf_id = C.id),
> rsr-#                                         acc_debts AD,
> rsr-#                                         acc_clients AC,
> rsr-#                                         services S
> rsr-#                                WHERE DD.debtid = AD.debtid
> rsr-#                                       AND DD.closed AND NOT
> DD.paid AND DD.has_invoice AND DD.active AND DD.has_proform AND NOT
> DD.storned
> rsr-#                                      AND AD.transact_no =
> AC.transact_no
> rsr-#
> AND AC.ino = 45
> rsr-#                                                    FOR UPDATE OF
> debts_desc;
> ERROR:  relation "debts_desc" in FOR UPDATE/SHARE clause not found in
> FROM clause



view thread (3+ messages)

Message-ID: <20060907071820.P60412@megazone.bigpanda.com>
Permalink:  ../20060907071820.P60412@megazone.bigpanda.com/
Also on:    postgresql.org/message-id/20060907071820.P60412@megazone.bigpanda.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: sszabo@megazone.bigpanda.com, news1@faith.digsys.bg
  Subject: Re: Problem with FOR UPDATE
  In-Reply-To: <20060907071820.P60412@megazone.bigpanda.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox