プロシージャとトリガpostgresqlは、すべての行ではなく1行でのみこれを実行する条件を追加します。

プロシージャとトリガpostgresqlは、すべての行ではなく1行でのみこれを実行する条件を追加します。

最初にトリガーとそのプロシージャを作成しましたが、プロシージャのifセクションにサブ説明がありませんでした。

create trigger a_financereconnomiser after update of prix_reel on a_financer execute procedure payetoeconomie() ; 

現在の手順は次のとおりです。

create or replace function payetoeconomie() returns trigger as $$
begin
if (select prix_estim-prix_reel from a_financer) >= 1 then 
insert into  economie (ref,designation,economie ) select ref*1000,date,objet,prix_estim-prix_reel from a_financer where prix_reel ;
end if ; 
end $$
language 'plpgsql' ;

ここで使用しようとすると、psqlは関数が一意の行以上を返すと応答します。これは論理的なようです。

だから「追加する必要があります。更新中に列が変更されました。「prix_reel カラムに関する内容です。プログラムで何をすべきか理解できない部分です。

情報テーブルは次のように構成されます。

ソース 1:

 ref        | integer          |                 | not null  |            | plain    |                       | 
 date       | date             |                 |           |            | plain    |                       | 
 dl         | date             |                 |           |            | plain    |                       | 
 prix_estim | integer          |                 |           |            | plain    |                       | 
 prix_reel  | double precision |                 |           |            | plain    |                       | 
 paye       | integer          |                 |           |            | plain    |                       | 
 objet      | text             |                 |           |            | extended |                       | 
 besoin     | integer          |                 |           |            | plain    |                       | 

ターゲット1は次のとおりです。

 ref         | integer          |                 | not null  |            | plain    |                       | 
 date        | date             |                 |           |            | plain    |                       | 
 designation | text             |                 |           |            | extended |                       | 
 economie    | double precision |                 |           |            | plain    |                       | 
 commentaire | text             |                 |           |            | extended |                       | 

ベストアンサー1

おすすめ記事