diff options
author | Masaya Tojo <masaya@tojo.tokyo> | 2023-03-05 14:29:29 +0900 |
---|---|---|
committer | Masaya Tojo <masaya@tojo.tokyo> | 2023-03-05 19:04:21 +0900 |
commit | 131c856bdd5c48bbd8358fc8c1840fce4fcf2178 (patch) | |
tree | c413bc3099fafef9b89c55f6fb4f435ab8239582 /deploy/insert_transaction@v1.0.0-dev3.sql | |
parent | efe664d3614e540ff381e8ac234a01ad177b7109 (diff) |
Rename column of transactions from type to type_code.
Diffstat (limited to 'deploy/insert_transaction@v1.0.0-dev3.sql')
-rw-r--r-- | deploy/insert_transaction@v1.0.0-dev3.sql | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/deploy/insert_transaction@v1.0.0-dev3.sql b/deploy/insert_transaction@v1.0.0-dev3.sql new file mode 100644 index 0000000..42e825d --- /dev/null +++ b/deploy/insert_transaction@v1.0.0-dev3.sql @@ -0,0 +1,25 @@ +-- Deploy kakeibo:insert_transaction to pg +-- requires: appschema +-- requires: transactions + +BEGIN; + +DROP FUNCTION kakeibo.insert_transaction(kakeibo.transaction_type, DATE, TEXT); +CREATE OR REPLACE FUNCTION kakeibo.insert_transaction( + p_type INTEGER, + p_date DATE, + p_note TEXT +) RETURNS INTEGER AS $$ +DECLARE + inserted_id INTEGER; +BEGIN + INSERT INTO kakeibo.transactions ( + type, date, note + ) VALUES ( + p_type, p_date, p_note + ) RETURNING id INTO inserted_id; + RETURN inserted_id; +END; +$$ LANGUAGE plpgsql SECURITY DEFINER; + +COMMIT; |