Extracting table data and its column names

Kalyansid

New Member
Hi,

I need help with my table dump. It is easier to dump a table. But I have to dump a table with all column names and its data i.e the column names in .csv format along with its data down below. Is there a way to extract column name as well as its data together. Right now i have to do a .df dump seperate and a .d seperately.


regards
 
I think you'll have to write a program for it yourself. If the format of the export is not too complex and if you don't use binary data and blobs etc, it should not all be that hard to do. You can get table and field names out of the _file and _field virtual tables and then dump your data out after it
 
There was a thread discussing this in depth within the last couple of months, if you browse a bit you should be able to find it.
 
Hi Tom,

I ran the query given by you.

find _file no-lock where _file-name = "ad_mstr".
output to value( _dump-name + ".hdr" ).
for each _field no-lock of _file break by _order:
if not last( _order ) then
put _field-name + ", ".
else
put _field-name skip.
end.
for each ad_mstr no-lock:
export delimiter "," ad_mstr.
end.
output close.

The output of column details displayed as below.

ad_addr,ad_name,ad_line1ad_line2ad_city,ad_statead_zip, ad_type,ad_attn,ad_phonead_ext, ad_ref, ad_sort,ad_countad_attn2ad_phonead_ext2,ad_fax, ad_fax2,ad_lin
e3ad_user1ad_user2ad_lang,ad_pst_iad_date,ad_countad_temp,ad_bk_acad_bk_acad_formaad_vat_rad_coc_rad_gst_iad_tax_tad_taxc,ad_taxabad_tax_iad_edi_tad_timezad_m
od_dad_useriad_edi_iad_edi_cad_conread_barlbad_barlbad_calenad_edi_sad_edi_lad__qad0ad__qad0ad__qad0ad__qad0ad__qad0ad__chr0ad__chr0ad__chr0ad__chr0ad__chr0ad
_tp_load_ctry,ad_tax_zad_tax_uad_misc1ad_misc2ad_misc3ad_wk_ofad_inv_mad_sch_mad_po_mtad_asn_data

It seems to miss the comma delimiter after some fields. Any idea. Sorry to bother you. Please advice.

regards,
 
Try this out
.
.
.
for each _field no-lock of _file break by _order:
if first( _order ) then
put unformatted _field-name.
else
put unformatted ", " + _field-name skip.
end.

.
.
.
 
Thanks Sikandra. I modified a bit and it works. The code snippet only displays field names using _field-name. Do we have a different keyword to fetch field labels.

thanks for help.

regards,
 
To get the labels, you should use _field._label instead of _field-name.
I would also so a check for the field name being blank just in case, something like:

for each _field no-lock of _file break by _order:
if first( _order ) then

do:
if _field._label <> "" then
put unformatted _field._label.
else
put unformatted _field._field-name skip.

end.
else do:
if _field._label <> "" then
put unformatted "," + _field._label.
else
put unformatted ", " + _field-name skip.
end.
end.
This way you will get the field name output in the eventuality that a label has been left blank.
 
Back
Top