Here is my code :
DROP TABLE IF EXISTS clients, accounts, transactions, failed_transactions CASCADE;
CREATE TABLE IF NOT EXISTS clients
(
id int PRIMARY KEY,
name varchar
);
CREATE TABLE IF NOT EXISTS accounts
(
id int PRIMARY KEY,
balance float,
client int,
FOREIGN KEY (client) REFERENCES clients(id),
CHECK (balance >= -500)
);
CREATE TABLE IF NOT EXISTS transactions
(
id serial PRIMARY KEY,
amount float
);
CREATE TABLE failed_transactions
(
id serial,
account_id integer,
attempted_amount float,
timestamp timestamp DEFAULT NOW()
);
CREATE OR REPLACE PROCEDURE log_failed_transaction(new_line record, old_line record)
LANGUAGE plpgsql
AS $$
BEGIN
IF new_line.balance
0 comments:
Post a Comment
Thanks