Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Data pipeline or PL support #7071

beikov started this conversation in Design Proposals
Discussion options

PostgreSQL and DB2 support building "data pipelines" in SQL i.e. have one query which acts on the result of DML statements that are also embedded in the query.
Other DBs usually support executing inline/anonymous procedures which can be used to emulate this. As a last resort, we could also just execute individual statements and push results to temporary tables or use the VALUES clause mechanism to propagate the values further.

The PostgreSQL syntax uses the RETURNING clause like this:

WITH inserted_result AS (
  insert into some_table ...
  returning id
),
queued_mails AS (
  insert into some_other_table ...
  returning mail_id
)
select 
  (select count(*) from inserted_result),
  (select count(*) from queued_mails)

I don't know if it's worth adding support for DML in CTEs explicitly or if it might be better to add a HQL based procedural language that we can translate to this SQL construct.

Having the possibility on the SQL AST to model procedural logic is definitely interesting as that will open the door for some JDBC driver pipelining optimizations.

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant
Morty Proxy This is a proxified and sanitized view of the page, visit original site.