Solved

How to completely drop this function from Oracle database

Posted on 2008-10-23
5
640 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.

Join & Write a Comment

Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and theā€¦
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
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.
This video shows how to recover a database from a user managed backup

744 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

16 Experts available now in Live!

Get 1:1 Help Now