Re: how to convert "output deleted/inserted into" in My SQL to Postgres

Поиск
Список
Период
Сортировка
От Marc Mamin
Тема Re: how to convert "output deleted/inserted into" in My SQL to Postgres
Дата
Msg-id B6F6FD62F2624C4C9916AC0175D56D8828B5D784@jenmbs01.ad.intershop.net
обсуждение исходный текст
Ответ на how to convert "output deleted/inserted into" in My SQL to Postgres  (Michael_LT <michaelbleedgreen@gmail.com>)
Список pgsql-general
>hey guys, I'm kinda new to Postgres and I'm learning it now. I have work to
>convert some stored procedures in MySQL to Postgres and I came across an
>issue here that I can't solve:
>
>update  db.user
>             set Deleted        = 1
>            , UpdateTerminal = @UpdateTerminal
>             , UpdateUser     = @UpdateUser
>             , UpdateDate     = @UpdateDate
>        output deleted.CreditTypeID
>             , deleted.CreditID
>             , deleted.Amount
>          into @ReconDeleted
>         where Deleted = 0
>           and ClientID = @ClientID;
>
>I think it tried to update a couple of columns in table user and insert
>values in other 3 columns into another table ReconDeleted at the same time.
>I have issues converting "OUTPUT INTO" and "deleted" items, with my limited
>knowledge about Postgres, I don't think we have those in pg. Can someone
>tell me how to convert it? Thanks.

Hi,

it seems that you are looking for UPDATE RETURNING:

http://www.postgresql.org/docs/9.4/static/sql-update.html

regards,

Marc Mamin

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

Предыдущее
От: Alban Hertroys
Дата:
Сообщение: Re: Query optimization to select rows instead of too many or conditions
Следующее
От: Samuel Smith
Дата:
Сообщение: Postgres architecture for multiple instances