DTWF_READFILE

AIX HP-UX Linux OS/2 OS/390 OS/400 PTX SUN Win NT
X X X X

X X X

Purpose

Use this function to read in a file and assign it to a variable. The function searches FFI_PATH for the specified file.

This function can be used to pass a large amount of data to another function or stored procedure. If the file data contains NULL characters, it might be truncated when the variable is referenced in the macro.

Format

@DTWF_READFILE(fileIn,varOut)

Parameters

Table 180. DTW_READFILE Parameters
Data Type Parameter Use Description
string fileIn IN The name of the file to read in.
string varOut OUT The variable that is assigned the contents of the file.

Return Codes

Table 181. DTWF_READFILE Return Codes
Return Code Explanation
-1001 The server could not process a Net.Data request to allocate memory.
1001 An input parameter contained a NULL value.
1002 An input parameter contained a string value which consisted of the null-terminating character.
1003 An incorrect number of parameters were passed on a function call.
1004 A parameter passed on a function call, required to be a Net.Data macro table variable, was of a different variable type.
1005 A parameter passed on a function call, required to be a string variable, was of a different variable type.
1006 A literal string was passed on a function call for a parameter which was required to be an output parameter.
1007 A parameter contains a value which is not valid.
1010 Data was written to the table until it was full, and the remainder of the data was discarded.
2000 A flat file interface built-in function could not find the specified file.
2001 A flat file interface built-in function could not open the specified file because it was in use by this or another process, and could not be shared in the specified mode.
2003 A flat file interface built-in function could not read a row of data into a table variable because the number of bytes in the row exceeded the maximum supported number of bytes.
2004 A flat file interface built-in function was attempting to find a file, but encountered a path in the FFI_PATH configuration file variable that was longer than the maximum supported number of bytes, which is 4095.
2005 A call to a system function failed.
2006 A flat file interface built-in function could not access the specified file because it was in use by this or another process and could not be shared in the specified mode.

Examples

Example 1: A file is read and displayed in all caps.

%HTML(report){
@DTWF_READFILE("sample.html",sampfile)
@DTW_UPPERCASE(sampfile)
%}

Example 2: In this example, a file is uploaded to the server, then is read in using DTWF_READFILE and passed to a stored procedure for processing and display in an XML browser.

In the configuration file:

DTW_UPLOAD_DIR /usr/lpp/internet/server_root/tmplobs
FFI_PATH       /usr/lpp/internet/server_root/tmplobs
 

In the macro:

%DEFINE{
    DATABASE="SALES_DB"
%}
 
%FUNCTION(DTW_SQL) dxx_GenXML(IN CLOB dad,       IN CHAR(31) result_tab,
                              IN INTEGER ovType, IN VARCHAR(1024) over,
                              IN INTEGER MaxRow, OUT INTEGER NumRow,
                              OUT INTEGER dxxRC, OUT VARCHAR(99) dxxMSG) {
   CALL db2xml!dxxGenXML
   %REPORT{
      %ROW{
         @DTW_rHTMLENCODE(V1)
      %}
   %}
   %MESSAGE{
      default: "" : continue
   %}
%}
 
%HTML(input){
<form enctype="multipart/form-data" method="post" action="report">
   <p>File to upload:</p>
   <p><input type="file" name="dad_file" /></p>
   <p><input type=submit /></p>
</form>
%}
 
%XML(report){
  @DTWF_READFILE(DAD_file, DAD)
<xml version="1.0" ?>
<xml-stylesheet type="text/xsl" href="ndTable.xsl" ?>
  <XMLBlock>
  @dxx_GenXML( DAD, "result_tab", "0", "" , "1", numRows, dxxRC, dxxMSG )
  </XMLBlock>
%}
 


[ Top of Page | Previous Page | Next Page | Index ]