简体   繁体   English

通过Shell脚本从表中删除记录

[英]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. 我认为您不需要阅读-r。 Use just read roll 使用只读卷
  2. Make sure roll_no is not a varachar. 确保roll_no不是变量。 if yes, add single quotes to $roll 如果是,请在$ roll中添加单引号

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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