Skip to Main Content

Write Great SQL Office Hours

Free tips and training every month! Subscribe for reminders and more from Office Hours. FAQ

Header container

June 16, 2020

13:00 UTC   Start Times Around the World

Subscribe to be notified of changes to sessions and give us feedback!

Having trouble watching the video on this page? Open the video in your browser.


Pattern Matching + SQL Macros = Pure SQL Awesomeness!
Added in Oracle Database 12c, SQL pattern matching (match_recognize) makes it easy to answer many questions that were hard-to-impossible with SQL.

But turning match_recognize clauses into reusable functions was tricky at best.

No more!

Added in 19.6, SQL macros enable you to define reusable code fragments. These return SQL that becomes part of your final SQL statement.

This session will show you how you can combine SQL macros and match_recogize. Together these enable you to write generic functions answering common questions such as "find me all the consecutive rows".

Highlights for this session include:

- 01:30 - Finding consective rows using match_recognize
- 10:15 - Demo of match_recognize for consecutive rows
- 22:45 - SQL Macros to create reusable SQL fragments
- 27:10 - Demo of SQL macros to find consecutive rows
- 41:50 - Finding gaps in start/end dates across rows
- 48:30 - Combining match_recognize and SQL macros to build generic "find the gaps" solutions

Your Experts

    Chris Saxon

    Chris Saxon   

    Chris Saxon is an Oracle Developer Advocate and quizmaster on Dev Gym. His job is to help you get the best out of the Oracle Database and have fun with SQL! He's also part of the answer team on Ask TOM and creates YouTube videos at The Magic of SQL channel.
    Keith Laker

    Keith Laker   

    I have been working with Oracle data warehouse technology for over 20 years working on a wide variety of data warehouse projects both as a consultant and an onsite support engineer. I am now part of the Data Warehouse Product Management Team where I am responsible for Autonomous Database and analytical SQL. I am based in the UK at our Manchester office. A key part of my role is to work with our sales teams to brief our customers on data warehousing and analytical SQL: explaining the wide variety of new and exciting opportunities that our DW and analytical solutions can support. I regularly deliver sales training for data warehousing and analytical SQL across all our sales regions and provide competitive intelligence support across all the major data warehouse vendors.