Solved

How to completely drop this function from Oracle database

Posted on 2008-10-23
5
641 Views
Last Modified: 2013-12-19
I have used the following code to create a function, however, it contains many sub functions, etc. How can I completely drop all the stuff that it created? Thanks! I got this code from the web.
CREATE OR REPLACE TYPE t_string_agg AS OBJECT

(

  g_string  VARCHAR2(32767),
 

  STATIC FUNCTION ODCIAggregateInitialize(sctx  IN OUT  t_string_agg)

    RETURN NUMBER,
 

  MEMBER FUNCTION ODCIAggregateIterate(self   IN OUT  t_string_agg,

                                       value  IN      VARCHAR2 )

     RETURN NUMBER,
 

  MEMBER FUNCTION ODCIAggregateTerminate(self         IN   t_string_agg,

                                         returnValue  OUT  VARCHAR2,

                                         flags        IN   NUMBER)

    RETURN NUMBER,
 

  MEMBER FUNCTION ODCIAggregateMerge(self  IN OUT  t_string_agg,

                                     ctx2  IN      t_string_agg)

    RETURN NUMBER

);

/

SHOW ERRORS
 
 

CREATE OR REPLACE TYPE BODY t_string_agg IS

  STATIC FUNCTION ODCIAggregateInitialize(sctx  IN OUT  t_string_agg)

    RETURN NUMBER IS

  BEGIN

    sctx := t_string_agg(NULL);

    RETURN ODCIConst.Success;

  END;
 

  MEMBER FUNCTION ODCIAggregateIterate(self   IN OUT  t_string_agg,

                                       value  IN      VARCHAR2 )

    RETURN NUMBER IS

  BEGIN

    SELF.g_string := self.g_string || ',' || value;

    RETURN ODCIConst.Success;

  END;
 

  MEMBER FUNCTION ODCIAggregateTerminate(self         IN   t_string_agg,

                                         returnValue  OUT  VARCHAR2,

                                         flags        IN   NUMBER)

    RETURN NUMBER IS

  BEGIN

    returnValue := RTRIM(LTRIM(SELF.g_string, ','), ',');

    RETURN ODCIConst.Success;

  END;
 

  MEMBER FUNCTION ODCIAggregateMerge(self  IN OUT  t_string_agg,

                                     ctx2  IN      t_string_agg)

    RETURN NUMBER IS

  BEGIN

    SELF.g_string := SELF.g_string || ',' || ctx2.g_string;

    RETURN ODCIConst.Success;

  END;

END;

/

SHOW ERRORS
 
 

CREATE OR REPLACE FUNCTION string_agg (p_input VARCHAR2)

RETURN VARCHAR2

PARALLEL_ENABLE AGGREGATE USING t_string_agg;

/

SHOW ERRORS

Open in new window

0
Comment
Question by:mawingho
  • 2
  • 2
5 Comments
 
LVL 9

Accepted Solution

by:
MarkusId earned 400 total points
ID: 22793941
Just the way you created it:

drop function string_agg;
drop type body  t_string_agg;
drop type t_string_agg;
0
 

Author Comment

by:mawingho
ID: 22793986
becuase it contains MEMBER FUNCTION ODCIAggregateMerge, I don't know how to drop it...
0
 
LVL 9

Assisted Solution

by:MarkusId
MarkusId earned 400 total points
ID: 22794158
The MEMBER FUNCTIONs are part of the 't_string_agg'-type-body, so dropping this type body should also drop the included member functions (the last 'END' before the second 'SHOW ERRORS' belongs to the 'CREATE OR REPLACE TYPE BODY t_string_agg IS'.

It's like a package where you can have several procedures/functions, dropping the package also drops the included procedures/functions.
0
 

Author Comment

by:mawingho
ID: 22794350
Thanks for your explanation!
0
 
LVL 34

Assisted Solution

by:johnsone
johnsone earned 100 total points
ID: 22796682
Technically speaking, the drop type body is not necessary.  Dropping the type will drop the body, just like with a package.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

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…
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
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.
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…

920 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now