我正在尝试编写一个 bash 函数来提示模式所有者并删除所有相应的模式。
function db_cleanup
{
#accept user input
read -p "Schema Owner: " input
sqlplus -s $usr1/$pwd1@$sid1 << EOF
declare
usr_d varchar2(10) := '&input'; --reas user input here
sqlstmt varchar2(128);
begin
sqlstmt := 'drop user '||$usr_d||' cascade';
dbms_output.put_line(sqlstmt); execute immediate sqlstmt;
sqlstmt := 'drop user ab_'||$usr_d||' cascade';
dbms_output.put_line(sqlstmt); execute immediate sqlstmt;
sqlstmt := 'drop user xy_'||$usr_d||' cascade';
dbms_output.put_line(sqlstmt); execute immediate sqlstmt;
end;
/
EOF
}
输出如下所示:
Enter Schema Owner: ABC
Enter value for usr_in:
User requested Interrupt or EOF detected.
-bash-3.2$
请让我知道如何解决这个问题。提前致谢。