Created
February 8, 2018 13:14
-
-
Save cristianc-ty/6c9a85c7467511bafdfbc1de2e0f62d9 to your computer and use it in GitHub Desktop.
quick_customer_search_view.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- build a view to show all data that combines | |
create view quick_customer_search as | |
select customer_search.* | |
from customer_search | |
-- * records that are not marked as stale | |
where customer_search.is_stale = false | |
union all | |
select r.* | |
from customer_search | |
-- * records that are stale => recompute the most up to date fields on the fly | |
cross join refresh_customer_search (customer_search.customer_id, customer_search.contact_id) r | |
where customer_search.is_stale = true; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment