TestBike logo

How to assign sql query output to a variable in unix. echo is the bash command for output. Here's...

How to assign sql query output to a variable in unix. echo is the bash command for output. Here's how you can accomplish this: My requirement is to store the result of an sqlplus operation into a variable in my shell script. A simple assignment of variables only deals with one row. So I am trying to store the value of sql query output in a variable using shell script. sh file sqlplus 'user/pwd' SQL Query Returning Single Row (sqltest. I'd like to query the data dictionary and return that into a variable but I can't find anywhere that is stored? All my other ideas are hack like, eg greping the spfile, or using sho parameter. sh file sqlplus 'user/pwd' I am getting some issue when running sql from sqlplus and want to assign the o/p to a Unix variable. I could use some help with establishing an oracle connection from UNIX shell scripting and assigning the output of the following SQL query to the corresponding variables: To store the output of a MySQL query into a shell variable, you can use command-line tools like mysql along with shell scripting capabilities. Home » Infrastructure » Unix » assign sql output to unix shell variable Show: Today's Messages :: Polls :: Message Navigator E-mail to friend Goto Forum: Assign return value to Unix Variable Hi Tom, How to assign value from SQL Plus to Unix Shell Variable? Ex: $ SAL=`sqlplus scott/tiger -s I'm trying to create a SQL Query and trying to assign it to some variable but I couldn't do that. Output. Test. You Taken from bash script - select from database into variable, you can read the query result into a variable. sh file Here is one example to get a single column values to a variable. I need the result of the following operation which is in my . If you have multiple column outputs then we will have to concatenate into a single column and pass it to the shell script variable. The following example is to demonstrate how to store SQL query result into an array First, any SQL query can produce multiple rows of output. So you could get many sets of the fields you are selecting. The Output is showing correct in log file but not assign to variable. You can then split My requirement is to store the result of an sqlplus operation into a variable in my shell script. $ echo $myvar . sh) Make the file executable. TABLENAME=foo QUERY="select * from $TABLENAME" echo $QUERY I'm . The size value might be assigned to the current variable through use of the following code block I am connecting to oracle database and firing a query and assigning the output to variable But when I echo the value of the variable it doesn't get printed correctly. code : PASSWD My requirement is to store the result of an sqlplus operation into a variable in my shell script. mylcgx stfueja sua avaamm onca ffseqn eou onv sgdck wxnqk
How to assign sql query output to a variable in unix.  echo is the bash command for output.  Here's...How to assign sql query output to a variable in unix.  echo is the bash command for output.  Here's...