473,883 Members | 1,718 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Export Command - How to generate a row with column headers

I have been using the export command for quite some times to export
comma delimited file. I have always been looking at how to generate
the first row with the column header but never found a clean way to do
it. I have searched this newsgroup and the only suggestion found was
to cast all column to strings and do a union, or to add the first row
afterwards and I saw one suggestion where it was to create a unix
script.

Does anybody knows how to do this ? Or can you let me know if it is
not possible for comma delimited list to produce an output where the
first row contains the column header?

I found one way of doing it but it is sort of a HACK. You use WSF
format instead of DEL for the export and you can open that binary
output with Excel. (It's a WKS 1.2.3 file... Lotus note) For Example,
you run:
Db2export to "C:\you_file.xl s" of WSF select * from your_table

Then, after you open the above file with Excel, you can save it as a
CSV format. The new file in the CSV format now contains the column
header as the first row.

Oct 12 '06 #1
5 30338

Here is a sample DOS BAT file (Although, this is not so elegant, it
will work):
DB2 "EXPORT TO Dept_Data.txt OF DEL SELECT * FROM DEPARTMENT"
DB2 "EXPORT TO Dept_Header.txt OF DEL Modified by NoCharDEL SELECT
SUBSTR(REPLACE( REPLACE(XMLSERI ALIZE(CONTENT XMLAGG(XMLELEME NT(NAME c,
colname) ORDER BY colno) AS VARCHAR(100)),' <C>',', '),'</C>',''),3)
FROM syscat.columns WHERE tabschema='DB2A DMIN' AND
tabname='DEPART MENT'"
copy Dept_Header.txt +Dept_Data.txt Dept_with_Heade r.txt

Oct 13 '06 #2
That works great thanks! ...but I had to remove the nochardel.

For some odd reason it doesn't work and give this error:

SQL3016N An unexpected keyword "nochardel" was found in the filetmod
parameter for the filetype.

I type "db2 ? export" and it shows these options that are available for
the DB version I have ( Database server = DB2/6000 8.2.2)

NODOUBLEDEL, LOBSINFILE, CHARDELx, COLDELx, DLDELx
DECPLUSBLANK, DECPTx, DATESISO, 1, 2, 3, 4, CODEPAGE=x
Is it possible with the options above to produce the same behavior as
nochardel? For example, somehow pass a space to CHARDELx?

Oct 13 '06 #3
I think RS/6000 is already get minor.
I also don't know DB2/6000.
But, if you know RS/6000 script, it would be easy to remove first
character and last character of a file.
So, my idea is as fllowing:
DB2 "EXPORT TO Dept_Data.txt OF DEL SELECT * FROM DEPARTMENT"
DB2 "EXPORT TO Dept_Header.txt OF DEL SELECT
SUBSTR(REPLACE( REPLACE(XMLSERI ALIZE(CONTENT XMLAGG(XMLELEME NT(NAME c,
colname) ORDER BY colno) AS VARCHAR(100)),' <C>',', '),'</C>',''),3)
FROM syscat.columns WHERE tabschema='DB2A DMIN' AND
tabname='DEPART MENT'"
/* insert OS/script to remove first and last character of Header.txt */
copy Dept_Header.txt +Dept_Data.txt Dept_with_Heade r.txt

Oct 16 '06 #4
Thanks Tonkuma!

Oct 19 '06 #5
Thanks Tonkuma!

Oct 19 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
6797
by: ccjunk | last post by:
This may be a simple one but I have been working on it without joy for a couple of days now. Reading books and searching these groups hasn't helped yet either. I am trying to create a table dynamically with column headers based on the value of certain nodes and the rows populated ewith the values of certain child nodes of the same parent. My xml is something like this:
2
1872
by: Yaron | last post by:
Hi I'm creating a control very similar to the ListView in Details mode. I'm confused as to how to go about drawing the column headers at the top As the column headers are static and stay in one position (hence, they do not need to be scrolled by the system when the AutoScrollPosition is changed), I do not want to draw them each time the control needs to be repainted or the user scrolls down. The only way I can think of to do this right...
2
9694
by: David Veeneman | last post by:
How can I set a bound DataGridView control to use a dataset table's column captions, instead of column names? I'm working with a DataGridView control, which I have bound to a table in a dataset. The dataset is created at run time, so I don't know column headers in advance. The table's column captions are set at run time, using the DataColumn.Caption property. The table is bound to the grid using the grid's DataSource property. Here is my...
4
5098
by: Hans Merkl | last post by:
Hi, Is there a way to show the column headers of a GridView control even if there is no data? The only thing I see is the EmptyDataTemplate but I would also like to display the column headers. Thanks Hans
1
10245
by: ElenaR | last post by:
I need to figure out how to name my column headers in a DataGrid. In VB6, I could write DataGrid1.Columns(0).Caption = "ID". What is the format for VB.NET? Thanks in Advance!
2
2002
by: John Walker | last post by:
Hi, We have a datagrid with column headers. If the datagrid has more than say 25 rows the user needs to scroll down to be able to see the rest of the grid. When the user does this the column headers scrolls up off the screen and it becomes hard for the user to determine what the columns are. Is there a way to keep the columns headers in place (only for vertical scrolling) when the user scrolls down. Thanks, John
6
8768
by: no_spam_for_gman | last post by:
Hi, I have been using the db2 export function for quite sometimes. Everytime I want to use it I have to remove every carriage return from my SQL statement and have it all on one line as shown in the following simplistic example: db2 export to myfile.txt of del select a,b,c from staff This can be time consuming when you have big SQL joining many tables
0
4455
by: CDonlan | last post by:
Here is how im exporting //Clear response content and headers response.Clear(); response.ClearContent(); response.ClearHeaders(); //Add header response.AddHeader("content-disposition", "attachment;filename=" + fileName + ".xls");
1
4673
Denburt
by: Denburt | last post by:
This function was originally created back in the dawn of time, over the years I have made a number of changes and after searching the net I still didn't see 1 that allowed for the use of column headers so I thought I would post one that does. On the controls property simply click yes or no for Column Headers and off you go. You can use the Tag property to determine the column and the words displayed. 2;<No Selection> To help save a...
0
11109
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10405
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7957
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7114
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5782
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5979
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4602
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4198
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3226
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.