Collapse all procedures in a package
Is there a way to collapse all of the procedures listed in a package using SQL Developer? I have a package with a couple dozen procedures in it, and i would like to look them all over at a glance without the need to collapse each procedure manually.
Thanks.
If you right click in the code folding margin (far left of code), you will get a menu that allows you to collapse all procedure/declaration bodies or alternatively collapse all statements. Unfortunately, if you have a significant amount of comments outside your procedures and functions, it doesn't look as good as I would want.
theFurryOne
Similar Messages
-
Execute all procedures in a package
Pls tell me how to execute all the functions and procedures in a Package in a single shot or is there any coding for the same
Please help me
Thanks in advanceYou would need to have a procedure or function in the package that ran all of the others. Given a package like:
CREATE PACKAGE p AS
FUNCTION f1 RETURN NUMBER;
FUNCTION f2 RETURN NUMBER;
PROCEDURE p1;
PROCEDURE p2;
PROCEDURE RUN_ALL;
END;
CREATE PACKAGE BODY p AS
FUNCTION f1 RETURN NUMBER IS
BEGIN
RETURN 1;
END; -- f1
FUNCTION f2 RETURN NUMBER IS
BEGIN
RETURN 2;
END; -- f2
PROCEDURE p1 IS
BEGIN
NULL;
END; -- p1
PROCEDURE p2 IS
BEGIN
NULL;
END; -- p2
PROCEDURE RUN_ALL IS
l_f1 NUMBER;
l_f2 NUMBER;
BEGIN
l_f1 := f1();
l_f2 := f2();
p1;
p2;
END; -- run_all
END; -- package bodyThen you would run all the procedures and functions by calling
p.run_all;If you will never wnat to run the other procedures and function individually, then you could define the package spec as:
CREATE PACKAGE p AS
PROCEDURE RUN_ALL;
END;HTH
John -
Package Body in the tree doesn't show all procedures
I am using Sql Developer 1.0.0.14.67 on Win XP Professional,
DB servers Oracle 9i on both Linux Red HAt and Win XP Professional
I have troubles with one of packages - in the tree under Package Body SQL Developer doesn't show all procedures of this package body.
On the right panel all package body source is shown, but in the tree under Package Body it shows names of only procedures up to certain line in the source code - up to line where first Private (not included in Package Spec) procedure code starts.
BUT, there are more Public procedures in package body below this Private procedure - and all of procedures below first private are not included in the tree under Package BodyI find this quite annoying. I cannot use the navigation panel on the left to find the location of all functions and procedures in the package body. The 'missing' procedures are listed under the package spec, and double clicking on them takes me to the spec and not the body.
I'm running v1.2.1.32.13. Is this a know issue and is there a fix planned? -
Copy procedures, functions and packages to files
Can anyone help me, how to put all procedures, functions and packages to files. It is important, that when procedure have name PROCEDURE_CREATE then file have PROCEDURE_CREATE.txt
Is that possible?Hi,
I guess you want following.
Do:
1 DECLARE
2 CURSOR Cur_All IS SELECT DISTINCT NAME
3 FROM ALL_SOURCE
4 WHERE ROWNUM <= 10 ;
5 -- WHERE OWNER LIKE 'KIN%' ;
6 v_Name ALL_SOURCE.NAME%TYPE ;
7 BEGIN
8 OPEN Cur_All ;
9 LOOP
10 FETCH Cur_All INTO v_Name ;
11 EXIT WHEN Cur_All%NOTFOUND;
12 DBMS_OUTPUT.PUT_LINE('SPOOL '||v_Name||'.txt') ;
13 DBMS_OUTPUT.PUT_LINE('SELECT TEXT FROM ALL_SOURCE WHERE NAME ='''||v_Name||''' ORDER BY LINE ;') ;
14 DBMS_OUTPUT.PUT_LINE('SPOOL OFF') ;
15 END LOOP;
16 CLOSE Cur_All;
17* END ;
SQL> /
SPOOL STANDARD.txt
SELECT TEXT FROM ALL_SOURCE WHERE NAME ='STANDARD' ORDER BY LINE ;
SPOOL OFF
PL/SQL procedure successfully completed.
SQL> Do spool of the above anonymous block. And run it as a SQL script. You will get required output.
Regards,
Arpit
Message was edited by:
arpit_shah4u -
Query for getting all function and procedure inside the packages
hi All
Please provide me Query for getting all function and procedure inside the packages
thanksAs Todd said, you can use user_arguments data dictionary or you can join user_objects and user_procedures like below to get the name of the packaged function and procedure names.
If you are looking for the packaged procedures and functions source then use user_source data dictionary
select a.object_name,a.procedure_name from user_procedures a,
user_objects b
where a.object_name is not null
and a.procedure_name is not null
and b.object_type='PACKAGE'
and a.object_name=b.object_name -
Help on ORA-06550 & PLS-00363 Error while running a procedure from a packag
Greeting All,
I ran the following procedure from a package on a command line in sqlplus:
SQL> exec QUALITY_ASSURANCE.COPY_SW_RESOURCES(2009,2010,9508);Where '2009' is the old fiscal year, '2010' is the new fiscal year and '9508' is the error code passed from the calling program. But, I received the following error messages:
ERROR at line 1:
ORA-06550: line 1, column 53:
PLS-00363: expression '9508' cannot be used as an assignment target
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
Any thoughts, suggestions and/or advice to resolve these errors.
Thanks in advance.Orchid wrote:
Justin,
Thanks for your response and information. Yes, Theoa was correct the 3rd parameter is an OUT variable, and it is a numeric field. The procedure was called by a form as follows:
QUALITY_ASSURANCE.COPY_SW_RESOURCES(:BLK_CONTROL.FROMFY,:BLK_CONTROL.TOFY,V_ERR);But the form does not work so I am trying to isolate the problem by running the procedure by itself in sqlplus to make sure there is no problem with the procedure.
Yesterday, I was able to run the procedure in Toad for Oracle to a successful completion by providing the 3 parameters: (2009, 2010, null). Just wonder why I cannot run the same procedure with the same parameters on a command line in sqlplus as follows:
exec QUALITY_ASSURANCE.COPY_SW_RESOURCES(2009,2010,null);So, if I understand your suggestion correctly, in order to run the procedure with the 3 parameter successfully in sqlplus,
I have to declare the 3rd parameter in PL/SQL. That is to create a PL/SQL file as suggested and run the file, correct? CORRECT! -
Need to get the list of all procedures called in an object
Hi,
I am trying to find the list of all proceudres called in an object. I can get the list of packages and individual procedures/functions using dba_dependencies, all_dependencies or user_dependencies. However this would not give me the list of procedures of a package that are used in my object.
How to find the procedures of a package (and not just the package name) being called in another object?
Thanks in advance
UpendraYou can take the package name from user_depencies and query the USER_SOURCE table for the object name where the package name exists.
Eg code, here PKemp is the package name.
SELECT SUBSTR(TEXT,INSTR(TEXT,'PKEMP'))
FROM USER_SOURCE
WHERE NAME = 'PROCEMP'
AND INSTR(TEXT,'PKEMP') >=1
SUBSTR(TEXT,INSTR(TEXT,'PKEMP'))
PKEMP.SALUP; -
How can i find start line of any functions or procedures stored in package body?
hi
how can i find start line of any functions or procedures stored in package body?
is there any way to write a query from for example user_source?
thankshow can i find start line of any functions or procedures stored in package body?
Why? What will you do differently if a procedure starts on line 173 instead of line 254?
Tell us what PROBLEM you are trying to solve so we can help you find the best way to solve it.
If you use PL_SCOPE that info is available in the *_IDENTIFIERS views. See 'Using PL/Scope in the Advanced Dev Doc
http://docs.oracle.com/cd/B28359_01/appdev.111/b28424/adfns_plscope.htm
Try this simple sample code. The query is modified from that doc sample:
-- tell the compiler to collect the info
ALTER SESSION SET PLSCOPE_SETTINGS='IDENTIFIERS:ALL';
-- recompile the package
CREATE OR REPLACE package SCOTT.pack1 as
PROCEDURE proc1;
PROCEDURE proc2;
END;
CREATE OR REPLACE package BODY SCOTT.pack1 as
PROCEDURE proc1 IS
BEGIN
NULL;
END;
PROCEDURE proc2 IS
BEGIN
proc1;
END;
PROCEDURE proc3 IS
BEGIN
proc1;
proc2;
END;
END;
-- query the info for the package spec
WITH v AS (
SELECT Line,
Col,
INITCAP(NAME) Name,
LOWER(TYPE) Type,
LOWER(USAGE) Usage,
USAGE_ID,
USAGE_CONTEXT_ID
FROM USER_IDENTIFIERS
WHERE Object_Name = 'PACK1'
AND Object_Type = 'PACKAGE'
SELECT LINE, RPAD(LPAD(' ', 2*(Level-1)) ||
Name, 20, '.')||' '||
RPAD(Type, 20)||
RPAD(Usage, 20)
IDENTIFIER_USAGE_CONTEXTS
FROM v
START WITH USAGE_CONTEXT_ID = 0
CONNECT BY PRIOR USAGE_ID = USAGE_CONTEXT_ID
ORDER SIBLINGS BY Line, Col
LINE,IDENTIFIER_USAGE_CONTEXTS
1,Pack1............... package declaration
2, Proc1............. procedure declaration
3, Proc2............. procedure declaration
-- query the info for the package body - change 'PACKAGE' to 'PACKAGE BODY' in the query above
LINE,IDENTIFIER_USAGE_CONTEXTS
1,Pack1............... package definition
2, Proc1............. procedure definition
6, Proc2............. procedure definition
8, Proc1........... procedure call
10, Proc3............. procedure declaration
10, Proc3........... procedure definition
12, Proc1......... procedure call
13, Proc2......... procedure call -
Searching strings in procedures, function and packages (OWB)
Hi all,
I'm working on an OMB script to look for a string in procedures, function and packages in OWB. So far, I found how to do it for functions and procedures:
string match -nocase \*text_to_find* [OMBRETRIEVE FUNCTION 'my_function' GET PROPERTIES(IMPLEMENTATION)]
string match -nocase \*text_to_find* [OMBRETRIEVE PROCEDURE 'my_procedure' GET PROPERTIES(IMPLEMENTATION)]
I have tried something similar for packages but it didn't work. Does someone know how to do this search in packages? Any help will be appreciated.
Regards,
MauricioOf course, if you are looking for a match in any source - including procedures and packages not imported into OWB, then OMB+ isn't going to be a ton of help as it won't be aware of those other packages.
In that case, you can always find those dependencies by doing a standard select owner, name, type, text from all_source where text like '%YOUR_SEARCH_CRITERIA%' query.
and you can embed that in your OMB+ using the Java/SQL library: How to run SQL from OMB+
Cheers,
Mike -
How to find Unused variables in procedure,function or package
Hi all,
I want find out unused variables in procedure, function and package.
I have written below script for doing this ,but i am not getting the expected result.
Kindly help me to improve the below code ,so that it works as expected.
{code}
version details
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
PL/SQL Release 11.2.0.3.0 - Production
"CORE 11.2.0.3.0 Production"
TNS for Linux: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production
{code}
{code}
What i Have tried is This.
DECLARE
V_OBJECT_NAME VARCHAR2(30) :='PR_PRINT';
V_OBJECT_TYPE VARCHAR2(30) :='PROCEDURE';
CURSOR C1(CP_OBJECT_NAME VARCHAR2,CP_OBJECT_TYPE VARCHAR2)
IS
SELECT US.NAME,
US.TYPE,
US.LINE,
REGEXP_SUBSTR(US.TEXT,'.* ') AS var_name
FROM user_source US
WHERE name=CP_OBJECT_NAME
AND type =CP_OBJECT_TYPE
AND REGEXP_LIKE (TEXT,'(v_|g_|c_)','i')
AND REGEXP_LIKE (TEXT,'^[^ ]')
AND REGEXP_LIKE (TEXT,'^[^--]') ;
v_count NUMBER ;
BEGIN
FOR i IN C1(V_OBJECT_NAME,V_OBJECT_TYPE)
LOOP
SELECT COUNT( *)
INTO V_COUNT
FROM USER_SOURCE US
WHERE US.NAME=I.NAME
AND REGEXP_LIKE(US.TEXT,i.var_name,'i' )
AND US.LINE<>I.LINE;
IF V_COUNT =0 THEN
DBMS_OUTPUT.PUT_LINE('variable '||I.VAR_NAME||'Is declared at line#'||I.LINE||' But no where used');
END IF ;
END LOOP;
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('p_err_code := '||SQLCODE||dbms_utility.format_Error_backtrace());
DBMS_OUTPUT.PUT_LINE('p_err_msg := '||sqlerrm);
END ;
{code}
Thanks,
P PrakashHello,
as suggested by padders you can use PL/Scope, an example:
ALTER SESSION SET PLSCOPE_SETTINGS='IDENTIFIERS:ALL';
CREATE OR REPLACE PACKAGE ui_test1 AS
global_number NUMBER := 9;
FUNCTION get_number
RETURN NUMBER;
END ui_test1;
CREATE OR REPLACE PACKAGE BODY ui_test1 AS
PROCEDURE setNull
p_varchar IN OUT VARCHAR2
IS
BEGIN
p_varchar := NVL(p_varchar,'NULL');
END setNull;
FUNCTION get_number
RETURN NUMBER
IS
FUNCTION setZero
p_number IN NUMBER
RETURN NUMBER
IS
BEGIN
RETURN NVL(p_number,0);
END setZero;
BEGIN
RETURN global_number;
END get_number;
END ui_test1;
SELECT DISTINCT
object_name
,object_type
,name
,type
,line
,col
FROM all_identifiers obj
WHERE obj.owner = USER
AND obj.usage = 'DECLARATION'
AND obj.object_name = 'UI_TEST1'
AND NOT EXISTS (
SELECT 1
FROM all_identifiers with_rh
WHERE obj.signature = with_rh.signature
AND with_rh.usage IN ('REFERENCE','CALL','ASSIGNMENT')
ORDER BY TYPE
,object_name
,object_type
,name;
OBJECT_NAME OBJECT_TYPE NAME TYPE LINE COL
UI_TEST1 PACKAGE GET_NUMBER FUNCTION 11 10
UI_TEST1 PACKAGE BODY SETZERO FUNCTION 35 14
UI_TEST1 PACKAGE UI_TEST1 PACKAGE 1 9
UI_TEST1 PACKAGE BODY SETNULL PROCEDURE 12 11
Regards
Marcus -
Exp/imp procedures, functions and packages question
Hi
I've a 9i R2 version Oracle database. I would like to export procedures, functions and packages from a schema. How do I do that?
Is there any script or command lines can provide?
ThanksHello user12259190.
You can do an export of the user itself, excluding table data as inH:\>exp
Export: Release 10.2.0.1.0 - Production on Tue Dec 22 11:22:52 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Username: db_user@db_sid
Password:
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, Data Mining and Real Application Testing options
Enter array fetch buffer size: 4096 >
Export file: EXPDAT.DMP >
(2)U(sers), or (3)T(ables): (2)U > 2
Export grants (yes/no): yes > no
Export table data (yes/no): yes > no
Compress extents (yes/no): yes > no
Export done in WE8MSWIN1252 character set and AL16UTF16 NCHAR character set
server uses UTF8 character set (possible charset conversion)
Note: table data (rows) will not be exported
Note: grants on tables/views/sequences/roles will not be exported
. exporting pre-schema procedural objects and actions
. exporting foreign function library names for user DB_USER
. exporting PUBLIC type synonyms
. exporting private type synonyms
. exporting object type definitions for user DB_USER
About to export DB_USER's objects ...
. exporting database links
. exporting sequence numbers
. exporting cluster definitions
. about to export DB_USER's tables via Conventional Path ...
. . exporting table TABLE_NAMEs
EXP-00091: Exporting questionable statistics.
. exporting synonyms
. exporting views
. exporting stored procedures
. exporting operators
. exporting referential integrity constraints
. exporting triggers
. exporting indextypes
. exporting bitmap, functional and extensible indexes
. exporting posttables actions
. exporting materialized views
. exporting snapshot logs
. exporting job queues
. exporting refresh groups and children
. exporting dimensions
. exporting post-schema procedural objects and actions
. exporting statistics
Export terminated successfully with warnings.Unfortunately, you can't export just the objects you want to unless they are tables.
Using import (imp) you can list the content of your packages, procedures, functions, views, etc. and perhaps that will give you what you need.
Another choice would be to useSELECT * FROM user_source ORDER BY 2, 1, 3;to list the code.
Hope this helps,
Luke -
How to query DDL locks on stored procedures/functions and packages?
Hi!
The subject says it all: How do I see existing DDL locks on stored procedures/functions and packages?
While a procedure is executed it can't be deleted or replaced, so there has to be a DDL lock on it. The information does not seem to be in V$LOCK or V$LOCKED_OBJECTS.
Thanks!
Marcus
Edited by: MMarcus on Nov 21, 2009 3:43 PMHello,
Here you can find an article about the view DBA_DDL_LOCKS:
[http://www.praetoriate.com/int_40.htm]
If you don't have this view on the Data Dictionary, you may have
to execute the "OH/rdbms/admin/catblock.sql" script first.
Hope it can help.
Best regards,
Jean-Valentin -
Schedule a procedure in a package?
I have a developer who would like to schedule a procedure that is part of a package to run on a nightly basis. I wasn't able to select the packaged procedure in EM (10.2). Can you schedule a packaged procedure, but just not with EM?
Yes you can do it with dbms_scheduler but I am not sure if the EM interface supports it.
You can try something like
begin
dbms_scheduler.set_attribute('my_job','job_action',
'scott.test_pkg.proc1');
end;
EM might let you fill in the procedure name manually, in which case you just have to fill in all three parts (schema.package.procedure).
Hope this helps,
Ravi. -
Invoking a procedure in the package
Hi All,
I am planning to invoke three procedures into one package...
the main problem is the procedures are like procedures with in the procedures
so while iam invoking do i need to specify the main procedure (or) all the procedures in the package specification?
oracle version: 10gAre you saying that you have a stucture like this?
PROCEDURE p (p_var IN NUMBER) IS
< variable declarations >
PROCEDURE inside_p (p_var2 IN NUMBER) IS
< inside_p variables >
BEGIN
< inside_p body >
END inside_p;
BEGIN
< do_stuff >
inside_p(42);
< do more stuff >
END p;If so, then you only need to declare p in your package spec, in fact you cannot declate inside_p in your spec since it is only "known" within the scope of p. That is, you cannot even call it from another procedure in the package, let alone form outside.
However, if you have a structure more like:
PROCEDURE inside_p (p_var2 IN NUMBER) IS
< inside_p variables >
BEGIN
< inside_p body >
END inside_p;
PROCEDURE p (p_var IN NUMBER) IS
< variable declarations >
BEGIN
< do_stuff >
inside_p(42);
< do more stuff >
END p;Then you can declare inside_p in the package spec, but do not neccessarily have to. If you want to be able to call inside_p on it's own form outside the package then it needs to be in the package spec. If you just want it to be available to procedures within the package then you do not need to declare it in the space.
John -
Procedures inside Oracle Packages
Hello All,
Can I execute an procedure defined inside an Oracle package using jdbc?
Are the procedures defined inside Oracle packages are same as stored procedures ?
Any help would be grately appreciated.
regards,
Abhishek.Yes you can execute a procedure defined inside an Oracle package. Use the prepareCall method eg
String param1 = 'some value';
oracleCStmt = oracleConn.prepareCall("begin package_name.proc_name(?); end;");
oracleCStmt.setString(1,param1);
oracleCStmt.executeUpdate();Yes a stored procedure in a package is no different to on inside a package. A package is just a collection of PL/SQL objects.
Richard
Maybe you are looking for
-
How get all released production orders
Hi experts, I need to get all released Production Orders for a specific plant. I noticed that usually you don´t select directly from table AUFK. Most of people use function module WCFS_STTXT_GET to get the status of an order. I know that table AUFK h
-
How to create a record for table PLAF with order type 'NB'.
How to create a record for table PLAF with order type 'NB'(standard purchase order). who can tell me the T-code or some usefull information? Thanks.
-
Hi all please help me or my company is gonna fire me :'(
i use mightycall, and fiverr cheap and perfect.
-
Friends, Is it possible to add titles, captions, etc. to images downloaded to the iPad through LR mobile? If so, how do I do it, and will these titles sync to the desktop? I looked in the manual and couldn't find it, or I missed it. Thanks! Steve
-
10.6.5 update went well except....
now my second monitor is darker? I tried several setting and re calibrated, but it is just darker than it was before and i cannot get it back to what it was??? I think i read the issue from someone else, but that was hours ago and probably 100 clicks