Problem while storing sql query value in a variable


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Problem while storing sql query value in a variable
# 1  
Old 02-28-2008
Problem while storing sql query value in a variable

Hi,

When i execute the below statement , the value is not getting stored in the variable.

AnneeExercice=`sqlplus $LOGSQL/$PASSWORDSQL << FIN >> $GEMOLOG/gemo_reprev_reel_data_ventil_$filiale.trc
SELECT bi09exercice
FROM bi09_scenario
WHERE bi09idfiliale=UPPER('de')
AND bi09flagcourant='O'
AND bi09cycle='R' ;
FIN`

I got struck at this point. Can you please suggest me whats wrong in the statement.
# 2  
Old 02-28-2008
Well, you are redirecting standard output to $GEMOLOG/gemo_reprev_reel_data_ventil_$filiale.trc
Either remove this redirection or change the ">>" into "2>"...
At least, assuming all the other stuff is OK... Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to Assign the Output of an SQL Query to a Variable?

Hi iam new to shell scripting how to declare variables as redshift query and I have to compare two counts by using if condition . ex:count=select count(*) from prd; select count(*) from prd; select count(*) from tag; can any one help me . Please use CODE tags when displaying... (1 Reply)
Discussion started by: sam526
1 Replies

2. Shell Programming and Scripting

Storing multiple sql queries output into variable by running sql command only once

Hi All, I want to run multiple sql queries and store the data in variable but i want to use sql command only once. Is there a way without running sql command twice and storing.Please advise. Eg : Select 'Query 1 output' from dual; Select 'Query 2 output' from dual; I want to... (3 Replies)
Discussion started by: Rokkesh
3 Replies

3. Shell Programming and Scripting

Asign to variable ksh some values of sql query

Hi, I'm trying to asign to ksh varible some values of a sql query. The output query would be: xxxx 1 yyyy 2 I do: values=`$PATH_UTI/query_sh " select think1||'------'||think2 from some_table where think3 = '$1'; ... (2 Replies)
Discussion started by: mierdatuti
2 Replies

4. Shell Programming and Scripting

Storing the value of a single query to a Variable - What am i doing wrong?

I tried the below : #!/bin/ksh testvar=$( sqlplus $user/$pass << EOF set pagesize 0 feedback off verify off heading off echo off; whenever sqlerror exit 1 SELECT 1+1 FROM DUAl; COMMIT; EXIT; EOF) echo "testvar="$testvar The output that I am getting is : > sh example.sh... (3 Replies)
Discussion started by: SriRamKrish
3 Replies

5. Shell Programming and Scripting

Problem in storing value to variable

#bash curVer=`cat /var/sadm/clsversion | cut -f 2 -d "_"` echo "CurVer:$curVer" ls |grep -v tar| grep -v sh| grep -v log|cut -f 1 -d "_" | sort -u >tmp1 for line in $(cat tmp1) do ver=`echo $line_$curVer` ls $line* |sort >tmp2 grep -n ${ver} tmp2 >/dev/null ... (2 Replies)
Discussion started by: rajamohan
2 Replies

6. UNIX for Advanced & Expert Users

Passing Hash variable in to sql query in perl

Hi Everyone, Can anyone help me how do i call hash variable in to sql query in perl. Please see the script below i have defined two Hash %lc and %tab as below $lc{'REFF'}='V_RES_CLASS'; $lc{'CALE'}='V_CAP_CLASS'; $lc{'XRPD'}='V_XFMR_CLASS'; $tab{'V_RES_CLASS'}='V_MFR_SERS';... (6 Replies)
Discussion started by: jam_prasanna
6 Replies

7. Shell Programming and Scripting

How to store the sql query's output in a variable

Hi, My requirement is : We are calling an sql statement from a UNIX session, and fetching data into some variables from a table .. now we are unable to access these variables from outside the SQL part. Please let me know how can I achieve this. Can you please share a code snippet which... (4 Replies)
Discussion started by: venkatesh_sasi
4 Replies

8. Shell Programming and Scripting

script variable within a sql query

I created a script to read a csv file with four columns. The script also saved values of each col in a arry. In the script, i connected to db try to run a query to pull out data baisc on the values from the csv file. select Num from tableName where Sec_Num in ('${isin}') /*isin is an arry... (1 Reply)
Discussion started by: Sherry_Run
1 Replies

9. Shell Programming and Scripting

storing database query in a variable

I am executing a SQL query in Unix Server: select status,location from user_information where request_id='DS-43720' In shell script I am writing this query in the below manner: echo "select status,location from user_information where request_id='DS-43720' ;" >> $directory/info.sql ... (3 Replies)
Discussion started by: debu
3 Replies

10. Shell Programming and Scripting

sql query variable not exactly unix

I know htis isnt exactly unix.... but hopefully someone can help me or direct me someplace to get help. I can run sql queries in scripts against my informix db using: dbaccess mydb myquery.sql >> sql.output I need to write my script to select based on todays date. Its very... (5 Replies)
Discussion started by: MizzGail
5 Replies
Login or Register to Ask a Question