dbms_datapump.get_dumpfile_info can't read directory when compiled in stored procedure
I'm creating a stored procedure to load (impdp) a Datapump database dump.
I am trying to get the dump file's creation date (to compare with the date of a previously loaded dump), using DBMS_DATAPUMP.GET_DUMPFILE_INFO, like in this example.
When running in an anonymous block (like below), it runs fine, outputting the dump file's creation date. However, when this same block is adapted and compiled in a stored procedure, I get the ORA-39087 error (Directory name is invalid).
DECLARE
dumpfile VARCHAR2(256) := 'my_file.dp';
dir VARCHAR2(30) := 'MY_DIR';
info ku$_dumpfile_info;
ft NUMBER;
BEGIN
sys.dbms_datapump.get_dumpfile_info(dumpfile, dir, info, ft);
FOR rec IN (SELECT * FROM TABLE (info) WHERE item_code = 6 ) LOOP
dbms_output.put_line(rec.value);
END LOOP;
END;
The directory exists. The name is valid. When I run
SELECT * FROM datapump_dir_objs;
with the same user, I can see that the user has READ and WRITE privileges on the directory. Oracle version is 11g Release 11.2.0.4.0.
Any light on what I am doing wrong?
Thanks in advance.
oracle plsql directory datapump
add a comment |
I'm creating a stored procedure to load (impdp) a Datapump database dump.
I am trying to get the dump file's creation date (to compare with the date of a previously loaded dump), using DBMS_DATAPUMP.GET_DUMPFILE_INFO, like in this example.
When running in an anonymous block (like below), it runs fine, outputting the dump file's creation date. However, when this same block is adapted and compiled in a stored procedure, I get the ORA-39087 error (Directory name is invalid).
DECLARE
dumpfile VARCHAR2(256) := 'my_file.dp';
dir VARCHAR2(30) := 'MY_DIR';
info ku$_dumpfile_info;
ft NUMBER;
BEGIN
sys.dbms_datapump.get_dumpfile_info(dumpfile, dir, info, ft);
FOR rec IN (SELECT * FROM TABLE (info) WHERE item_code = 6 ) LOOP
dbms_output.put_line(rec.value);
END LOOP;
END;
The directory exists. The name is valid. When I run
SELECT * FROM datapump_dir_objs;
with the same user, I can see that the user has READ and WRITE privileges on the directory. Oracle version is 11g Release 11.2.0.4.0.
Any light on what I am doing wrong?
Thanks in advance.
oracle plsql directory datapump
3
Does the user have read and write privileges granted directly to them, or via a role? (A quick way to check is to see whether your query still shows the same data after you doset role none
.)
– Alex Poole
Nov 20 at 18:39
Thanks @AlexPoole ! The privilege is granted by a role. I addedAUTHID CURRENT_USER
to the procedure's header and all went fine.
– Fernando Volquind
Nov 21 at 10:45
add a comment |
I'm creating a stored procedure to load (impdp) a Datapump database dump.
I am trying to get the dump file's creation date (to compare with the date of a previously loaded dump), using DBMS_DATAPUMP.GET_DUMPFILE_INFO, like in this example.
When running in an anonymous block (like below), it runs fine, outputting the dump file's creation date. However, when this same block is adapted and compiled in a stored procedure, I get the ORA-39087 error (Directory name is invalid).
DECLARE
dumpfile VARCHAR2(256) := 'my_file.dp';
dir VARCHAR2(30) := 'MY_DIR';
info ku$_dumpfile_info;
ft NUMBER;
BEGIN
sys.dbms_datapump.get_dumpfile_info(dumpfile, dir, info, ft);
FOR rec IN (SELECT * FROM TABLE (info) WHERE item_code = 6 ) LOOP
dbms_output.put_line(rec.value);
END LOOP;
END;
The directory exists. The name is valid. When I run
SELECT * FROM datapump_dir_objs;
with the same user, I can see that the user has READ and WRITE privileges on the directory. Oracle version is 11g Release 11.2.0.4.0.
Any light on what I am doing wrong?
Thanks in advance.
oracle plsql directory datapump
I'm creating a stored procedure to load (impdp) a Datapump database dump.
I am trying to get the dump file's creation date (to compare with the date of a previously loaded dump), using DBMS_DATAPUMP.GET_DUMPFILE_INFO, like in this example.
When running in an anonymous block (like below), it runs fine, outputting the dump file's creation date. However, when this same block is adapted and compiled in a stored procedure, I get the ORA-39087 error (Directory name is invalid).
DECLARE
dumpfile VARCHAR2(256) := 'my_file.dp';
dir VARCHAR2(30) := 'MY_DIR';
info ku$_dumpfile_info;
ft NUMBER;
BEGIN
sys.dbms_datapump.get_dumpfile_info(dumpfile, dir, info, ft);
FOR rec IN (SELECT * FROM TABLE (info) WHERE item_code = 6 ) LOOP
dbms_output.put_line(rec.value);
END LOOP;
END;
The directory exists. The name is valid. When I run
SELECT * FROM datapump_dir_objs;
with the same user, I can see that the user has READ and WRITE privileges on the directory. Oracle version is 11g Release 11.2.0.4.0.
Any light on what I am doing wrong?
Thanks in advance.
oracle plsql directory datapump
oracle plsql directory datapump
asked Nov 20 at 18:35
Fernando Volquind
153
153
3
Does the user have read and write privileges granted directly to them, or via a role? (A quick way to check is to see whether your query still shows the same data after you doset role none
.)
– Alex Poole
Nov 20 at 18:39
Thanks @AlexPoole ! The privilege is granted by a role. I addedAUTHID CURRENT_USER
to the procedure's header and all went fine.
– Fernando Volquind
Nov 21 at 10:45
add a comment |
3
Does the user have read and write privileges granted directly to them, or via a role? (A quick way to check is to see whether your query still shows the same data after you doset role none
.)
– Alex Poole
Nov 20 at 18:39
Thanks @AlexPoole ! The privilege is granted by a role. I addedAUTHID CURRENT_USER
to the procedure's header and all went fine.
– Fernando Volquind
Nov 21 at 10:45
3
3
Does the user have read and write privileges granted directly to them, or via a role? (A quick way to check is to see whether your query still shows the same data after you do
set role none
.)– Alex Poole
Nov 20 at 18:39
Does the user have read and write privileges granted directly to them, or via a role? (A quick way to check is to see whether your query still shows the same data after you do
set role none
.)– Alex Poole
Nov 20 at 18:39
Thanks @AlexPoole ! The privilege is granted by a role. I added
AUTHID CURRENT_USER
to the procedure's header and all went fine.– Fernando Volquind
Nov 21 at 10:45
Thanks @AlexPoole ! The privilege is granted by a role. I added
AUTHID CURRENT_USER
to the procedure's header and all went fine.– Fernando Volquind
Nov 21 at 10:45
add a comment |
1 Answer
1
active
oldest
votes
The problem was that the READ and WRITE privileges on the directory were added via a role. By default, anonymous blocks are executed with the current user's privileges, but stored procedures are not.
I added AUTHID CURRENT_USER
to the procedure's header and managed to access my directory.
Thanks to Alex Poole for the insight.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53399406%2fdbms-datapump-get-dumpfile-info-cant-read-directory-when-compiled-in-stored-pro%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The problem was that the READ and WRITE privileges on the directory were added via a role. By default, anonymous blocks are executed with the current user's privileges, but stored procedures are not.
I added AUTHID CURRENT_USER
to the procedure's header and managed to access my directory.
Thanks to Alex Poole for the insight.
add a comment |
The problem was that the READ and WRITE privileges on the directory were added via a role. By default, anonymous blocks are executed with the current user's privileges, but stored procedures are not.
I added AUTHID CURRENT_USER
to the procedure's header and managed to access my directory.
Thanks to Alex Poole for the insight.
add a comment |
The problem was that the READ and WRITE privileges on the directory were added via a role. By default, anonymous blocks are executed with the current user's privileges, but stored procedures are not.
I added AUTHID CURRENT_USER
to the procedure's header and managed to access my directory.
Thanks to Alex Poole for the insight.
The problem was that the READ and WRITE privileges on the directory were added via a role. By default, anonymous blocks are executed with the current user's privileges, but stored procedures are not.
I added AUTHID CURRENT_USER
to the procedure's header and managed to access my directory.
Thanks to Alex Poole for the insight.
answered Nov 21 at 10:51
Fernando Volquind
153
153
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53399406%2fdbms-datapump-get-dumpfile-info-cant-read-directory-when-compiled-in-stored-pro%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
3
Does the user have read and write privileges granted directly to them, or via a role? (A quick way to check is to see whether your query still shows the same data after you do
set role none
.)– Alex Poole
Nov 20 at 18:39
Thanks @AlexPoole ! The privilege is granted by a role. I added
AUTHID CURRENT_USER
to the procedure's header and all went fine.– Fernando Volquind
Nov 21 at 10:45