How to extract the details of the stored procedures in the database?

Dear all,
How to extract the details of them?
Bst Rgds,
Edward

Hi Wa-Man Edward Chan,
Following is the PLSQL Block Which Will Give Package, Procedure, Function Source
set verify off
undefine which_object;
undefine which_line;
declare
Shows lines with context of:
VIEW
FUNCTION
PROCEDURE
TRIGGER
PACKAGE SPECIFICATION
PACKAGE BODY
The script uses to temporary tables ERROR_TABLE_TEMP and ERROR_CLOB_TEMP created with:
CREATE GLOBAL TEMPORARY TABLE ERROR_TABLE_TEMP(line number, text varchar2(4000));
CREATE GLOBAL TEMPORARY TABLE ERROR_CLOB_TEMP(TEXT CLOB);
v_offset number:= 5; -- Controls how many lines before and after the line in focus are to be shown
v_obj_name varchar2(100);
v_obj_type varchar2(100);
v_obj_type_new varchar2(100);
v_obj_line number;
v_counter number := 0;
v_text varchar2(32767);
v_subtext varchar2(1000);
v_from number;
v_len number;
v_marker varchar2(10);
v_found number;
v_line_from number;
v_line_to number;
v_long_text clob;
procedure ins_line (p_text in varchar2) is
begin
v_counter := v_counter + 1;
insert into error_table_temp(line,text)
values (v_counter,p_text);
end;
begin
delete error_table_temp;
select ltrim(rtrim(upper('&which_object'))), nvl(to_number('&which_line'),0)
into v_obj_name, v_obj_line
from dual;
begin
select decode(object_type,'PACKAGE','PACKAGE BODY',object_type)
into v_obj_type
from user_objects
where object_name = v_obj_name
and nvl(v_obj_line,0) > 0
and rownum = 1;
exception when no_data_found then
ins_line('ERROR: Object/line not found');
return;
end;
ins_line(v_obj_name||' ('||v_obj_type||')');
if v_obj_type in ('PACKAGE BODY','PACKAGE','FUNCTION','PROCEDURE') then
v_obj_type_new := v_obj_type;
ins_line('----------------------- PROGRAM LISTING -------------------------');
for code in (select trim(text) text, lpad(line,4,' ')||' '||decode(line,v_obj_line,'>>>>> ',' ') marker, type
from user_source
where name = v_obj_name
and line between v_obj_line-v_offset and v_obj_line+v_offset
order by decode(type,v_obj_type,1,2),line) loop
if v_obj_type_new != code.type then
ins_line(null);
v_obj_type_new := code.type;
v_counter := -100000; -- In order to show specification before body
ins_line(v_obj_name||' ('||v_obj_type_new||')');
ins_line('----------------------- PROGRAM LISTING -------------------------');
end if;
ins_line(code.marker||code.text);
end loop;
elsif v_obj_type = 'VIEW' then
select text
into v_text
from user_views
where view_name = v_obj_name;
v_line_from := v_obj_line-v_offset;
v_line_to := v_obj_line+v_offset;
v_obj_line := v_obj_line -1;
ins_line('------------------------------- PROGRAM LISTING -------------------------------');
for i in v_line_from..v_line_to loop
begin
if i = v_obj_line then
v_marker := '>>>>> ';
else
v_marker := ' ';
end if;
if i = 0 then
v_from := 0;
v_len := instr(v_text,chr(10));
else
v_from := instr(v_text,chr(10),1,i);
v_len := instr(v_text,chr(10),1,i+1) - v_from;
end if;
v_subtext := substr(v_text,v_from+1,v_len-1);
if v_len > 0 then
ins_line(lpad(to_char(i+1),4,' ')||' '||v_marker||v_subtext);
end if;
exception when others then
null;
end;
end loop;
elsif v_obj_type = 'TRIGGER' then
ins_line('----------------------- PROGRAM LISTING -------------------------');
delete error_clob_temp;
execute immediate 'insert into error_clob_temp (text) '||
'select to_lob(trigger_body) '||
'from user_triggers ' ||
'where trigger_name = '''||v_obj_name||'''';
select text
into v_long_text
from error_clob_temp;
v_obj_line := v_obj_line-1;
v_line_from := v_obj_line-v_offset;
v_line_to := v_obj_line+v_offset;
for i in v_line_from..v_line_to loop
begin
if i = v_obj_line then
v_marker := '>>>>> ';
else
v_marker := ' ';
end if;
if i = 0 then
v_from := 0;
v_len := dbms_lob.instr(v_long_text,chr(10));
else
v_from := dbms_lob.instr(v_long_text,chr(10),1,i);
v_len := dbms_lob.instr(v_long_text,chr(10),1,i+1) - v_from;
end if;
v_subtext := dbms_lob.substr(v_long_text,v_len-1,v_from+1);
if v_len > 0 then
ins_line(lpad(to_char(i+1),4,' ')||' '||v_marker||v_subtext);
end if;
exception when others then
null;
end;
end loop;
end if;
if v_counter = 0 then
ins_line('*********** NO CODE FOUND ***********');
else
ins_line(null);
end if;
exception when others then
ins_line('*********** ERROR: NOT POSSIBLE TO SHOW THE CODE ***********');
ins_line(' FEJL: '||sqlerrm);
end;
set linesize 4000
set heading off
set feedback off
set verify on
select text
from error_table_temp
order by line;
set linesize 80
set heading on
set feedback on
Prashant

Similar Messages

  • How to pass the parameter of a stored procedure to iReport

    Hi... i don't know how to pass the parameter of the stored procedure to the iReport.
    In the Report Query, i tried
    1. sp_storedprocedure ' value'
    2. sp_storedprocedure +''''+$P{parameter}+''''+
    3. sp_storedprocedure +$V+$P{parameter}++$F($F is a variable having a value of ' (a single quote))may you enlighten us please? thank you

    For M$ SQL server I find that it only works when U use the fully qualified name...
    e.g. catalod.dbo.my_procedure_name 'variable'
    My full query in the Report Query window is something like this:
    EXEC arc.dbo.jasper_Invoice 1000
    Note that you may find that selecting from VIEWS / TABLES fails for no apparent reason and iReport will prompt you with the usual very unhelpful (we have what we "pay" for) prompt, stating that "The document is empty".
    To work around this issue, where a statement like "SELECT * FROM arc.dbo.acc_invoices WHERE Invoice_id=1000" does not work, simply create a PROC, something like:
    CREATE PROC jasper_MyProc (@my_rec_id integer) AS
    SELECT * FROM arc.dbo.acc_invoices WHERE Invoice_id= @my_rec_id integer
    ...to wrap your SELECT statement, then call the PROC
    Edited by: Sylinsr on Apr 22, 2008 4:23 PM

  • How to verify the user information pass by the form with a stored procedure?

    Hi,
    I would like to know how to verify user information pass by the form with a stored procedure.
    I want make a portal which accepts to new user registration, but I want verify the new user's informations (like the name don't contain a number etc).
    Thanks for your help
    regards
    jla

    Hi Samson,
    You can use the UI API to do this. You can catch the form_ADD event and then validate the input from the users. You can even block the event from completing (and stop the document from being added) if your code finds some incorrect data using the bubbleEvent functionality.
    I don't have one specific example to show you, but if you look at some of the SDK samples (for example C:\Program Files\SAP\SAP Business One SDK\Samples\COM UI\VB.NET\02.CatchingEvents) to see how to work with events, you can then create your own validation to ensure the users data is valid.
    Regards,
    Niall

  • How to extract all keys (PK, FK) and constraints from the schema?

    hi,
    How to extract all keys (PK, FK) and constraints from the schema?Thanks!

    I have no idea about any tool which only extract the DDL of constraints.
    In oracle 9i or above you can use DBMS_METADATA to extract DDL of a table which also shows contraints defination.
    You can take the tables export without data and use databee tool to extract the DDL.
    www.databee.com

  • How to get a list of values used in the WHERE filter of stored procedures and functions in SQL Server

    How can I get a list of values (one or more) used in the WHERE filter of stored procedures and functions in SQL Server?
    How can get a list of values as shown (highlighted) in the sample stored procedure below?
    ALTER PROC [dbo].[sp_LoanInfo_Data_Extract] AS
    SELECT   [LOAN_ACCT].PROD_DT,
                  [LOAN_ACCT].ACCT_NBR, 
                  [LOAN_NOTE2].OFCR_CD, 
                  [LOAN_NOTE1].CURR_PRIN_BAL_AMT, 
                  [LOAN_NOTE2].BR_NBR,
    INTO #Table1
    FROM
                    dbo.[LOAN_NOTE1],
                    dbo.[LOAN_NOTE2],
                    dbo.[LOAN_ACCT]
    WHERE
                    [LOAN_ACCT].PROD_DT = [LOAN_NOTE1].PROD_DT
                    and
                    [LOAN_ACCT].ACCT_NBR = [LOAN_NOTE1].ACCT_NBR
                    and
                    [LOAN_NOTE1].PROD_DT = [LOAN_NOTE2].PROD_DT
                    and
                    [LOAN_NOTE1].MSTR_ACCT_NBR = [LOAN_NOTE2].MSTR_ACCT_NBR
                    and
                    [LOAN_ACCT].PROD_DT = '2015-03-10'
                    and
                    [LOAN_ACCT].ACCT_STAT_CD IN
    ('A','D')
                    and
                    [LOAN_NOTE2].LOAN_STAT_CD IN
    ('J','Z')
    Lenfinkel

    Hi LenFinkel,
    May I know what is purpose of this requirement, as olaf said,you may parse the T-SQL code (or the execution plan), which is not that easy.
    I have noticed that the condition values in your Stored Procedure(SP) are hard coded and among them there is a date values, I believe some day you may have to alter the SP when the date expires. So why not declare 3 parameters of the SP instead hard coding?
    For multiple values paramter you can use a
    table-valued parameter. Then there's no problem getting the values.
    If you could elaborate your purpose, we may help to find better workaround.
    Eric Zhang
    TechNet Community Support

  • How to extract pick details after pick release with OPM Modules

    Hi, Can someone show me how to extract pick details (for third party warehouse) after pick release released in OPM modules?
    I remembered that I can access interface tables MTL_TXN_REQUEST_HEADER and MTL_TXN_REQUEST_LINES to extract pick detail. But it seems that in OPM modules, it does not use these two tables. Any help are greatly appreciated.
    Calvin

    Hi,
    This problem Could happen when you referesh quality or test system.
    Your delta setup for the related master and transaction data needs to be reinit.
    What happens is when you init. the delta and subsequent delta is all maintained in your source system
    please check Notes 852443,424848,834229
    Hope this helps
    Thanks
    Teja
    Message was edited by:
            Teja badugu

  • How to extract   OHC_C21    detail step required FOR THIS

    how to extract   OHC_C21    detail step required FOR THIS

    Hi Deba,
    Check the following URL
    http://help.sap.com/saphelp_nw70/helpdata/en/ba/a3463c9c9ffc3ae10000000a114084/frameset.htm
    Regards,
    Tom

  • Adding a stored procedure to the master database?

    I have a SQL server instance being used as our data warehousing environment. The instance consists of several databases that I am snapshotting as part of our high availability strategy for data. I've created a stored procedure that takes the source database
    as an argument and that will create a new snapshot when a new one needs to be created and will also automatically remove the old snapshot. It also updates some synonym tables that point to the new snapshot but that might not be an important detail.
    I would like to have the stored procedure stored some place global to all of the databases that I am routinely snapshotting, but that would mean putting it in the master database. Although having it there makes things significantly better in terms of usability,
    it seems like there's something wrong with putting any stored procedures in the master database. Am I wrong? Is it OK to put stored procedures there in situations like this?

    Yes Database snapshot. We're using it to make our data more available so that when we're refreshing the underlying database we can still access the previous version of the data. Otherwise our reports and applications won't have access to the data or will
    get partial data sets. We don't intend to use it for DR or as a backup.
    ok. if it is for temporary purpose, it will work..
    you can create one master procedure and do that - master database. but you need to make sure you point your applications/reports to the snapshot database and not actual database
    Hope it Helps!!

  • Adding a stored Procedure to the Report

    Hi,
    I am developing a report using crystal plugin in eclipse.I have problems in adding a stored procedure to the report .I write the following command in SQL SCRAPBOOK dbo.StoredProcedure @Param1="param1",@Param2="param2",@Param3="None" and run it. It runs successfully ,but when i try to add it to report nothing is being added to it.
    I am using a Sybase database and driver(com.sybase.jdbc3.jdbc.SybXADataSource)
    Any suggestions regarding this would be of great help.
    Thanks in advance
    Siva
    Edited by: Siva_velicheti on Jun 1, 2010 12:10 PM

    Hmm, not sure about stored procedures, but you can get SQL queries to work like below....
    @method to get ResultSet from SQL query with user, pwd, and dbConnectionInfo
    @param query, scrollType, user, password, dbName, db
    @throws SQLException 
    @throws ClassNotFoundException
             private static ResultSet getResultSetQueryDBInfo(String query, int scrollType, String user, String password, String dbName, String db)
             throws SQLException, ClassNotFoundException
                  String DBUSERNAME =  user;
                  final String DBPASSWORD = password;
                  final String CONNECTION_URL = "jdbc:oracle:thin:@" + dbName + ":1521:" + db;
                  Connection connection = DriverManager.getConnection(CONNECTION_URL, DBUSERNAME, DBPASSWORD);
                  DatabaseMetaData meta = connection.getMetaData();
                  System.out.println("getResultSetQueryDBInfo - Connected to URL : " + meta.getURL());
                  System.out.printf("getResultSetQueryDBInfo - as user: %s\n", meta.getUserName() );
                  Statement statement = connection.createStatement(scrollType, ResultSet.CONCUR_READ_ONLY);
                  System.out.println("getResultSetQueryDBInfo method - executing query: \n");
                  return statement.executeQuery(query);

  • Java web service to invoke a stored procedure in the database

    Hi
    Does anybody have a example Java web srevice to invoke a stored procedure in the database
    regards
    Edited by: hrishy on May 20, 2011 12:11 AM

    hrishy wrote:
    Thanks i have modified the title so its easy to comprehendWrite the two parts mentioned above and post if you get problems with your code.
    First write code that calls the stored procedure and test that to make sure that it works.
    Then write a simple webservice and test it out to make sure it works. The integration should be trivial after that.

  • Is it possible to pass TABLE as the output parameter in stored procedure

    Hey Experts,
      Is it possible to pass TABLE as the output parameter in stored procedure.
    eg
    create procedure spGetData
    @tableName as TABLE(intValue INT NOT NUL)
    as 

    You can use OPENQUERY or OPENROWSET, as mentioned above, to make stored procedure results table like. There are
    some limitations with these methods:
    http://technet.microsoft.com/en-us/library/ms188427.aspx
    In OPENQUERY this-sql-server-instance can be used instead of a linked server name. It requires setting data accces server option:
    exec sp_serveroption @server = 'PRODSVR\SQL2012'
    ,@optname = 'DATA ACCESS'
    ,@optvalue = 'TRUE'
    LINK: http://www.sqlusa.com/bestpractices/select-into/
    Kalman Toth Database & OLAP Architect
    SELECT Video Tutorials 4 Hours
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

  • What is the data dictionary that stores the SQL text of stored procedures?

    I am handling both Oracle 8i on IBM AIX 5L and Oracle9i on SUN Soliars 8 /9.
    What is/are the data dictionary tables, or v$ views that store the SQL text of stored procedured and triggers?
    Thank you in advance!

    If the procedures are not wrapped, you can view them in the dba/all/user_source view. Trigger bodies can be seen in dba/all/user_triggers view.
    Message was edited by:
    Daniel Fink

  • Stored procedure ignore the synonym

    I have defined 2 user : usr1 and usr2 and I have 2 table table1 and table2.
    I define one synonym for table1 that for the usr2 is link to table2.
    If I run sqlplus80 connect whit usr1 and I execute 'Select * from table1'
    the query run correctly on table1.
    If I run sqlplus80 connect whit usr2 and I execute 'Select * from table1'
    the query run correctly on table2.
    After I wrote a stored procedure with the same query.
    If I execute the strored procedure from sqlplus80 connect with usr1 It work correclty with table1.
    If I execute the stored procedure from sqlplus80 connect with usr2 It don't work because contine to work with table1, it seem that don't use the synonym.
    Can someone help me ?

    Please repost this question in the appropriate section of the Discussion Forum.
    This forum is for general suggestions and feedback about the OTN site. For technical question about an Oracle product,
    You can also use our new offering called OTN Service Network:
    For Oracle Advice/Minimal Support (fee based) on Reports, Forums,
    SQL*Plus, and PL/SQL, please go to: http://www.oracle.com/start/otnServiceNetwork/intro.html?src=9123 86&Act=6
    For customers with paid support (Metalink) please go to:
    http://www.oracle.com/support/metalink

  • What is the problem with this Stored Procedure

    Hi ,
    What is the problem with this Stored Procedure ?Why is it giving errors ??
    CREATE or replace  PROCEDURE getEmpName
    *(EMP_FIRST OUT VARCHAR2(255))*
    BEGIN
    SELECT ename INTO EMP_FIRST
    FROM Emp
    WHERE EMPNO = 7369;
    END ;
    */*

    You don't specify precision in procedure arguments.
    (EMP_FIRST OUT VARCHAR2(255))should be
    (EMP_FIRST OUT VARCHAR2)Since you asked what's wrong with it, I could add that it needs formatting and the inconsistent use of upper and lower case is not helping readability.

  • How to bind arrays to PL/SQL stored procedure using OCI?

    Hi,
    We are having problems trying to bind arrays to PL/SQL stored procedure using OCI. Here is the situation:
    - We have a stored procedure called "GetVEPFindTasks" with the following interface:
    PROCEDURE GetVEPFindTasks (
    p_ErrorCode OUT NUMBER,
    p_ErrorMsg OUT VARCHAR2,
    p_RowCount OUT NUMBER,
    p_VEPFindTasks OUT t_VEPFindTaskRecordTable,
    p_MaxTask IN NUMBER);
    t_VEPFindTaskRecordTable is a record with the following entries:
    TYPE t_VEPFindTaskRecord IS RECORD (
    RTCID NUMBER,
    TransNum NUMBER,
    TransTimestamp VARCHAR2(20),
    Pathname1 image_data.pathname%TYPE,
    Pathname2 image_data.pathname%TYPE,
    Pathname3 image_data.pathname%TYPE,
    OperatorID operator.id%TYPE);
    - Now, we are trying to call the stored procedure from C++ using OCI (in UNIX). The call that we use are: OCIBindByName and OCIBindArrayOfStruct to bind the parameters to the corresponding buffers. We bind all parameters in the interface by name. Now, we do bind the record's individual item by name (RTCID, TransNum, etc.), and not as a record. I don't know if this is going to work. Then, we use the bind handles of the binded record items (only record items such as RTCID, TransNum, and NOT error_code which is not part of the record) to bind the arrays (using OCIBindArrayOfStruct).
    All of the parameters that are binded as arrays are OUTPUT parameters. The rest are either INPUT or INPUT/OUTPUT parameters. Now, when we try to execute, OCI returns with an error "Invalid number or types of arguments" (or something to that sort... the number was something like ORA-06550). Please help...
    Is there any sample on how to use the OCIBindArrayOfStruct with PL/SQL stored procedures? The sample provided from Oracle is only for a straight SQL statement.
    Thank's for all your help.
    ** Dannil Chan **

    As you said:
    You have to pass in an array for every field and deconstruct/construct the record in the procedure. There is no support for record type or an array of records. Can you give me a example? I'am very urgently need it.
    thanks
    email: [email protected]

  • How to execute multiple queries in one stored procedure.

    Hi,
    I am Kumar,
    How to execute multiple queries in one stored procedure.
    here is the my requirements,
    1. get the max value from one table and sum of the that value.
    2. insert the values and also sum of the max value.
    using stored procedure
    I am using SQL server 2000 database.
    Please help me.
    Advance thanks
    by,
    Kumar

    This is not a java question and it is not even a problem: your only problem is
    1) lack of knowledge
    2) lack of interest to find a manual
    But you are going to have to change both by actually reading a book or a manual that explains the stored procedure language of SQL Server. It is the same as Sybase I think, so you could also look for a manual for that DBMS.

Maybe you are looking for

  • Another halting Thread problem

    Hello, I want to make a benchmark software using Java, and I want to add capability to stop the test if such setting was selected that the test would take forever. I know that I can do this with using such code like: public class MyBenchThread extend

  • Printer will only print from computer won't copy from printer

    My  printer will only print items that i send to it from y email. when i walk out to the printer and try to make copies the pages all come out blank no matter if i use the document feeder or place them on the glass directly. i have turned it off and

  • Will Oracle 8I release 3 Server work with Oracle 9I Client?

    My company wrote some software for DBing imagery tags and such. this was originally done for win2k. They company now needs to upgrade to winXP systems in order to keep there maintenance contracts. long story short can i continue to use the DB 8 serve

  • Boot Camp error x80300024

    Getting an error message when loading Windows onto my MAC of 'Unable to load error x80300024'.  Not too sure what is going on here.  I am installing per the manuel and this isn't the first time I have done this and I have never received this error be

  • Using Adobe Production Studio on Bootcamp

    I am currently a pc user; however, I am very interested in the new Mac Pro. I would like to run my current software which is the Adobe Production Studio Video bundle. It is meant to run on Windows. If I were to switch to the Mac Pro and run bootcamp,