SET SERVEROUTPUT ON
-- Demonstrate the usage of createHomeDirectory() and ResourceExists() subprograms.
-- Create a Home folder for the userName specified in the XML DB repository using createHomeDirectory() subprogram
-- and checks whether the folder created exists in the repository using ResourceExists() subprogram.
-- Note: Here 'userName' refers to the database schema. Modify reference to SCOTT with your schema
-- name in the below mentioned SQL statement.
-- This script can be executed by the 'SYS' user as it has the required privileges.
DECLARE
targetResource VARCHAR2(50); -- For specifying the path of the Home folder.
userName VARCHAR2(30) := 'SCOTT';
BEGIN -- Create Home folder for the connected user using the createHomeDirectory() subprogram.
-- createHomeDirectory() subprogram uses the ResourceExists() subprogram to check if the
-- Home directory already exists.
xdb_utilities.createHomeDirectory(userName);
-- Using ResourceExists() subprogram to check for the existence of the Home Folder
-- created above.
targetResource := '/home/' || userName;
IF (xdb_utilities.ResourceExists(targetResource) = 1) THEN
DBMS_OUTPUT.PUT_LINE('Resource exists !!!');
ELSE
DBMS_OUTPUT.PUT_LINE('Resource does not exist');
END IF;
END;
/
|