RED Script Output Protocol
For all RED scripts the Exit Code must be 0 always.
The script result is determined by reading the status value from the first line of the standard-out, therefore all standard-out must be suppressed/collected until the final status value and status result messages are written. The second line of standard-out is taken as the status result message. Any further lines of standard-out are considered audit log messages. Any standard-error messages are considered detail/error logs and are printed after the audit logs in the results pane.
| Output Channel | Purpose |
| Exit Code | Must be ‘0’, non-zero will throw an error and can suppress further logging. |
| Standard Output | Line 1 - Numeric result code (1,-1,-2,-3)* Line 2 - Result message Lines 3+ - Audit messages |
| Standard Error | Lines 1+ - Detail messages |
| *RED Script Result Codes | Meaning |
| 1 | Success |
| -1 | Success with Warnings |
| -2 | Failure |
| -3 | Fatal Unexpected Error |
Windows Example for Oracle:
In the following example, the first line '@echo off' prevents unwanted information from being reported to standard out. A Sql*loader script file is built up (echo statements). The sqlldr command is then executed with the 'silent-header,feedback' option once again to prevent unwanted output.
@echo off echo load data >c:\temp\wsl1.ctl echo infile 'C:\Temp\budget.txt' >>c:\temp\wsl1.ctl echo badfile 'c:\temp\wsl1.bad' >>c:\temp\wsl1.ctl echo into table load_budget_txt >>c:\temp\wsl1.ctl echo fields terminated by "," >>c:\temp\wsl1.ctl echo optionally enclosed by '^"' >>c:\temp\wsl1.ctl echo trailing nullcols >>c:\temp\wsl1.ctl echo ( >>c:\temp\wsl1.ctl echo product_code,>>c:\temp\wsl1.ctl echo customer_code,>>c:\temp\wsl1.ctl echo budget_quantity,>>c:\temp\wsl1.ctl echo budget_sales_value,>>c:\temp\wsl1.ctl echo budget_date date 'dd-mon-yyyy'>>c:\temp\wsl1.ctl echo ) >>c:\temp\wsl1.ctl sqlldr userid=dssadm/wsl@ORCL control=c:\temp\wsl1.ctl skip=1 silent=header,feedback log=c:\temp\wsl1.log goto answer%errorlevel% :answer0 echo 1 echo Load completed successfully type c:\temp\wsl1.log >&2 exit :answer2 echo -1 echo Not all rows loaded. See error trail type c:\temp\wsl1.log >&2 exit :answer1 echo -2 echo SQL*Loader execution exited with EX_FAIL, see error trail type c:\temp\wsl1.log >&2 exit :answer3 echo -3 echo SQL*Loader execution encountered a fatal error type c:\temp\wsl1.log >&2 exit