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 are the different types of variables used in shell script?
Write a shell script to get current date, time, user name and current working directory.
What is the difference between scripting and coding?
How to redirect both standard output and standard error to the same location?
How to calculate the number of passed arguments?
Calculate a real number calculation directly from the terminal and not any shell script.
How do I debug a shell script?
Given a file find the count of lines containing the word "abc".
How to get the last line from a file using just the terminal?
What are the various stages of a linux process it passes through?
How can you find out how long the system has been running?
How do you find out What is your shell?
What are the advantages of shell script?
What does it mean to debug a script?
What does $$ mean in shell script?