Solved

External Table creation inside PLSQL Package error...

Posted on 2004-08-18
4
973 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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Oracle SQL Select unique values from two columns 4 79
Help on model clause 5 47
add more rows to hierarchy 3 33
Checking for column width 8 39
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

756 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