Solved

External Table creation inside PLSQL Package error...

Posted on 2004-08-18
4
975 Views
Last Modified: 2008-01-09
Hi Experts..


I am trying to create an External Table inside PLSQL Package but an error "Insufficient Priviledges" occurs...

DECLARE
issuccess BOOLEAN;
BEGIN

-- Now call the stored program
  my_package.proc_load_file('INCOMING','SA202_PPD_WARRANTY_20041010_09101010.txt',issuccess);

-- Output the results
IF issuccess THEN
  dbms_output.put_line('issuccess = TRUE');
ELSE
  dbms_output.put_line('issuccess = FALSE');
END IF;

EXCEPTION
WHEN OTHERS THEN
  dbms_output.put_line(SubStr('Error '||TO_CHAR(SQLCODE)||': '||SQLERRM, 1, 255));
RAISE;
END;



Here is my Package...

PACKAGE BODY MY_PACKAGE AS
PROCEDURE PROC_LOAD_FILE (
        varFileDirectory        IN VARCHAR2
        , varFile               IN VARCHAR2
        , isSuccess             OUT BOOLEAN)
IS
      varTransposedPhoneNumber    VARCHAR2(30) := '';
    varMobileNumber             VARCHAR2(30) := '';
    varSourceTransactionDate    VARCHAR2(15) := '';
    varTransactionIdentifier    VARCHAR2(30) := '';
   
    varDelimiter                VARCHAR2(1) := ',';
    varSQL                      VARCHAR2(1000);
BEGIN
    BEGIN
        varSQL :=
            'CREATE TABLE PREPAID_WARRANTY_EXT_TBL
            (
                TRANSPOSED_PHONE_NUMBER VARCHAR2(30),
                MOBILE_NUMBER VARCHAR2(30),
                SOURCE_TRANSACTION_DATE VARCHAR2(15),
                TRANSACTION_IDENTIFIER VARCHAR2(30)
            )
            ORGANIZATION EXTERNAL
            (
                TYPE ORACLE_LOADER
                DEFAULT DIRECTORY ' || varFileDirectory || '
                ACCESS PARAMETERS
                (
                    FIELDS TERMINATED BY ' || '''' || varDelimiter || '''' || '
                )
                LOCATION (' || '''' || varFile || '''' || ')
            )';
        --DBMS_OUTPUT.PUT_LINE('varSQL is [' || varSQL || ']');
        EXECUTE IMMEDIATE(varSQL);
        COMMIT;
        DBMS_OUTPUT.PUT_LINE('successfull create table');
    --EXCEPTION
        --WHEN OTHERS THEN
           --DBMS_OUTPUT.PUT_LINE('other exceptions create table');
    END;
END PROC_LOAD_FILE;
END MY_PACKAGE;



however, if I am to create an External Table outside of PLSQL Package, it is successfull...

CREATE TABLE PREPAID_WARRANTY_EXT_TBL
    (
         TRANSPOSED_PHONE_NUMBER    VARCHAR2(30),
         MOBILE_NUMBER              VARCHAR2(30),
         SOURCE_TRANSACTION_DATE    VARCHAR2(15),
         TRANSACTION_IDENTIFIER     VARCHAR2(30)
    )
    ORGANIZATION EXTERNAL
    (
         TYPE ORACLE_LOADER
         DEFAULT DIRECTORY INCOMING
         ACCESS PARAMETERS
         (
            FIELDS TERMINATED BY ','
         )
         LOCATION ('SA202_PPD_WARRANTY_20041010_09101010.txt')
    );



May I ask what do I need to set or configure with regards to priviledges...?


Thanks in advanced experts...   =)
0
Comment
Question by:aris_datuin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 8

Assisted Solution

by:baonguyen1
baonguyen1 earned 25 total points
ID: 11828108
Hi aris_datuin,

If you grant priviledge to user via role you may get "insufficient Priviledges" when executing PLSQL package. What you need to do is grant Create Any Table to that use directly then try again;

SQL>grant create any table to <schema>;

Hope this helps
0
 
LVL 8

Accepted Solution

by:
Pierrick LOUBIER earned 100 total points
ID: 11828148
Add AUTHID CURRENT_USER to your procedure :

PROCEDURE PROC_LOAD_FILE (
        varFileDirectory        IN VARCHAR2
        , varFile               IN VARCHAR2
        , isSuccess             OUT BOOLEAN) AUTHID CURRENT_USER
IS
0
 

Author Comment

by:aris_datuin
ID: 11828250
That was fast...!   And it worked already...

I would just like to ask, what does AUTHID CURRENT_USER is for...?


Thanks again experts...   =)
0
 
LVL 8

Expert Comment

by:Pierrick LOUBIER
ID: 11828319
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to take different types of Oracle backups using RMAN.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question