- 1 year ago
Unable to MKDIR using %userprofile% from within SQL*plus
When running SQLPlus, the %userprofile%
environment variable is not expanded automatically. However, you can use a combination of SQLPlus commands and the host
command to achieve the desired result.
Here's an example of how you can create a directory using %userprofile%
from within SQL*Plus:
- Start SQL*Plus and connect to your Oracle database.
- Use the
host
command to execute a shell command. In this case, we'll use themkdir
command to create a directory. - Pass the value of
%userprofile%
as an argument to themkdir
command.
Here's the SQL*Plus script:
sql-- Start SQL*Plus and connect to your Oracle database
-- Use the HOST command to execute a shell command
host mkdir "&userprofile\mydirectory"
When you run this script in SQL*Plus, the host
command will execute the mkdir
command, creating the specified directory using the expanded value of %userprofile%
.
Make sure to enclose the %userprofile%
variable in double quotes ("&userprofile\mydirectory"
) to handle any special characters or spaces that may be present in the path.
Note that the host
command is specific to SQL*Plus and may not work in other database tools or environments.