Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SqlPlus query issue (Package Spec and Body)

I am trying to get package spec and body from sqlplus by doing so..

select text from all_source
where name = 'PACK_JACK'
order by line;

but I am only getting its body not the spec.. what I have to change to get both of them as one file.. Thank you

like image 566
Jack Avatar asked Aug 08 '11 18:08

Jack


People also ask

How can I get package body?

select text from all_source where name = 'PADCAMPAIGN' and type = 'PACKAGE BODY' order by line; Oracle doesn't store the source for a sub-program separately, so you need to look through the package source for it. If you're selecting from ALL_SOURCE you should include the OWNER in the WHERE clause.

How do I open a SQL Plus package?

select text from all_source where name = 'PACK_JACK' and type = 'PACKAGE BODY' order by line; Additionally, instead of using all_source, you can use user_source. all_source includes everything including system packages. USER_SOURCE only has user defined packages.

How do you compile both package specification and body?

Use the ALTER PACKAGE statement to explicitly recompile a package specification, body, or both. Explicit recompilation eliminates the need for implicit run-time recompilation and prevents associated run-time compilation errors and performance overhead.

How do I view the contents of a package in Oracle?

You can find the package body in all_source view. SELECT * FROM all_source WHERE TYPE = 'PACKAGE BODY' AND name = '<your package name>' ORDER BY line; I think you are probably trying to search using function name and not able to find it.

How do I create a package body in SQL*Plus?

If you use SQL*Plus for compiling and creating a package body, you type forward slash (/) as follows: If you manage package body using files, you can compile the package body using the following command: In SQL Developer, you click the Run Script button to create a package body from a file.

What is a PL/SQL package?

A PL/SQL package consists of two parts: package specification and package body. If the package specification has cursors or subprograms, then the package body is mandatory. Otherwise, it is optional.

How to get the spec of package in all_source view?

There is a TYPE column in all_source view. The type can have 2 values - 'PACKAGE' and 'PACKAGE BODY'. So to get the spec, Additionally, instead of using all_source, you can use user_source. all_source includes everything including system packages.

How to get the package body of a specific type?

The type can have 2 values - 'PACKAGE' and 'PACKAGE BODY'. So to get the spec, Additionally, instead of using all_source, you can use user_source. all_source includes everything including system packages. USER_SOURCE only has user defined packages. Show activity on this post. But chances are you don't have the right to see the package body.


1 Answers

There is a TYPE column in all_source view. The type can have 2 values - 'PACKAGE' and 'PACKAGE BODY'. So to get the spec,

select text from all_source
where name = 'PACK_JACK'
and type = 'PACKAGE'
order by line;

and to get the body

select text from all_source
where name = 'PACK_JACK'
and type = 'PACKAGE BODY'
order by line;

Additionally, instead of using all_source, you can use user_source. all_source includes everything including system packages. USER_SOURCE only has user defined packages.

like image 69
Basanth Roy Avatar answered Oct 11 '22 23:10

Basanth Roy