Sponsored Content
Top Forums Shell Programming and Scripting Unable to pass value from .Shell script to .SQL file Post 302942466 by reddy298599 on Wednesday 29th of April 2015 04:41:14 AM
Old 04-29-2015
Unable to pass value from .Shell script to .SQL file

Hi All,
I am new to shell script. I am trying to pass value from .sh file to .sql file .
But I am able to run the .sql file from .sh file with values in sql file.
But I am unable to pass the values from .sh file. can some one please help to resolve this.

here is my .sh file
s1.sh

Code:
#!/bin/ksh[/FONT][/SIZE][/COLOR]
echo "please enter case:"
read v_case_nbr
echo "the case number entered is $v_case_nbr"
sqlplus wmtst/wmtst@wmtest <<EOF
@ test.sql $ v_case_nbr
exit;
EOF

here is .sql file


Code:
 SET SERVERoutput on;
declare 
v_case_nbr varchar(400):='&Enter_Case_nbr';
c_stat_code case_hdr.stat_code%type;

 cursor c1 is select ch.stat_code into c_stat_code from case_hdr ch  where ch.case_nbr=v_case_nbr;
  
 
begin
open c1;
LOOP
FETCH c1 into c_stat_code;
EXIT when c1%notfound;
If (c_stat_code = '50')
then
update case_hdr ch
set ch.stat_code='30',
ch.user_id = 'PILLAREM',
ch.mod_date_time = sysdate 
where ch.case_nbr = v_case_nbr;
dbms_output.put_line('Case_hdr:Case updated To putaway status ');
end if;
 end loop;
 close c1;
 end;
 /

Here I need to pass v_case_nbr='123456' from .sh file to .sql file

Please help me to resolve this.

Thanks a bunch.

Regards,
reddy298599

Last edited by Don Cragun; 04-29-2015 at 01:31 PM.. Reason: Remove FONT, COLOR, and FONT tags; add CODE and ICODE tags.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

how to pass values from oracle sql plus to unix shell script

how to pass values from oracle sql plus to unix shell script (2 Replies)
Discussion started by: trichyselva
2 Replies

2. Shell Programming and Scripting

How to pass pl/sql table values to shell script

Hello, i am using '#!/bin/bash', i want to make a loop in pl/sql, this loop takes values from a table according to some conditions, each time the loop choose 3 different variables. What i am not able to do is that during the loop i want my shell script to read this 3 variables and run a shell... (1 Reply)
Discussion started by: rosalinda
1 Replies

3. Shell Programming and Scripting

How to pass arguments to SQL file passed in shell script?

Hi, I am using SYBASE database. in my script i am connecting to DB via using isql. isql -U${S_USER} -S${S_SERV} -D${S_DB} -P${S_PWD} -b0 -w3000 -h0 -s"|" -i${MYDIR}/ABC.sql -oXYZ.txt << FINSQL i am taking a ABC.sql file to use the queries written in it and storing the output in... (3 Replies)
Discussion started by: dazdseg
3 Replies

4. Shell Programming and Scripting

How to Pass the Output Values from the PL/SQL Procedure to Shell Script?

hi, Could anyone tell me how to pass the output values of the PL/SQL procedure to Shell script and how to store that values in a shell script variable... Thanks in advance... (5 Replies)
Discussion started by: funonnet
5 Replies

5. Shell Programming and Scripting

pass null value to sql script from korn shell script

There are 4 parameters that I have to pass from korn shell to sql script. 1) I have to check if $1 , $2 , $3 and $4 are null values or not . How can I do that ? 2) Once its determined that these values are null (in the sense they are empty) how can I pass null values to sql script... (11 Replies)
Discussion started by: megha2525
11 Replies

6. Shell Programming and Scripting

unable to pass value to user prompt from calling shell script

This is my script structure main script calls configure script which needs to be run as a different user and the configure script calls my application installation script. the application instruction script prompts the user for a directory which I need to pass from my main or configure script. ... (4 Replies)
Discussion started by: cmastays
4 Replies

7. Post Here to Contact Site Administrators and Moderators

Unable to pass shell script parameter value to awk command in side the same script

Variable I have in my shell script diff=$1$2.diff id=$2 new=new_$diff echo "My id is $1" echo "I want to sync for user account $id" ##awk command I am using is as below cat $diff | awk -F'~' ''$2 == "$id"' {print $0}' > $new I could see value of $id is not passing to the awk... (0 Replies)
Discussion started by: Ashunayak
0 Replies

8. Shell Programming and Scripting

Unable to pass shell script variable to awk command in same shell script

I have a shell script (.sh) and I want to pass a parameter value to the awk command but I am getting exception, please assist. diff=$1$2.diff id=$2 new=new_$diff echo "My id is $1" echo "I want to sync for user account $id" ##awk command I am using is as below cat $diff | awk... (2 Replies)
Discussion started by: Ashunayak
2 Replies

9. Shell Programming and Scripting

Unable to pass send command in shell script

I am trying to automate a testcase . I am installing some software and it waits for user input after displaying "Do you want to continue ? " I am trying to do this in shell scripting. #!/bin/bash #!/usr/bin/expect -f /usr/bin/expect << EOF spawn apt-get install openjdk-7-jdk expect "*Do you... (1 Reply)
Discussion started by: Abdul Navaz
1 Replies

10. Shell Programming and Scripting

How to pass Oracle sql script as argument to UNIX shell script?

Hi all, $ echo $SHELL /bin/bash Requirement - How to pass oracle sql script as argument to unix shell script? $ ./output.sh users.sql Below are the shell scripts and the oracle sql file in the same folder. Shell Script $ cat output.sh #!/bin/bash .... (7 Replies)
Discussion started by: a1_win
7 Replies
CUBRID_IS_INSTANCE(3)							 1						     CUBRID_IS_INSTANCE(3)

cubrid_is_instance - Check whether the instance pointed by OID exists

SYNOPSIS
int cubrid_is_instance (resource $conn_identifier, string $oid) DESCRIPTION
The cubrid_is_instance(3) function is used to check whether the instance pointed by the given $oid exists or not. PARAMETERS
o $conn_identifier -Connection identifier. o $oid -OID of the instance that you want to check the existence. RETURN VALUES
1, if such instance exists; 0, if such instance does not exist; -1, in case of error EXAMPLES
Example #1 cubrid_is_instance(3) example <?php $conn = cubrid_connect("localhost", 33000, "demodb"); $sql = <<<EOD SELECT host_year, medal, game_date FROM game WHERE athlete_code IN (SELECT code FROM athlete WHERE name='Thorpe Ian'); EOD; $req = cubrid_execute($conn, $sql, CUBRID_INCLUDE_OID); $oid = cubrid_current_oid($req); $res = cubrid_is_instance ($conn, $oid); if ($res == 1) { echo "Instance pointed by $oid exists. "; } else if ($res == 0){ echo "Instance pointed by $oid doesn't exist. "; } else { echo "error "; } cubrid_disconnect($conn); ?> The above example will output: Instance pointed by @0|0|0 doesn't exist. SEE ALSO
cubrid_drop(3), cubrid_get_class_name(3). PHP Documentation Group CUBRID_IS_INSTANCE(3)
All times are GMT -4. The time now is 01:18 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy