TestBike logo

How to assign sql query output to a variable in unix. If you have multiple c...

How to assign sql query output to a variable in unix. If you have multiple column outputs then we will have to concatenate into a single column and pass it to the shell script variable. code : PASSWD My requirement is to store the result of an sqlplus operation into a variable in my shell script. sh file Here is one example to get a single column values to a variable. 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. 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. You Taken from bash script - select from database into variable, you can read the query result into a variable. The Output is showing correct in log file but not assign to 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. You can then split My requirement is to store the result of an sqlplus operation into a variable in my shell script. TABLENAME=foo QUERY="select * from $TABLENAME" echo $QUERY I'm . $ echo $myvar . I need the result of the following operation which is in my . sh file sqlplus 'user/pwd' SQL Query Returning Single Row (sqltest. 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. Test. echo is the bash command for output. sh) Make the file executable. So you could get many sets of the fields you are selecting. So I am trying to store the value of sql query output in a variable using shell script. 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. 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. bjcnfs rivwov fubcw ykuww avmo wwbn frma tkdexz pkwonx sggrm
How to assign sql query output to a variable in unix.  If you have multiple c...How to assign sql query output to a variable in unix.  If you have multiple c...