Re: Strange situation with two tables.

Поиск
Список
Период
Сортировка
От Terry Yapt
Тема Re: Strange situation with two tables.
Дата
Msg-id 3D7F5626.CC4C6F0F@technovell.com
обсуждение исходный текст
Ответ на Strange situation with two tables.  (Terry Yapt <yapt@technovell.com>)
Ответы Re: Strange situation with two tables.  (Oliver Elphick <olly@lfix.co.uk>)
Список pgsql-novice
If I understand you and

USER1 starts this pl/pgsql body function
    BEGIN
       SELECT count(*) AS c1 FROM debits;
       ........
       ........  -- Here USER2 INSERTS a new row in debits table. --
       ........
       SELECT count(*) AS c2 FROM debits
       IF c1 = c2 THEN
          RETURN true
       ELSE
          RETURN false
       END IF;
    END;

This functions returns TRUE ?  It is right ?

Thanks...



Oliver Elphick wrote:
>
> On Wed, 2002-09-11 at 14:34, Terry Yapt wrote:
> ...
> > And here is the problem because more client connections are inserting
> debits (and perhaps to the same customer_number I am working with), but
> I _ONLY_ MUST to update the debits.bill_number to that debits.ROWS I
> have treated in the bill.ROW creation step.
>
> I think you are worrying about a non-problem..  If you are working in a
> PL/PGSQL function. anything you do will automatically happen inside one
> transaction.  Therefore, nothing that happens to the database after that
> transaction starts will be visible to your function.  So you don't have
> to worry about subsequent changes.
>
> If you are doing several inserts before doing your bill update, and
> don't want a later bill to include the ones you are dealing with,
> enclose all your SQL commands in BEGIN ... END to turn them all into one
> transaction.  (Don't confuse PL/PGSQL's BEGIN...END with SQL's
> BEGIN...END)  None of the results of the transaction will be visible to
> other connections until the transaction is committed.
>
> --
> Oliver Elphick                                Oliver.Elphick@lfix.co.uk
> Isle of Wight, UK
> http://www.lfix.co.uk/oliver
> GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839  932A 614D 4C34 3E1D 0C1C
>                  ========================================
>      "I am crucified with Christ; nevertheless I live; yet
>       not I, but Christ liveth in me; and the life which I
>       now live in the flesh I live by the faith of the Son
>       of God, who loved me, and gave himself for me."
>                                          Galatians 2:20

В списке pgsql-novice по дате отправления:

Предыдущее
От: "Chad Thompson"
Дата:
Сообщение: Re: real beginner's questions
Следующее
От: Oliver Elphick
Дата:
Сообщение: Re: Strange situation with two tables.