unloadTable()
The sqlLib.unloadTable() system function unloads data from a relational database into a file. The function is available only for Java™ generation.
To load information from a file and insert it into a relational database table, use the sqlLib.loadTable() function.
Syntax
sqlLib.unloadTable(
fileName STRING in,
selectStatement STRING in
[, delimiter STRING in
])
- fileName
- The name of the file. The name is fully qualified or is relative to the directory from which the program is invoked.
- selectStatement
- Specify the criteria for selecting data from the relational database.
Use the syntax of an SQL SELECT statement without including host variables;
for example:
"SELECT column1, column2 FROM myTABLE WHERE column3 > 10" - delimiter
- Specifies the symbol that separates one value from the next in
the file. (One row of data must be separated from the next by the
newline character.)
The default symbol for delimiter is the value in the Java™ vgj.default.databaseDelimiter runtime property, and the default value for that property is a pipe (|).
The following symbols are not available:- Hexadecimal characters (0 through 9, a through f, A through F)
- Backslash (\)
- The newline character or Ctrl+J
Example
The following example stores the tab character (a decimal 9 in ASCII) in a character, then uses that character as a delimiter.
myTabChar CHAR(1) = strLib.intAsChar(9);
sqlLib.loadTable("myDataFile.txt",
"SELECT column1, column2 FROM myTABLE", myTabChar);
Empty strings and nulls
In the files accessed by the sqlLib.loadTable() or sqlLib.unloadTable() function, a zero-length string is represented by the "\" character followed by a blank, and a null is represented by two delimiters in a row.
||\ | |1234That string contains a null, a zero-length string, a string of one blank, and "1234".
Compatibility
| Platform | Issue |
|---|---|
| COBOL generation | The function is not supported. |