Looking to create something dynamic/generic enough to handle any file thrown at it. I'd like to dump a physical file to Excel and populate the headings and then data. I'm running into issues with the host variable.
Compile error:
My goal is to load up an array with the meta data and use it later in the program to output column headings in an Excel spreadsheet. I'll have this same need later when reading data from the file.
Compile error:
Code:
SQL0312 30 304 Position 41 Variable FIELDS not defined or not usable.
Code:
d ds d fields dim( 999 ) d columnName 50a overlay( fields ) d columnText 50a overlay( fields : *next ) d dataType 50a overlay( fields : *next ) d length 10i 0 overlay( fields : *next ) d numericScale 5i 0 overlay( fields : *next ) exec sql declare c1 cursor for select c.column_name , c.column_text , c.data_type , c.length , c.numeric_scale , t.table_schema , t.table_name , t.system_table_name , c.system_column_name from qsys2/systables t , qsys2/syscolumns c where t.table_name = c.table_name and t.table_schema = c.table_schema and t.table_schema = :library and t.table_name = :file ; exec sql open c1; exec sql fetch c1 into :fields ;
Comment