Open Source RDBMS - Seamless, Scalable, Stable and Free

한국어 | Login |Register

Versions available for this page: CUBRID 8.2.1 |  CUBRID 8.3.0 |  CUBRID 8.3.1 |  CUBRID 8.4.0 |  CUBRID 8.4.1 |  CUBRID 8.4.3 |  CUBRID 9.0.0 | 

Using CALL Statement

You can call the Java stored functions/procedures by using a CALL statement, from SQL statements or Java applications.

The following shows how to call them by using the CALL statement. The name of the Java stored function/procedure called from a CALL statement is not case sensitive.

Syntax

CALL {procedure_name ([param[, param]...) | function_name ([param[, param]...) INTO :host_variable

param {literal | :host_variable}

Example

call Hello() into :HELLO;

call Sp_int(3) into :i;

call phone_info('Tom','016-111-1111');

In CUBRID, the Java functions/procedures are called by using the same CALL statement. Therefore, the CALL statement is processed as follows:

  1. It is processed as a method if there is a target class in the CALL statement.
  2. If there is no target class in the CALL statement, it is checked whether a Java stored function/procedure is executed or not; a Java stored function/procedure will be executed if one exists.
  3. If no Java stored function/procedure exists in step 2 above, it is checked whether a method is executed or not; a method will be executed if one with the same name exists.

The following error occurs if you call a Java stored function/procedure that does not exist.

CALL deposit()

ERROR: Stored procedure/function 'deposit' is not exist.

 

CALL deposit('Tom', 3000000)

ERROR: Methods require an object as their target.

If there is no argument in the CALL statement, a message "ERROR: Stored procedure/function 'deposit' is not exist." appears because it can be distinguished from a method. However, if there is an argument in the CALL statement, a message "ERROR: Methods require an object as their target." appears because it cannot be distinguished from a method.

If the CALL statement is nested within another CALL statement calling a Java stored function/procedure, or if a subquery is used in calling the Java function/procedure, the CALL statement is not executed.

call phone_info('Tom', call sp_int(999));

call phone_info((select * from Phone where id='Tom'));

If an exception occurs during the execution of a Java stored function/procedure, the exception is logged and stored in the dbname_java.log file. To display the exception on the screen, change a handler value of the $CUBRID/java/logging.properties file to " java.lang.logging.ConsoleHandler." Then, the exception details are displayed on the screen.