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

determine the output of the following command: echo ${new:-variable}

726


What is basename in shell script?

778


Print a given number, in reverse order using a shell script such that the input is provided using command line argument only.

921


Explain about non-login shell files?

867


What is the difference between break and continue commands?

773


What is the default ubuntu terminal?

810


Rewrite the command to print the sentence and convert the variable to plural: echo “i like $variable”.

798


Why do we write bin bash in shell scripts?

706


What does $$ mean in shell script?

775


write a shell script to generate a alert ? like when ur birthday came then generate a alert ur birthday is today like that ?

3781


What is an sh file?

725


Which shell is the best?

739


What are the advantages of shell scripting?

803


Explain how you Automate your application using Shell scripting.

2037


What is the syntax of "nested if statement" in shell scripting?

798