vendredi 22 mai 2020

Extract named sub-queries into separate files

Let's say I have a file containing a SQL-query with multiple named sub-queries:

WITH first_part AS (
  ...
),
second_part AS (
  ...
)

SELECT * FROM first_part....

I would like to extract first_part and second_part into standalone files, to make it easier to write tests.

I could, of course, simply extract them to separate files, and then write some code to merge all the queries into a single one at runtime. But I was wondering if there is some "conventional" way of achieving this?

Aucun commentaire:

Enregistrer un commentaire