Skip to content
Snippets Groups Projects
Commit b3cbd387 authored by Peter Gerwinski's avatar Peter Gerwinski
Browse files

Beispiele 7.12.2023: Korrektur der Einrückung

parent f600e89e
Branches
No related tags found
No related merge requests found
......@@ -51,7 +51,11 @@ testdb-> ;
FEHLER: Syntaxfehler bei »if«
ZEILE 2: if new.balance <> old.balance then
^
testdb=> create function log_change () returns trigger language plpgsql as $$ begin if new.balance <> old.balance then insert into log_change (account_id, change, datetime) values (old.id, new.balance - old.balance, now ());
testdb=> create function log_change () returns trigger language plpgsql as $$
begin
if new.balance <> old.balance then
insert into log_change (account_id, change, datetime)
values (old.id, new.balance - old.balance, now ());
end if;
return new;
end;
......
......@@ -10,8 +10,10 @@ FEHLER: kann Funktion log_change() nicht löschen, weil andere Objekte davon ab
DETAIL: Trigger after_update_account für Tabelle account hängt von Funktion log_change() ab
TIP: Verwenden Sie DROP ... CASCADE, um die abhängigen Objekte ebenfalls zu löschen.
testdb=> create or replace function log_change () returns trigger language plpgsql as $$
begin if new.balance <> old.balance then
insert into account_log (account_id, change, datetime) values (old.id, new.balance - old.balance, now ());
begin
if new.balance <> old.balance then
insert into account_log (account_id, change, datetime)
values (old.id, new.balance - old.balance, now ());
end if;
return new;
end;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment