Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emulate procedural languages in H2 #8302

Closed
lukaseder opened this issue Feb 6, 2019 · 1 comment
Closed

Emulate procedural languages in H2 #8302

lukaseder opened this issue Feb 6, 2019 · 1 comment

Comments

@lukaseder
Copy link
Member

Procedural languages can be emulated in H2 using Java code. For example, this PostgreSQL program:

DO $$
BEGIN
  FOR i IN 1 .. 10 LOOP
    RAISE INFO '%', i;
  END LOOP;
END;
$$

... can be written as follows in H2

CREATE ALIAS x AS $$
void x() {
  for (int i = 1; i <= 10; i++)
    System.out.println(i);
}
$$;

CALL x();

DROP ALIAS x;

A future version might even support a DO syntax, akin to PostgreSQL: h2database/h2database#1723

DO $$
void x() {
  for (int i = 1; i <= 10; i++)
    System.out.println(i);
}
$$;
@lukaseder
Copy link
Member Author

lukaseder commented Feb 6, 2019

This first implementation is clearly experimental. The following follow up issues need to be addressed:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant