0

I want to update the 'Inactive' for selected customer value where their status is active, I tried to do so but it does not update the 'Inactive' for the selected customer. Anyone having any idea what's wrong please let me know. Thanx!

#!/bin/bash

echo " --- Enter the Database name ---" #name of the database
read databasename

echo " --- enter the table name --- " #name of the table
read table_name

sqlite3 $databasename.db $table_name;

sqlite3 $databasename.db "select * from $table_name WHERE cus_status = 'Active';"

echo "---Select the domain to make Inactive---"
read inactive_user


sqlite3 $databasename.db  "UPDATE $table_name SET cus_status = 'Inactive' WHERE cus_name = $inactive_user $table_name";


sqlite3 $databasename.db "select * from $table_name";
5
  • Try putting $inactive_user in single quotes Commented Aug 21, 2017 at 11:25
  • sqlite3 $databasename.db "UPDATE $table_name SET cus_status = 'inactive' WHERE cus_name = '$inactive_user'"; Not working Commented Aug 21, 2017 at 11:37
  • Why do you repeat $table_name at the end of your SQL update query? Commented Aug 21, 2017 at 11:54
  • What error are you getting. Commented Aug 21, 2017 at 11:56
  • no error ,but the value not changed Commented Aug 22, 2017 at 2:54

1 Answer 1

1

Check data type of column cus_name. I'm assuming it's varchar. So, instead of $inactive_user you may try '$inactive_user'

"UPDATE $table_name SET cus_status = 'Inactive' WHERE cus_name = '$inactive_user' $table_name;"

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.