--1、创建DIRECTORY
create directory test_dir as '/usr/tmp'; (注:此处'/usr/tmp'可以是任何路径,只要该路径在服务器上存在)
--2、授权
Grant read,write on directory test_dir to cux;
--3、查看目录及权限
SELECT privilege, directory_name, directory_path
FROM user_tab_privs t, all_directories d
WHERE t.table_name(+) = d.directory_name
ORDER BY 2, 1;
# Initialize the environment variables by running the enviroment file
#*********************************************************************
# Initialize the environment variables by running the enviroment file*
#*********************************************************************
Initialize_Vars ()
{
echo "Initializing"
### Initialize the environment variables by running the enviroment file
. ${CUX_TOP}/bin/CUX_env
export SCRIPT_DIR="${CUX_TOP}/bin"
export TEMP_DIR=`eval echo $test_dir`
}
#*********************************************
# Check for the AP Directory *
#*********************************************
check_temp_dir ()
{
if [ ! "$TEMP_DIR" ];
then
echo " $TEMP_DIR irectory path is not specified in the environment file."
echo "Check CUX_env"
return 2
fi
if [ ! -d $TEMP_DIR ];
then
echo "Invalid Directory. "$TEMP_DIR" may not be existing."
return 2
fi
return 0
}
#*************************************************
# Check for the Script Directory *
#*************************************************
check_script_dir ()
{
#Check whether the scrip directory Exists or not
if [ ! -d $SCRIPT_DIR ];
then
echo "Invalid Script Directory. "$SCRIPT_DIR" may not be existing."
return 2
fi
echo "Valid Script Directory. "$SCRIPT_DIR" exists."
return 0
}
#Calling Main Program
#*********************************************
# Main Program *
#*********************************************
main ()
{
#Calling Initialize Variables to set the paths in Environment File
Initialize_Vars
exe_status=$?
#Start of First If statement
if [ $exe_status -ne 0 ];
then
echo "Intialize variables failed so Exiting"
exit $exe_status
fi
#End of First If statement
#Calling check_script_dir to check
check_script_dir
exe_status=$?
#Start of Second If statement
if [ $exe_status -ne 0 ];
then
echo "check_script_dir failed. So Exiting"
exit $exe_status
fi
#End of Second If statement
check_gl_dir
exe_status=$?
#Start of Third If statement
if [ $exe_status -ne 0 ];
then
echo "check_temp_dir failed. So Exiting"
exit $exe_status
fi
#End of Third If statement
echo "SQL_Loader program about to start for the file : " $P_FILE_NAME
#Loading data using SQL Loader
sqlldr $CUX_LOGIN silent=header silent=feedback control=$TEMP_DIR/$P_CONTROL_FILE data=$TEMP_DIR/$P_FILE_NAME log=$TEMP_DIR/$P_FILE_NAME"_"$ORA_REQID.log errors=10000 discardmax=10000
l_num_ldr_status=$?
echo $l_num_ldr_status
if [ $l_num_ldr_status -eq 1 ] || [ $l_num_ldr_status -eq 3 ] ;
then
echo "SQL Loader Failed to Load data file"
l_file_status=E
else
echo "SQL Loader Successfully Loaded the data file"
l_file_status=N
fi
exit 0
}
main