1. Learn
  2. /
  3. Courses
  4. /
  5. Transactions and Error Handling in PostgreSQL

Exercise

Savepoints and rolling back

Continuing to think about the amount of maturing time deposits in the near future. The ones over 250K have the most impact on the outcomes seen during the 2008 market.

RCONHK12 (>=250k) stores those maturing in the next three months and RCONHK13 (>=250k) stores those expiring between 3 and 12 months. If these are higher than $1 million dollars it can cause a funds shortage at a bank as these are typically larger customers of the bank who might also pull other assets. Again, there is a positive factor if these are less than $500K.

I've made a few mistakes in my code by setting the wrong value for those over $500 thousand!

Instructions

100 XP
  • Within a transaction set FIELD48 to mature+ if total maturing deposits is less than $500 thousand and set a savepoint matureplus_flag_set.
  • Set FIELD48 to mature- if total maturing deposits is between $500 thousand and $1 million then set a savepoint matureminus_flag_set.
  • Set FIELD48 to mature-- if total maturing deposits is greater than $100 thousand (not $1 million) - "accidentally" omitting a 0.
  • Undo back to just after we set the mature- records and count all the banks with a mature-- deposit maturity schedule.