Database Reference
In-Depth Information
postgres=# SELECT * FROM accounts;
owner | balance
-------+---------
Bob | 100
Mary | 200
(2 rows)
postgres=# SELECT * FROM
transfer('Bob','Mary',14.00);
transfer
----------
OK
(1 row)
postgres=# SELECT * FROM accounts;
owner | balance
-------+---------
Mary | 214.00
Bob | 86.00
(2 rows)
Your application would need to check the return code and decide how to handle
these errors. As long as it was written to reject any unexpected value, you could ex-
tend this function to do more checking, such as minimum transferrable amount, and
be sure it would be prevented. There are three errors this can return:
postgres=# SELECT * FROM
transfer('Fred','Mary',14.00);
transfer
-------------------------
Payer account not found
(1 row)
postgres=# SELECT * FROM
transfer('Bob','Fred',14.00);
transfer
--------------------------
Search WWH ::




Custom Search