Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The following PL/SQL code creates a cursor that can be used to store the result set to a file when specifying the result_set_as_variables argument with one of the values csv, xml or json. In addition, the result_file argument is used to specify the file to which selected data is written to.

Code Block
languagesql
titlePL/SQL procedure returning result set cursor
DECLARE
  return_cursor SYS_REFCURSOR;
BEGIN
  OPEN return_cursor FOR 'SELECT FIRST_NAME, LAST_NAME, AGE FROM EMPLOYEES';
END;

...

This argument specifies the user account for a database schema which has been assigned the required privileges to execute the PL/SQL code.

...

This argument specifies a regular expression for parsing the output created by the the DBMS_OUTPUT package from the PL/SQL statements. For each match an order variable is created that is available for subsequent for subsequent jobs. For example, the statement:

EXEC DBMS_OUTPUT.PUT_LINE( 'SET order_date IS ' || TO_CHAR(CURRENT_DATE, 'YYYY-MM-DD') );

...

The output will be parsed by the regular expression:

^SETs+(\\s)\\s*ISs(.*)$

and will result in an order variable:

order_date = "2021-05-04"

...

Code Block
languagesql
titleExample how to specify a return variable
EXEC DBMS_OUTPUT.PUT_LINE( 'SET order_date IS ' || TO_CHAR(CURRENT_DATE, 'YYYY-MM-DD') );

results e.g. in the output such as:

Code Block
languagesql
titleExample for a return variable
SET order_date IS 2021-05-04

...

This job automatically creates the following order variables that which are available to subsequent instructions and jobs. 

...