The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Add multiple .csv files as sheets to an excel file in unix. libin4u2000 Shell Programming and Scripting 2 01-20-2009 11:20 PM
How to combine different Excel sheets into a single work book using UNIX jagadish99 Shell Programming and Scripting 3 08-27-2008 07:23 PM
How to format excel sheets in UNIX?? Vijay06 Shell Programming and Scripting 2 05-16-2007 10:01 AM
Multiple excel work sheets through UNIX puspendu Shell Programming and Scripting 1 05-03-2006 05:28 AM
creating more than 2 excel sheets in C manceryder High Level Programming 7 12-20-2005 06:10 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-28-2009
parvathi_rd parvathi_rd is offline
Registered User
  
 

Join Date: Apr 2009
Posts: 7
Sending SQL Queries output to different Excel sheets

Hi,

I need your help in sedning sql queries output to different excel sheets.

My requirement is like this:

Query1: Select name from table1 where status = 'Complete'
Query2: Select name from table1 where status = 'Failed'
Query3: Select name from table1 where status = 'Ignored'

When i execute these queries, i want output of Query1 to be on sheet1 and output of query2 to be on sheet2 and output of query3 on sheet3 of an excel file.

Not sure whether it can be achieved using sqlplus.

Could some one please help me in this.

Thanks .
Parvathi
  #2 (permalink)  
Old 05-28-2009
dinjo_jo dinjo_jo is offline
Registered User
  
 

Join Date: May 2008
Posts: 78
You can do that in perl using Simple::Excel
  #3 (permalink)  
Old 05-28-2009
parvathi_rd parvathi_rd is offline
Registered User
  
 

Join Date: Apr 2009
Posts: 7
Hi dinjo_jo,

Thanks for your inputs.
Could you please tell me the procedure to do that?
sorry for asking. I know perl but not to this extent.

Once again thanks.

Parvathi.
  #4 (permalink)  
Old 05-28-2009
dinjo_jo dinjo_jo is offline
Registered User
  
 

Join Date: May 2008
Posts: 78
I have being doing it in sybase using perl.

use Spreadsheet::WriteExcel;
use Spreadsheet::WriteExcel::Worksheet;
use Sybase:Blib;

my @results;


my $sql = "select *"
my $dbh = Sybase:Blib->new($user , $passwd , $server);
if (defined $dbh)
{
@results = $dbh->nsql($sql , "HASH");
}
else
{
print "No DB Connection found for $server";
}

my $ebook = Spreadsheet::WriteExcel->new(file);
my $esheet = $ebook->addworksheet($title);
my $format = $ebook->addformat();
my $formatheader = $ebook->addformat();
my $formatcolumn = $ebook->addformat();

$formatheader->set_size(20);
$formatheader->set_font('Verdana');
$formatheader->set_color('brown');
$formatheader->set_align('center');
$formatheader->set_bold();
$formatheader->set_merge();


$formatcolumn->set_size(10);
$formatcolumn->set_font('Verdana');
$formatcolumn->set_color('navy');
$formatcolumn->set_align('center');
$formatcolumn->set_bold();
$formatcolumn->set_italic();

$format->set_color('black');
$format->set_font('Verdana');
$format->set_align('center');

$esheet->write_blank(0,0,$formatheader);
$esheet->write_blank(0,1,$formatheader);
$esheet->write_blank(0,2,$formatheader);
$esheet->write_blank(0,3,$formatheader);
$esheet->set_column(0, 2, 25,$formatheader);


$esheet->set_column(2, 0, 25,$formatcolumn);
$esheet->set_column(2, 1, 25,$formatcolumn);
$esheet->set_column(2, 2, 25,$formatcolumn);
$esheet->set_column(2, 3, 25,$formatcolumn);
$esheet->set_column(2, 4, 25,$formatcolumn);


my $o = 0;
foreach my $values (@results)
{
$esheet->set_column(3,$o, 25,$format);
$esheet->write($i,0,"$values->{'Branches_ShortName'}",$format);
$esheet->write($i,1,"$values->{'Portfolios_ShortName'}",$format);
$esheet->write($i,2,"$values->{'Portfolios_Name'}",$format);
$esheet->write($i,3,"$values->{'Folders_ShortName'}",$format);
$esheet->write($i,4,"$values->{'Folders_Name'}",$format);
$i++;
$o++;
}

$ebook->close();
  #5 (permalink)  
Old 05-28-2009
parvathi_rd parvathi_rd is offline
Registered User
  
 

Join Date: Apr 2009
Posts: 7
Smile

Thanks dinjo_jo.

Will use this to get the results i am looking for.

Thanks alot...You have been very helpful.

Parvathi.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:31 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0