Object dependencies in PL/SQL code

Hi everyone,
Did anyone interest in the topic search for dependencies between objects in the database?
I want to see the PL/SQL code which is an appeal to a particular procedure or function or package and where and how does a table use in any PL/SQL code.
Often do you have a need to get answers to these questions?
I'm developing such tool now and I want to know, if everybody interested to one.

>
It's very simple. I know about PUBLIC_DEPENDENCIES' but I want to know how does an object use, to continue a search in subobjects
>
Sorry but that isn't very simple or clear to me. Can you provide a simple example of what you are talking about?
And are you familiar with PL/SCOPE?
http://docs.oracle.com/cd/B28359_01/appdev.111/b28424/adfns_plscope.htm
>
PL/Scope is a compiler-driven tool that collects data about identifiers in PL/SQL source code at program-unit compilation time and makes it available in static data dictionary views. The collected data includes information about identifier types, usages (declaration, definition, reference, call, assigment) and the location of each usage in the source code.
>
Search this forum for pl/scope and these links discuss using it.
Re: Finding out all procedures , functions in a tree like structure in sequence
Is PL/Scope all about all_identifiers?
Re: find object dependences in the same object
Re: PLSQL design: Common Shared Exception Handling Code

Similar Messages

  • How can I call a COM object from a PL/SQL CODE

    Hi everyone,
    Does anyone know how to call a COM object from a stored procedure in oracle.
    a sample of code
    please help,
    Hilaire

    Are you familiar with external procedures? Basically, you can expose functions exported by a shared library (i.e. a DLL on Windows) to the Oracle database. My assumption is that you'd probably need to write a wrapper DLL around the COM object, since I believe you can only pass fundamental data types back and forth (i.e. no object references). You'd expose the method(s) of that wrapper DLL to the database via external procedures.
    Justin
    Distributed Database Consulting, Inc.
    www.ddbcinc.com/askDDBC

  • Database Object Dependencies - only goes one level deep

    I've run the Database Object Dependencies report and it appears that the report only shows the top level dependencies and not lower level ones. Am I running this report incorrectly or is there something I'm missing.
    For example, it displays the tables and views correctly but does not show any triggers that have been created for a specific table. Additionally, I didn't see any references to database links being used.
    version: 3.1.1.00.09
    thanks
    John
    Edited by: johurj on Dec 8, 2008 2:49 PM
    Edited by: johurj on Dec 8, 2008 2:53 PM
    Edited by: johurj on Dec 8, 2008 2:54 PM

    John,
    The report shows the immediate dependencies for the anonymous blocks and similar code snippets contained within the application components. It's just like if you did this:
    create table footab (n1 number)
    create trigger footrig before insert on footab for each row begin null; end;
    create or replace procedure fooproc
    as
    begin
    for c1 in (select n1 from footab) loop
    null;
    end loop;
    end;
    SQL> select referenced_name from all_dependencies where name='FOOPROC'
    2 /
    REFERENCED_NAME
    SYS_STUB_FOR_PURITY_ANALYSIS
    STANDARD
    FOOTAB
    SQL>
    The table FOOTAB is the only "real" object that the procedure FOOPROC has a dependency on. No mention of the trigger on the table.
    Additionally, I didn't see any references to database links being used.Yes, that would be a possible improvement to the report.
    Scott

  • OpenSQLException - object of type java.sql.Date is not normalized

    Hi,
    I am attempting to code an SQL query in an EJB and get the following exception:
    com.sap.sql.log.OpenSQLException: The object of type java.sql.Date with the value '2010-06-04 13:21:09.424' assigned to host variable 1 is not normalized. It must not contain time components in the time zone running the virtual machine. at com.sap.sql.log.Syslog.createAndLogOpenSQLException(Syslog.java:85) at com.sap.sql.log.Syslog.createAndLogOpenSQLException(Syslog.java:124) at com.sap.sql.jdbc.common.CommonPreparedStatement.setDate(CommonPreparedStatement.java:650) at......
    Below is the code snippet I am using:
                        private static String selWQ  = "Select * from ZZZZ_TABLE " +
                                                                       "where DATEFROM >= ? " +
                                                                  "and DATETO <= ? ";
         public UsageRecord[] getRecords(Date fromDate,Date toDate)
              UsageRecord[] ura = null;
              String q          = null;
              ArrayList al      = new ArrayList();
              try
                   q = selWQ;
                   conn.open();
                   PreparedStatement p = conn.prepareStatement(q);               
                   p.setDate(1, fromDate);
                   p.setDate(2,toDate);                    
                   ResultSet rs = p.executeQuery();
    I have a PreparedStatement and am using setDate to set the values. The fromDate and toDate parameters are of type java.sql.Date
    Can someone please tell me what I am doing wrong and how to fix it?
    thanks
    Brian

    As requested, here is an example of what I used to resolve this:
                   PreparedStatement p = conn.prepareStatement(q);
                   SimpleDateFormat ddf = new SimpleDateFormat("yyyy-MM-dd");
                                               String sFrom = ddf.format(new java.util.Date(fromDate));
                   String sTo   = ddf.format(new java.util.Date(toDate));
                   p.setDate(1, java.sql.Date.valueOf(sFrom));
                   p.setDate(2, java.sql.Date.valueOf(sTo));
                   ResultSet rs = p.executeQuery();
    fromDate and toDate are parameters of type long...
    regards
    Brian

  • How can one  read a Excel File and Upload into Table using Pl/SQL Code.

    How can one read a Excel File and Upload into Table using Pl/SQL Code.
    1. Excel File is on My PC.
    2. And I want to write a Stored Procedure or Package to do that.
    3. DataBase is on Other Server. Client-Server Environment.
    4. I am Using Toad or PlSql developer tool.

    If you would like to create a package/procedure in order to solve this problem consider using the UTL_FILE in built package, here are a few steps to get you going:
    1. Get your DBA to create directory object in oracle using the following command:
    create directory TEST_DIR as ‘directory_path’;
    Note: This directory is on the server.
    2. Grant read,write on directory directory_object_name to username;
    You can find out the directory_object_name value from dba_directories view if you are using the system user account.
    3. Logon as the user as mentioned above.
    Sample code read plain text file code, you can modify this code to suit your need (i.e. read a csv file)
    function getData(p_filename in varchar2,
    p_filepath in varchar2
    ) RETURN VARCHAR2 is
    input_file utl_file.file_type;
    --declare a buffer to read text data
    input_buffer varchar2(4000);
    begin
    --using the UTL_FILE in built package
    input_file := utl_file.fopen(p_filepath, p_filename, 'R');
    utl_file.get_line(input_file, input_buffer);
    --debug
    --dbms_output.put_line(input_buffer);
    utl_file.fclose(input_file);
    --return data
    return input_buffer;
    end;
    Hope this helps.

  • Variant configuration-- syntax error in creation of object dependencies

    In variant configuration when i try to create object dependency (tcode=cu01), after entering the dependency and also description when i enter the syntax in the source code it is giving error: error in syntax check for simple condition
    I have entered syntax as  : engine_cap in ('1000','1400','2000'), pls guide me with the solution to create object dependency

    Dear, Shakeer
    Please follow along with my very own config guide of variant config.
    1)     Create a configurable Material Using KMAT u2013Material Type. Item Category 0002 and Item Category Group 0002. Go to classification tab-here you maintain the class type 300 and assign the class, we will create this shortly. (So after creating class come back into MM02 and input the class that you create in step 2.)
    2)     Create a class in T-Code CL01. Use class type 300 for Variants. In this we assign the characteristics we will create shortly.
    3)     Create characteristics in T-Code CT04. Create your characteristic like for example, Z_Type, Z_Model, and Z_Color.
    4)     We must create a characteristic for the pricing. Example, Z_CarPrice inside this characteristic we must maintain. Table Name SDCOM, Field Name VKOND in the additional data tab. Also, go to restrictions tab and enter the class type 300 Variants. Now in order to make this pricing work for you, you must maintain (enter) all the values from the characteristics. For example, Red, Blue, Black, Honda, Toyota, GLI, XLI, and 2.0D.
    5)     Now going back to the characteristics in CT04 change mode. Make sure Basic Data has *Multiple Selections circled. * Character Format has 26 and a check in case sensitive. Make sure in restrictions tab class type 300 Variants is present. Go back to Values and highlight the first one. Example, Red then go to Extras->Object Dependencies->Assignments You must maintain this code $self.Z_CarPrice=u2019Redu2019 in basic data make sure itu2019s released & procedure is filled in. Go back to dependency editor and paste the same code there after 000010 $self.Z_CarPrice=u2019Redu2019 and do this for each and every value. Very Important * Maintain configuration profile in T-Code CU41 for the material -> Priority 01, Variant Configuration, Class 300, status, Released 1, then click save. Note: If 2 conditions are inactive use class group A instead of B in SPRO for Condition type VA00.
    6)     Go to T-Code VK11 and enter VA00 condition type. Enter all the values maintained in the characteristics for example, Red, Blue, Black, Toyota, Etc and enter the price then click on save. Now it should work fine in VA01. Make sure you have assigned the VA00 condition type in the pricing procedure.
    Good Luck,
    Muhammad Ali Lozada

  • Function modules (and the like) for testing Object Dependencies in PLM

    Hi all,
    I've created an upload program for characteristic values to AUSP, but I need to <b>check the object dependencies</b> (as shown in transaction CU03) before saving the data.
    I have the list of the dependencies for the characteristic in question, but how can I perform a dependency check in program code? Is there any <b>function modules</b> (and the like) which I can use?
    All helpful answers will be rewarded!
    - Mari Virik

    Thanks!
    I'm not that familiar with BAPIs, which transactions can I use to check it out? Transaction BAPI? And how do I locate it in the BAPI Explorer? How do I perform the method call?
    More points will be rewarded
    - Mari

  • Function modules (and the like) for testing Object Dependencies

    Hi all,
    I've created an upload program for characteristic values to AUSP, but I need to <b>check the object dependencies</b> (as shown in transaction CU03) before saving the data.
    I have the list of the dependencies for the characteristic in question, but how can I perform a dependency check in program code? Is there any <b>function modules</b> (and the like) which I can use?
    All helpful answers will be rewarded!
    - Mari Virik

    Hi,
    How did you solve this problem?
    I have the same.
    Thanks.

  • Invalid table name  error when updating object in collection using SQL

    Hi,
    I have pl/sql code where I am selecting a object from a collection using sql select query. I am processing this record and now I want to update the collection with the new object. ie. ensure that the object that was fetched be removed and this new one be added.
    considering my_ot is the object type and my_tt is the table type.
    DECLARE
    my_col my_tt;
    my_col1 my_tt
    my_var my_ot;
    my_var2 VARCHAR2(10);
    BEGIN
    // populating my_col1 with select query
    //populating my_col with select query
    FOR my_col1.FIRST .. my_col.LAST LOOP
    //populating my_var2
    BEGIN
    SELECT my_ot(c.field1, c.field2 ,c.field3) INTO my_var FROM TABLE(my_col) c WHERE c.field3 = my_var2
    //processing the field my_VAR
    UPDATE TABLE(my_col) c SET c.field1 = my_var.field1 , c.field2 = my_var.field2 , WHERE c.field3 = my_var.field3;
    EXCEPTION WHEN NO_DATA_FOUND
    my_col.EXTEND;
    my_col(my_col.LAST) := // new my_ot object
    END;
    END LOOP;
    Here, when compiling the update query is not being compiled. I am getting a error 'invalid table name'. Is there any way to modify an object in the collection without knowing its index?
    If not, is it possible to find the index of a object in the collection in select query?
    Thanks in advance
    Paddy

    Hi,
    Is there any way to find the index of a object in the collection? Then I will simply replace the object at that index, right!
    Thanks
    Paddy

  • BDC selecting component - Assigning object dependencies

    Hi,
    I am facing a problem in developing a BDC program. In transaction CS02, for a configurable material there may be n number of components. The number of components may vary from material to material. My requirement is to assign object dependency Q & S to all the components for a given material.
    Through BDC program how can i pick the components one by one and assign object dependencies Q and S at runtime??? Dynamically on what basis do i have to pick the component? Any supporting code will be more helpfull. Very thankfull to you for solving the issue.
    Thanks,
    RAM

    I have a program which does exactly this.   What it does it excepts a flat comma-delimited file and uses this to chose the component and assign the obj dep.  Now that I'm looking at it, it looks that it will allow up to three obj dep to be added for a single component.  The file layout will need to have......
    material number
    plant
    item number
    component material lnumber
    object dep 1
    object dep 2
    object dep 3
    I can send you the code if you email me at the address on my business card.
    Regards
    Rich Heilman

  • Setting object attribute in dynamic sql

    I am trying to set an object attribute in PL/SQL. It looks like execute immediate is unhappy with
    create type test_object as object(username varchar2(200),id number);
    declare
    obj test_object;
    username varchar2(50);
    begin
    obj := test_object(null,null);
    username := 'MIKE';
    execute immedaite 'begin :x.username := :y; end;' using obj,username;
    end;
    Is this supposed to work?

    Hi Tony,
    Thanks so much for your response. I've had to study up on the dbms_sql package to understand your function... first time I've used it. I've fed my dynamic query to your function and see that it returns a colon delimited list of the column names; however, I think I need a little more schooling on how and where exactly to apply the function to actually set the column names in APEX.
    From my test app, here is the code for my dynamic query. I've got it in a "PL/SQL function body returning sql query" region:
    DECLARE 
      v_query      VARCHAR2(4000);
      v_as         VARCHAR2(4);
      v_range_from NUMBER;
      v_range_to   NUMBER;         
    BEGIN
      v_range_from := :P1_FY_FROM;
      v_range_to   := :P1_FY_TO;
      v_query      := 'SELECT ';
      -- build the dynamic column selections by looping through the fiscal year range.
      -- v_as is meant to specify the column name as (FY10, FY11, etc.), but it's not working.
      FOR i IN v_range_from.. v_range_to  LOOP
        v_as    := 'FY' || SUBSTR(i, 3, 4);
        v_query := v_query || 'MAX(DECODE(FY_NB,' || i || ',PFH_HEADCOUNT,0)) '
          || v_as || ',';
      END LOOP;
      -- add the rest of the query to the dynamic column selection
      v_query := rtrim(v_query,',') || ' FROM ('
        || 'SELECT FY_NB, PFH_HEADCOUNT FROM ('
        || 'SELECT FY_ID, FY_NB FROM FISCAL_YEAR) A '
        || 'LEFT OUTER JOIN ('
        || 'SELECT FY_ID, PFH_HEADCOUNT '
        || 'FROM PROJECT_FY_HEADCOUNT '
        || 'JOIN PROJECT_FY USING (PF_ID) '
        || 'WHERE PL_ID = ' || :P1_PROJECT || ') B '
        || 'ON A.FY_ID = B.FY_ID)';
      RETURN v_query;
    END;I need to invoke GET_QUERY_COLS(v_query) somewhere to get the column names, but I'm not sure where I need to call it and how to actually set the column names after getting the returned colon-delimited list.
    Can you (or anyone else) please help me get a little further? Once again, feel free to login to my host account to see it first hand.
    Thanks again!
    Mark

  • Output of PL/SQL code in Client Machine.

    I am writing the output of PL-SQL code to a file. Later on I will use that output in a UNIX shell script.
    For that I am creating directory object and using the UTL_FILE.fopen and UTL_FILE.put_line functions of UTL_FILE package in Oracle.
    E.G.
    1) CREATE OR REPLACE DIRECTORY MYDIR AS '…………………ANY VALID DIRECTORY PATH IN SERVER……………………………’;
    2)
    DECLARE
    config_file UTL_FILE.file_type;
    lv_i BINARY_INTEGER := 1;
    BEGIN
    lv_i := 2;
    config_file := UTL_FILE.fopen ('MYDIR', 'test.txt', 'W');
    UTL_FILE.put_line (config_file, 'This is test file' || 'lv_i= ' || lv_i);
    UTL_FILE.fclose (config_file);
    END;
    But UTL_FILE.fopen and UTL_FILE.put_line functions in oracle can write only to ORACLE SERVER side files.
    However, I want to write the output of the file to the UNIX box from where I am accessing database (using sqlplus DB_USER_NAME/DB_PASSWORD@DB_NAME).
    Is it possible in Oracle 10g (10.2.0.4.0) to write the output of PL/SQL code in client machine?

    Hi,
    Just an idea. I haven't tried it before in unix server since there's no chance to.
    In Windows you can actually map the specified folder where you want to write the file, so in this case, you just need to find a way on how you can map/mount the folder/directory where you want your file written. UTL_FILE can be used to write files(if the file does not exists) and write text in that file on a directory accross the network as I have done it before in Windows machine.
    Regards.

  • 26.4 Basing an entity Object on a PL/SQL Package API - Ref Cursor, no View

    I am hoping that I could get some help in the details of a problem. I am trying to follow the directions in the Oracle Application Development Framework Developer's Guide for Forms/4GL Developers, Section 26.4 - Basing an Entity Object on a PL/SQL Package API.
    There is example code in the downloadable AdvancedEntityExamples - EntityWrappingPL/SQLPackage
    The question is, how will the implementation change if the entity is based entirely on PL/SQL - simply stated - no view is available, just ref cursors and insert,update,delete procedures.
    In the example code, there are two procedures, lock_product and select_product. This is where things get more complicated. I can create a function to return a single record ref cursor, instead of the list of OUT variables defined in both functions (select_product and lock_product). It makes sense that I just return one cursor and get all of the columns from that instead of lots of OUT variables.
    So what's stopping me you may ask... There is one difference between select_product and select_lock. Select_lock has a select that includes "FOR UPDATE NOWAIT". I don't have that as an option when creating my ref cursor. I am not sure what the impact of "FOR UPDATE NOWAIT" is? Can I ignore it?
    In the problem I am working with, (getting data from Oracle Portal 10.1.4) I return the following:
    function getRefCursor return ref_cursor is
    v_tab wwsbr_all_items_object_type := wwsbr_all_items_object_type();
    p_recordset wwsbr_types.cursor_type;
    l_results wwsrc_api.items_result_array_type;
    begin
    wwctx_api.set_context(<username>,<password>);
    l_results := wwsrc_api.item_search(.. parameters..);
    <snip>
    ... Loop through the objects and populate v_tab
    <snip>
    open p_recordset for
    select * from table(cast(v_tab as wwsbr_all_items_object_type));
    return p_recordset;
    end getRefCursor;
    With this sample, it would be easy to return a single row by passing the masterid as a parameter.
    So I am still left with, how should the implementation of callLockProcedureAndCheckForRowInconsistency() and callSelectProcedure() be changed in order to use a ref cursor instead of a view? The user guide was missing that extra section <bg>.
    What would be REALLY helpful, is an example, say 26.4A that demonstrates creating an entity object from a ref cursor and procedures from PL/SQL only without a view.
    Thank you, Ken

    The lock procedure is expected to obtain a row-level lock on the row, given its key.
    Depending on the setting of jbo.locking.mode, the entity object's lock() method will be invoked either as soon as the first persistent attribute is successfully modified by the user (in the case of jbo.locking.mode=pessimistic), or it will be called during commit processing just before the row is updated in the database (with jbo.locking.mode=optimistic).
    Usually 2-tier Swing applications use pessimistic mode, while web applications use optimistic mode.
    The FOR UPDATE NOWAIT is the Oracle clause that can be appened to a SELECT statement to acquire a row-level lock on the selected rows. The NOWAIT modifier means that rather than hanging, waiting for a row locked by another user to free up, it will raise an exception if any of the rows being selected-and-locked are not available to lock.
    If you're not able to work the FOR UPDATE NOWAIT into the syntax of the ref cursor, perhaps you can initially perform the lock using a different cursor inside the stored procedure, then return your ref cursor.

  • Dbms_session.set_sql_trace(true) in PL/SQL Code to trace execution

    Hi,
    I'm working on some legacy PL/SQL Code with the objective of tuning. I added the following to the PL/SQL Body so that I can trace the execution and identify low-hanging-fruit that can be tuned.
    I added the following after the BEGIN section of the PL/SQL body:
    trace_process_flow_info_sp( this procedure captures the parameters passed into the procedure of the package body);
    execute immediate 'alter session set events '||''''||'10046 trace name context forever, level 12'||'''';
    dbms_session.set_sql_trace(true);
    My objective is to capture the execution of the code, capture the bind variable values, however I am not seeing the bind values in either tkprof or the Trace Analyzer.
    Any Ideas on how to see the Bind Variable Values?
    Thanks

    Level 0 means no binds.Are you sure that this level is available?
    According to note 115675.1 there are only four
    possible levels (1,4,8,12)Hmmm it seems you are right.
    SQL> conn xxx/xxx@xxx
    Connected.
    SQL> ed
    Wrote file afiedt.buf
      1* alter session set events '10046 trace name context forever, level 0'
    SQL> /
    ERROR:
    ORA-02194: event specification syntax error 231 (minor error 283) near '0'
    SQL> ed
    Wrote file afiedt.buf
      1* alter session set events '10046 trace name context forever, level 1'
    SQL> /
    Session altered.
    SQL> The same results for 9.2.0.7.0 and 10.2.0.1.0
    So OK a correction dbms_session.set_sql_trace(true) means level 1, but anyway it means no binds.
    Thank you for your correction, should go and update my article!
    Gints Plivna
    http://www.gplivna.eu

  • Accessing Secured Web Services fromPL/SQL  Code.

    Hi ,
    This is an urgent requirement.We need to call a Web Sercured which is secured(That we need Authenticate using Digital Signatures).I don't how to call a Secured web service from PL/SQL code.with java it is possible.
    Can anyone help me in confoguring/Writing code to call web services with Digital Certificates.
    Regards,
    Ram

    In the XmlDigester class you would have to change the following 2 functions...
    public int Compare(Object x, Object y)
    XmlAttribute lhs = (XmlAttribute)x;
    XmlAttribute rhs = (XmlAttribute)y;
    string ls = lhs.NamespaceURI;
    string rs = rhs.NamespaceURI;
    if ((ls == rs) || (ls.Equals(rs) && ls != null && rs != null))
    ls = lhs.LocalName;
    rs = rhs.LocalName;
    if (ls == null)
    return -1;
    if (rs == null)
    return 1;
    byte[] larr = Encoding.UTF8.GetBytes(ls);
    byte[] rarr = Encoding.UTF8.GetBytes(rs);
    int len = Math.Min(larr.Length, rarr.Length);
    for (int i = 0; i < len; i++)
    int li = (int)(larr[i] & 0xFF);
    int ri = (int)(rarr[i] & 0xFF);
    int d = li - ri;
    if (d != 0)
    return d;
    return larr.Length - rarr.Length;
    private void Serialize(string s, Stream outStream)
    byte[] bytes = Encoding.UTF8.GetBytes(s);
    int len = bytes.Length;
    Serialize((byte)(len >> 8), outStream);
    Serialize((byte)(len), outStream);
    Serialize(bytes, outStream);
    That should do the trick.

Maybe you are looking for