Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

how do you write sql queries using shell script
for eg:- we have databae table like EMPNO,ENAME,SAL,DEPTNO
columns in EMP table how you display EMPNO,SAL FIELDS from emp
in SHELL SCRIPT please explain with an example

Answer Posted / krishna

create a variable for your query like

sql1='select empid,empname,.... from emp;' in your script

then call sqlplus in your shell script as

slplus user/password@sql1

you can redirect the output or format it as you like.

you can pass userid pwd as parameters as arguments to your
shell script and use them as parameters $1 and $2. you can
check if all the parameters are given with Usage [$# eq. 2 ]
etc.

Is This Answer Correct ?    8 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

‎What is a shell? · ‎Types of shell · ‎what is shell scripting?

932


Which scripting language is best for automation?

895


How to find all the files modified in less than 3 days and save the record in a text file?

1010


How can you find out how long the system has been running?

853


What is a boot block?

966


What are the different types of shell scripting?

1042


What is an sh file?

893


how to get part of string variable with echo command only?

978


What are the different variables present in linux shell?

1049


When should shell programming/scripting not be used?

1090


How do I run a script on mac?

1040


What is difference between bash and shell?

1023


How to pass an argument to a script?

1105


How to open a read-only file in the shell?

1083


How do we create command aliases in a shell?

945