Call Statements

Call statements are used to call a stored procedure which is usually provided to perform data manipulation or administrative tasks.

Attention Currently, Call statements require the procedure called to exist in the corresponding catalog. So, please make sure the procedure exists in the catalog. If it doesn’t exist, it’ll throw an exception. You may need to refer to the doc of the catalog to see the available procedures. To implement an procedure, please refer to Procedure.

Run a CALL statement

Java

CALL statements can be executed with the executeSql() method of the TableEnvironment. The executeSql() will immediately call the procedure, and return a TableResult instance which associates the procedure.

The following examples show how to execute a CALL statement in TableEnvironment.

Scala

CALL statements can be executed with the executeSql() method of the TableEnvironment. The executeSql() will immediately call the procedure, and return a TableResult instance which associates the procedure.

The following examples show how to execute a single CALL statement in TableEnvironment.

Python

CALL statements can be executed with the execute_sql() method of the TableEnvironment. The executeSql() will immediately call the procedure, and return a TableResult instance which associates the procedure.

The following examples show how to execute a single CALL statement in TableEnvironment.

SQL CLI

CALL statements can be executed in SQL CLI.

The following examples show how to execute a CALL statement in SQL CLI.

Java

  1. TableEnvironment tEnv = TableEnvironment.create(...);
  2. // assuming the procedure `generate_n` has existed in `system` database of the current catalog
  3. tEnv.executeSql("CALL `system`.generate_n(4)").print();

Scala

  1. val tEnv = TableEnvironment.create(...)
  2. // assuming the procedure `generate_n` has existed in `system` database of the current catalog
  3. tEnv.executeSql("CALL `system`.generate_n(4)").print()

Python

  1. table_env = TableEnvironment.create(...)
  2. # assuming the procedure `generate_n` has existed in `system` database of the current catalog
  3. table_env.execute_sql().print()

SQL CLI

  1. // assuming the procedure `generate_n` has existed in `system` database of the current catalog
  2. Flink SQL> CALL `system`.generate_n(4);
  3. +--------+
  4. | result |
  5. +--------+
  6. | 0 |
  7. | 1 |
  8. | 2 |
  9. | 3 |
  10. +--------+
  11. 4 rows in set
  12. !ok

Syntax

  1. CALL [catalog_name.][database_name.]procedure_name ([ expression [, expression]* ] )