WRITE LINE statement (Character string output to a file)

Function

Outputs the character string in a specified value expression to a file.

Format

WRITE LINE value-expression

Operands

Specifies the value expression to be output to the file.

The following rules apply to the value expression:

  1. The following items can be specified in value-expression:
    • Literals
    • USER
    • SQL variables or SQL parameters
    • Concatenation operations
    • Scalar functions
    • Function calls
    • CASE expressions
    • CAST specifications
  2. The data type of the value expression should be a character data type (CHAR or VARCHAR), a national character data type (NCHAR or NVARCHAR), or a mixed character data type (MCHAR or MVARCHAR).
  3. The value expression is output to the location specified by PDWRTLNPATH in the client environment definition. Use PDWRTLNFILSZ in the client environment definition to specify the maximum size of the file to which the value expression is to be output. For details about PDWRTLNPATH and PDWRTLNFILSZ, see the manual HiRDB Version 8 UAP Development Guide.
  4. The linefeed code of the environment on the HiRDB server side is appended to the end of the character string in the value expression. The linefeed code varies from one HiRDB server operating system to another. If the value of the value expression exceeds the size specified in the PDWRTLNCOMSZ client environment definition, for the linefeed code on the HiRDB server side to be appended at the end, the trailing end of the value expression character expression is deleted so that the character string fits in the size specified in PDWRTLNCOMSZ, and a linefeed code is appended. For details about PDWRTLNCOMSZ, see the HiRDB Version 8 UAP Development Guide.
    Table 7-4 shows HiRDB server side linefeed codes that are appended:

    Table 7-4 Linefeed codes on the HiRDB server side that are appended

    HiRDB server OSAppended linefeed code
    HP-UXNL(X'0a')
    SolarisNL(X'0a')
    AIX 5LNL(X'0a')
    LinuxNL(X'0a')
    WindowsCR(X'0d') + NL(X'0a')
  5. If the value of the value expression is the null value, the linefeed code is not output to the file.
  6. A subquery cannot be specified in a value expression.

Common rules

  1. The WRITE LINE statement can be specified in SQL procedures and triggers; it cannot be specified in an SQL function.
  2. The WRITE LINE statement cannot be executed without specification of the PDWRTLNFILSZ client environment definition.

Example

Convert the SQL parameter fromdate of the date data type into a character string and output the results to a file:

 CREATE PROCEDURE proc_1(IN fromdate DATE)
   BEGIN
     WRITE LINE 'fromdate='||char(fromdate);
   END;