Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Thanks crabboy for your quick reply...yaa..I think this query will work....But I had given just sample queries.
My actual queries are:
1)select min(start_time) from table1 where req_name='s_20080709' and end_date='6/30/2008'
2)select max(upd_time) from table1 where req_name='s_20080709' and end_date='6/30/2008'
3)select min(start_time) from table1 where req_name='s_20080709' and end_date='7/31/2008'
4)select max(upd_time) from table1 where req_name='s_20080709’ and end_date='7/31/2008'
As you can see table name is same for all the queries but end_date is different for first two and last two queries.
I can combine query1 and query2 to single query and pass result to csv file and can combine query3 and query4 to single query and pass result to csv file.
How can I handle the field end_date,so that I can combine the result of all four queries and pass it to csv file.so that it will look like in csv file as below.
server1: result1 |result2| result3| result4|
Please help on how to append data to csv file as I will be running these quries for different servers.
You did not specify what database you are using, but for Oracle, something like this will work:
Code:
create or replace procedure test1( condition1 varchar2, condition2 varchar2, condition3 varchar2) as
lv_min varchar2(20);
lv_max varchar2(20);
lv_min2 varchar2(20);
lv_max2 varchar2(20);
BEGIN
select min(start_time) into lv_min from aps_account where req_name=condition1 and end_date=condition2;
select max(upd_time) into lv_max from aps_account where req_name=condition1 and end_date=condition2;
select min(start_time) into lv_min2 from aps_account where req_name=condition1 and end_date=condition3;
select max(upd_time) into lv_max2 from aps_account where req_name=condition1 and end_date=condition3;
dbms_output.put_line('Server x: ' || lv_min || '|' || lv_max || '|' || lv_min2 || '|' || lv_max2 );
END;
Thanks a lot crabboy...... I am using Sybase as database as I used command "isql -Sserver -Ppassword -o result.csv" in my first post...As per your reply,got an idea how to proceed further...I will try to use that for Sybase.
Hi crabboy.....could you please post the solution for Sybase as well in detail as you provided for the oracle like creating procedure,running it,passing parameters to it etc.as I tried to work on that but getting some errors with Sybase procedure....
begin
select @lv_min=(select min(start_time) from tabel1 where requestor_name= @condition1 and end_date= @condition2)
select @lv_max=(select max(upd_time) from tabel1 where requestor_name= @condition1 and end_date= @condition2)
select @lv_min2=(select min(start_time) from tabel1 where requestor_name= @condition1 and end_date= @condition3)
select @lv_max2=(select max(upd_time) from tabel1 where requestor_name= @condition1 and end_date= @condition3)
select @lv_min
select @lv_max
select @lv_min2
select @lv_max2
end
Can any one tell me how to copy data to a excel/csv file from text file to other columns,leaving first column unaffected i.e it should not overwrite data in first column using shell script.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.