如何在Oracle代码中传递Linux变量?
我需要以下面的格式传递它,并且它不应该要求“输入 1 的值:”
请指教。
mount='/u08/dbname/'
sqlplus -s "/ as sysdba" <<EOF
set serveroutput on;
set feedback off;
set verify off;
set heading off;
DECLARE
line varchar(100);
BEGIN
line := '&1';
if (5 > 0)then
dbms_output.put_line(line);
end if;
END;
/
$mount
EOF
答案1
export mount='/u08/dbname/'
sqlplus -s "/ as sysdba" <<EOF
set serveroutput on;
set feedback off;
set verify off;
set heading off;
DECLARE
line varchar(100);
BEGIN
line := '$mount';
if (5 > 0) then
dbms_output.put_line(line);
end if;
END;
/
$mount
EOF
您也可以将 Unix/Linux 命令的输出分配给变量:
export SPACE=$(df --output=avail -m /dev/sda8 | tail -1)