SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
DatabaseSave with column names

 
Reply to topic    SoftTree Technologies Forum Index » 24x7 Scheduler, Event Server, Automation Suite View previous topic
View next topic
DatabaseSave with column names
Author Message
Vince Sefcik



Joined: 22 Nov 2002
Posts: 4

Post DatabaseSave with column names Reply with quote

I'm using 24x7 version 3.3.5 to extract data from an
Oracle database and save it to an Excel file to
e-mail to a staff member. Is there an easy way to
add the selected table column names as the first row
of the spreadsheet? Here's a snippet of the code
I'm using to extract and save the data:

DatabaseConnect( "axis_PBX" )
DatabaseRetrieve( SQL, rows )
DatabaseDisconnect
isGreater( rows, 0, gotresults )
// If any results returned, send them via email
If( gotresults, NOTIFY, END )
NOTIFY:
// Save retrieved data in the temporary file
DatabaseSave( OutputFileName , "XLS" , rows )
END:

Fri Nov 22, 2002 12:32 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7963

Post Re: DatabaseSave with column names Reply with quote

Save column headers in a text file (as a comma-separated list) then save data as CSV file into another file and then concatenate both files.

Example:

FileSave( OutputFileName, "Column A, Column B, Column C\r\n" )
DatabaseSave( "temp.csv", "CSV" , rows )
ConcatEx( "cmd /b copy ", OutputFileName, " + temp.csv", Command )
RunAndWait( Command, "", 0, process )
FileDelete( "temp.csv" )

The created file will contain column headers and can be opened with Excel.

: I'm using 24x7 version 3.3.5 to extract data from an
: Oracle database and save it to an Excel file to
: e-mail to a staff member. Is there an easy way to
: add the selected table column names as the first row
: of the spreadsheet? Here's a snippet of the code
: I'm using to extract and save the data: DatabaseConnect( "axis_PBX"
: )
: DatabaseRetrieve( SQL, rows )
: DatabaseDisconnect
: isGreater( rows, 0, gotresults )
: // If any results returned, send them via email
: If( gotresults, NOTIFY, END )
: NOTIFY: // Save retrieved data in the temporary file
: DatabaseSave( OutputFileName , "XLS" , rows )
: END:

Fri Nov 22, 2002 1:28 pm View user's profile Send private message
Display posts from previous:    
Reply to topic    SoftTree Technologies Forum Index » 24x7 Scheduler, Event Server, Automation Suite All times are GMT - 4 Hours
Page 1 of 1

 
Jump to: 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


 

 

Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Flowers Online.