简体   繁体   中英

Delete record from table via shell script

I have the following code

echo "Please enter your Roll No"
 read -r roll
res_var=`sqlplus -s username/password << EOF
BEGIN
delete from stud_table where roll_no = '$roll'
COMMIT;
END;
/
EOF
`

I wish to delete a record when the user input roll no
Is my above code correct? Iam not getting any error but records are not getting deleted either

  1. I think you don't need read - r. Use just read roll
  2. Make sure roll_no is not a varachar. if yes, add single quotes to $roll

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM