include

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

include [2015/09/23 20:27]
include [2015/09/23 20:27] (current)
Line 1: Line 1:
 +====== INCLUDE Statement ======
  
 +INCLUDE statement allows you to include statements from another HPL/SQL script.
 +
 +You can define user-defined functions and stored procedures in separate HPL/SQL scripts and then use INCLUDE statements to make them available in the current script. ​
 +
 +Additionally you can put INCLUDE statements to [[configuration##​hplsqlrc-file|.hplsqlrc]] configuration file, so these functions and procedures are always available to users similar to persistent objects in the database.  ​
 +
 +**Syntax**:
 +
 +<code language=sql>​
 +INLCUDE file_name; ​
 +</​code>​
 +
 +Notes:
 +  * //​file_name//​ is the path to the file (quoted or unquoted) or an expression
 +
 +
 +**Example**:​
 +
 +Create a separate file //​set_message.sql//​ containing:
 +
 +<code language=sql>​
 +CREATE PROCEDURE set_message(IN name STRING, OUT result STRING)
 +BEGIN
 + SET result = '​Hello,​ ' || name || '​!';​
 +END;
 +</​code>​
 +
 +The call the procedure from another script as follows: ​
 +
 +<code language=sql>​
 +INCLUDE set_message.sql
 +
 +DECLARE str STRING;
 +CALL set_message('​world',​ str);
 +PRINT str;
 +
 +Result:
 +--
 +Hello, world!
 +</​code>​
 +
 +**Compatibility:​** HPL/SQL extension
 +
 +**Version**:​ PL/HQL 0.3.1
 +
 +See also:
 +  * [[call|CALL]]
 +  * [[create-function|CREATE FUNCTION]]
 +  * [[create-procedure|CREATE PROCEDURE]]