Skip site navigation (1) Skip section navigation (2)

Re: Problem with FOR UPDATE

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Kaloyan Iliev <news1(at)faith(dot)digsys(dot)bg>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Problem with FOR UPDATE
Date: 2006-09-07 14:20:27
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-sql
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 =,
> 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 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

In response to

pgsql-sql by date

Next:From: Stephan SzaboDate: 2006-09-07 14:26:33
Subject: Re: Is it possible to left join based on previous joins result
Previous:From: Tom LaneDate: 2006-09-07 14:15:39
Subject: Re: Problem with FOR UPDATE

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group