Linux parameters in SQL command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Linux parameters in SQL command
# 1  
Old 08-07-2015
Linux parameters in SQL command

Hello.
It's my first steps in creat bash skript.
This is my skript :
Code:
mysql -e "  
UPDATE datebase.table
SET U_O_ID=NULL 
WHERE U_O_ID LIKE '"$w4"'
AND N_U != '"$w1"'
   " -u admin -p""Password"" ;

It doesn't work.
I find a lot of topic about it, but I didn't find simple answer.
Thenks for any help.Smilie
# 2  
Old 08-07-2015
Possibly you are single quoting variables $w[14] add backslash in front of single quotes to remove its special meaning

Last edited by rbatte1; 08-07-2015 at 07:36 AM..
# 3  
Old 08-07-2015
Can you give me example ?

---------- Post updated at 06:43 AM ---------- Previous update was at 04:12 AM ----------

But w1 and w2 aren't a table items. They are like A and B.
# 4  
Old 08-07-2015
Instead of '"$w4"' use '$w4'. What is inside the shell variables w1 and w4 ? What is with the double double quotes around Password ?

--
The SQL Syntax aside, usually how this is done is, something like:
Code:
mysql -u admin ....   << EOF
UPDATE datebase.table
SET U_O_ID=NULL 
WHERE U_O_ID LIKE '$w4'
AND N_U != '$w1'
EOF


Last edited by Scrutinizer; 08-07-2015 at 09:40 AM..
# 5  
Old 08-07-2015
You put first
Code:
"

. in
Code:
mysql "

Where is the last one ?
# 6  
Old 08-07-2015
Yes that quote should not be there. I corrected in my post.
# 7  
Old 08-07-2015
Code:
mysql -u admin ....   << EOF
UPDATE datebase.table
SET U_O_ID=NULL 
WHERE U_O_ID LIKE '$w4'
AND N_U != '$w1'
EOF

It made without error, but it didn't do anythink in SQL table.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. 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

2. Shell Programming and Scripting

Shell script to run sql query having a long listing of parameters

Hi, I have a query regarding execution of a sql query having long listing of parameters ..I need to execute this query inside a shell script. The scenario is like.... Suppose I have a file abc.txt that has the card numbers..it could be in thousands.. then I need to fire a query like ... (12 Replies)
Discussion started by: vsachan
12 Replies

3. Shell Programming and Scripting

Calling sql file from shell script with parameters.

Hi, I am calling a sql file script.sql from shell script and passing few parameters also as shown below: sqlplus -S id/password @script.sql $param1 $param2 Now,In sql file I have to create a extract text file after querying oracle tables based on the parameters passed(param1,param2) as... (7 Replies)
Discussion started by: anil029
7 Replies

4. Shell Programming and Scripting

Dynamic SQL query based on shell script parameters

Hi, I need a script that will run a dynamic Oracle SQL. Dynamic meaning the SQL statement depends on the parameter. For instance, something like this: #!/bin/ksh -x # Set environment . /home/mine/set_vars sqlplus $LOGINID <<! >> /home/mine/log.txt select count(1) from $1 where... (2 Replies)
Discussion started by: laiko
2 Replies

5. Shell Programming and Scripting

Run SQL with parameters from a file

Hello, I need to run a SQL which will get parameters from a .txt file. Basically I need to run following query select * from a table where identity_id in <list of values in A.txt file> A.txt file is having values 1 2 3 4 5 I need the SQL to pick the values from the file and... (2 Replies)
Discussion started by: asdban
2 Replies

6. UNIX for Advanced & Expert Users

Reading putty command line parameters from Linux

I am running Putty 0.60 from Windows XP and I am connecting to a Linux box. I would like to be able to pass a command line parameter to my Linux session so that my Linux session can execute a specific command, depending on the command line parameter. I have looked on the Internet and tried... (1 Reply)
Discussion started by: SFNYC
1 Replies

7. UNIX for Dummies Questions & Answers

Linux kernel module parameters

Hi, Does anyone know if it is possible to know the current value of a kernel module parameters after the module is loaded. Are the values of the parameters advertised at some /proc or /sys location ? The only thing I know is modinfo, that actually looks a the module .ko and gives a... (3 Replies)
Discussion started by: macL
3 Replies

8. Shell Programming and Scripting

Calling sql in shell script with parameters

Dear All, I want to call an sql script within a unix shell script. I want to pass a parameter into the shell script which should be used as a parameter in teh sql script. e.g $ ./shell1.sh 5000129 here 5000129 is a prameter inside shell script i am calling one sql script e.g. ... (2 Replies)
Discussion started by: Radhe
2 Replies

9. Shell Programming and Scripting

parameters in PL/SQL script

Hi , I am writing a unix script, calls an PL/SQL block which uses the parameters I passed to the Unix script. There are 3 sets of parameters I am passing: set 1 - a or b (only one parameter) set 2 - 2 2 (two parameters) set 3 - 2 10000 20000 (three parameters) Now, my question is I want... (3 Replies)
Discussion started by: reddyp
3 Replies

10. Filesystems, Disks and Memory

kernal parameters on Linux 7.3

Hi all, I am running 7.3 Redhat Linux, I have Oracle database running on it and I have some problem with the memory. every time I startup the database, the memory was peak up to 630M of Ram out 640M ram on the entire box and I didn't specify that much of memory on my database. Oracle advise me... (2 Replies)
Discussion started by: lapnguyen
2 Replies
Login or Register to Ask a Question