[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Execute a DBMS package from within another package????

Posted on 2006-05-15
4
Medium Priority
?
1,638 Views
Last Modified: 2009-07-29
I would like to create a package with one procedure that refreshes a materialized view.  Here is the code......what am I doing wrong here?

SQL> CREATE OR REPLACE  PACKAGE TNET.REFRESH AS
  2   PROCEDURE TRANS_NETWORK_REFRESH;
  3  END REFRESH;
  4  /

Package created.

SQL> CREATE OR REPLACE PACKAGE BODY TNET.REFRESH AS
  2  PROCEDURE TRANS_NETWORK_REFRESH
  3  IS
  4   BEGIN
  5  EXECUTE IMMEDIATE 'dbms_refresh.refresh('TRANS_NETWORK_MV')';
  6  END TRANS_NETWORK_REFRESH;
  7  /

Warning: Package Body created with compilation errors.
0
Comment
Question by:tdavis30
  • 2
4 Comments
 
LVL 11

Expert Comment

by:f_o_o_k_y
ID: 16688832
Hello

SQL> CREATE OR REPLACE PACKAGE BODY TNET.REFRESH AS
  2  PROCEDURE TRANS_NETWORK_REFRESH
  3  IS
  4   BEGIN
  5  EXECUTE IMMEDIATE dbms_refresh.refresh('TRANS_NETWORK_MV');
  6  END TRANS_NETWORK_REFRESH;
  7  /

or use escape character. Because after 'dbms_refresh.refresh('
TRANS_NETWORK_MV  is no longer considered as character string.

Best Regards
0
 
LVL 3

Expert Comment

by:JacekMycha
ID: 16690290
EXECUTE IMMEDIATE 'dbms_refresh.refresh(''TRANS_NETWORK_MV'')';

You have to use two single quotes (not double quote) inside the string.

You can use
sql> SHOW ERRORS
in SQL*Plus to get more information on compilation errors.

Regards,
JacekMycha



0
 

Author Comment

by:tdavis30
ID: 16690952
These answers did not help.  I think that I am not supposed to use EXECUTE IMMEDIATE when trying to execute a package from within pl/sql but I don't know enough.  This is the error I am recieving:

SQL> CREATE OR REPLACE  PACKAGE TNET.REFRESH AS
  2   PROCEDURE TRANS_NETWORK_REFRESH;
  3  END REFRESH;
  4  /

Package created.

SQL> CREATE OR REPLACE PACKAGE BODY TNET.REFRESH AS
  2  PROCEDURE TRANS_NETWORK_REFRESH
  3  IS
  4   BEGIN
  5    dbms_refresh.refresh('TRANS_NETWORK_MV');
  6  END TRANS_NETWORK_REFRESH;
  7  /

Warning: Package Body created with compilation errors.

SQL> SHOW ERRORS
Errors for PACKAGE BODY TNET.REFRESH:

LINE/COL ERROR
-------- -----------------------------------------------------------------
6/26     PLS-00103: Encountered the symbol "end-of-file" when expecting
         one of the following:
         begin end function package pragma procedure form

SQL>

0
 
LVL 11

Accepted Solution

by:
f_o_o_k_y earned 2000 total points
ID: 16691283
Try this:

CREATE OR REPLACE  PACKAGE TNET.REFRESH AS
PROCEDURE TRANS_NETWORK_REFRESH;
END REFRESH;
/

CREATE OR REPLACE PACKAGE BODY REFRESH AS
PROCEDURE TRANS_NETWORK_REFRESH
IS
BEGIN
execute immediate dbms_refresh.refresh('TRANS_NETWORK_MV');
END TRANS_NETWORK_REFRESH;
END;
/

Best Regards
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

In this article, I’ll look at how you can use a backup to start a secondary instance for MongoDB.
MSSQL DB-maintenance also needs implementation of multiple activities. However, unprecedented errors can hamper the database management. In that case, deploying Stellar SQL Database Toolkit ensures fast and accurate database and backup repair as wel…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

834 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