9.242 TRANSFORM_LIST
Þ Note: Built-In Function Rules.
Transforms the current contents of one or more working lists into a disk file.
It is designed to facilitate the transfer of information between Visual LANSA applications and other products (e.g: spreadsheets).
For use with
|
Arguments
|
Return Values
|
Technical Notes - TRANSFORM_LIST
SQLNULL Handling
When a field is SQLNULL, the *NULL equivalent is output.
Special Handling for BLOB and CLOB value
The full BLOB/CLOB file name will be saved in the output file. The BLOB/CLOB file itself will be duplicated in a subdirectory under the output file directory. The name of this subdirectory is <output file name>_LOB. For example if the output file is:
C:\Root\Data\Transformed1.dat,
and the original CLOB file is C:\XYZ\ CLOBNumber1.txt
then the duplicated CLOB file is
C:\Root\Data\Transformed1_LOB\CLOBNumber1.txt
and the CLOB value in the Transformed1.dat will be:
C:\XYZ\ CLOBNumber1.txt
If Transformed1.dat is moved (or copied ) into another system, move or copy the sub directory Transformed1_LOB and all its contents as well.
Example
The following outline function can save the contents of an existing SQL table to a disk file, or insert the contents of disk file into an SQL table (i.e. An SQL table Save/Restore function) .....
def_list #list fields(....) listcount(#count) type(*working) entrys(100)
request fields (#option and name of disk file involved)
if (#option = SAVE)
select fields(...) from_file(...)
add_entry #list
if (#count = 100)
use TRANSFORM_LIST #list (with "do not close" option)
clr_list #list
endif
endselect
use TRANSFORM_LIST #list (with "close" option)
else (#option was RESTORE)
dowhile (#retcode *ne EF)
use TRANSFORM_FILE into #list (with "do not close" option)
execute insertlist
endwhile
execute insertlist
endif
subroutine insertlist
selectlist #list
insert fields(...) to_file(....)
endselect
clr_list #list
endroutine
By adding the CONNECT_SERVER and CONNECT_FILE Built-In Functions, this function could be very simply expanded to support the following table of "data transfers":
Data Target |
<- - - - - - - - - - |
Data Source |
- - - - - - - - - -> |
|
PC SQL Table | PC Disk File |
IBM i File |
PC SQL Table |
N/A |
Yes |
Yes |
PC Disk File |
Yes |
N/A |
Yes |
IBM i File |
Yes |
Yes |
N/A |