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
What is a shell? · Types of shell · what is shell scripting?
Which scripting language is best for automation?
How to find all the files modified in less than 3 days and save the record in a text file?
How can you find out how long the system has been running?
What is a boot block?
What are the different types of shell scripting?
What is an sh file?
how to get part of string variable with echo command only?
What are the different variables present in linux shell?
When should shell programming/scripting not be used?
How do I run a script on mac?
What is difference between bash and shell?
How to pass an argument to a script?
How to open a read-only file in the shell?
How do we create command aliases in a shell?