I am new to writing shell scripts. I currently have some reports that we run in HIVE SQL and I am trying to automate them the best I can. Currently I use crontab within our UNIX environment to have these queries run automatically everyday. Right now I have to paste that data into excel then filter and create separate documents for each "end-user".
What I am trying to accomplish is this:
I have a column in my output query that shows the name of a company, CompanyA, CompanyB, CompanyC etc. Depending on the details in there it could be anywhere from 12-20 different "companies". I don't want to hard code a query for each one to create it's own output. What I would like to do, is have a query that selects each unique company in that field(agency_name) and then run my select statement that would say:
select * from output_results where agency_name = "name here" and then write this output to a csv named Balance_Detail_"NAME"_Date then loop through and run this query and create an output for each name it found in the agency_name field.
selectstatment above in a loop,while read co_name ; do printf "select .... $co_name ....\n" | sqlClient ...args... | awk '...post filtering...' > $co_name.txt < co_nameFileList.txtWould be the general outline, but will require a fair amout of work on your part to get it to work and then bullet-proof it for errors.{}tool from the Edit menu on mouse-selected text to getcode/data/output/errMsgformatting. Try to make it so it is copy/pasteable by readers. Also recall that we won't have access to your databases, but include which client you are using from cmdline (no GUIs!).sqlplusorisqlare common. Good luck.