Search - "pl/pgsql"
  • 2
    I made this: https://gitlab.com/snippets/1992288

    Spare me if the title makes no sense grammatically, not a native speaker.

    I'm building a microservice that keeps a check of the subscribers on my product, I wanted to keep an eye of those subscribers that may be missing the latest payment.

    One way to do that is to make it work with my code and some ORM magic, but that may become unsustainable as the customer base grows, another idea that occurred to me was doing it fully inside (?) the database. The solution is to compare how many days have passed since the last payment and right now, if 'right now' is larger than 'last payment' then the subscriber is late with their next payment.

    I did this as a PL/pgSQL function with an example usage accompanying that code.

    Now, I just need to figure out how to use the result of those calculations in a WHERE statement...
    2