Call the procedure before any operation of DB

Hi all

I currently have an application configured to use a data source JDBC for all its transactions in database. I was wondering if it is possible to call a db procedure every time a new database connection is created for use.

My scenario:

All users are authenticated through an LDAP service and I store the user name and other relevant information on the success.

The DB is a procedure established to a user name for the database user as long as the parameter passed in view (s). This is necessary for all our inherited audit information on all the relevant tables to be filled.

So basically I have to call this procedure before any other transaction of db is called.

I have successfully deployed the dynamic JDBC example in the past, but I was wondering if anyone knew another way with the given scenario.

Any help is appreciated.

Thank you!

Maybe this can help http://blogs.oracle.com/jheadstart/entry/row_level_security_using_vpd_a

Tags: Java

Similar Questions

  • Avoid calling the procedure in the cursor loop

    Hi all

    The following example of procedure the procedure written in cursor loop, is called each time until the end of the cursor loop...
    procedure proc_main is
    DECLARE
     cursor c1 is 
        select e.empno empno
               ,e.ename ename
               ,d.dname dname
               ,d.loc   loc
        from emp e,dept d
        where e.deptno = d.deptno ;
     
    BEGIN
      for i in c1 LOOP
       proc_test(i.empno,i.ename,i.dname,i.loc) ;
       end loop;
    END;
    -----------
    
    PROCEDURE proc_test (p_empno,p_ename,p_dname,p_loc) is
    ---
    ---
    begin
     select * into v1,v2,v3 ..
      from temp_tab
       where col1 =p_empno
        ----
        ----
    
    end;
    What would be the alternative methods to write the procedure above instead to call the procedure inside the cursor for loop
    My idea is to use collections... could you give me the code example using collections to meet the above criteria

    Thank you

    Published by: smile on February 28, 2012 15:45

    The ideal would be to collect all SQL logic and put as much of it in a single SQL statement as possible. It would be also great to determine what is the final outcome of the process and use it as a starting point for your SQL. For example, if the desired result is to upgrade the salaries of the employees where they have an entry in table x, you might find that you can avoid needing to separate the logic between multiple, i.e. instead of procedures

    procedure proc_main is
    DECLARE
     cursor c1 is
        select e.empno empno
               ,e.ename ename
               ,d.dname dname
               ,d.loc   loc
        from emp e,dept d
        where e.deptno = d.deptno ;
    
    BEGIN
      for i in c1 LOOP
       proc_test(i.empno,i.ename,i.dname,i.loc) ;
       end loop;
    END;
    -----------
    
    PROCEDURE proc_test (p_empno,p_ename,p_dname,p_loc) is
    ---
    ---
    begin
     select * into v1,v2,v3 ..
      from temp_tab
       where col1 =p_empno
        ----
        ----
    
        UPDATE
            emp e
        SET
            sal = v2
        WHERE
            e.empno = p_Empno;
    
    end;
    

    You may simply have

    procedure proc_main is
    BEGIN
    
        UPDATE
            emp e
        SET
            sal = ( SELECT
                        t.new_sal
                    FROM
                        temp_tab t
                    WHERE
                        t.empno = e.empno
                   )
        WHERE
            EXISTS
                (   SELECT
                        NULL
                    FROM
                        temp_tab t
                    WHERE
                        t.empno = e.empno
                );
    
    END;
    

    Even if your logic is more complex, you are likely to find that you can merge several of the statements that you could be running in a loop and replace that loop with a join.

    Given the particular structure of what you posted if, instead of calling the procedure in a loop, you can simply move the cursor c1 as a parameter to proc_test that is

    procedure proc_main is
    
        lc_c1   sys_refcursor;
    
    BEGIN
    
        OPEN lc_c1 FOR
        select e.empno empno
               ,e.ename ename
               ,d.dname dname
               ,d.loc   loc
        from emp e,dept d
        where e.deptno = d.deptno ;
    
       proc_test(c1) ;
    
    END;
    -----------
    
    PROCEDURE proc_test (p_Cursor sys_refcursor) is
    
    begin
    
        LOOP
            FETCH ....
    
            ...DO SOMETHING...
    
            EXIT WHEN p_Cursor%NOTFOUND;
    
        END LOOP;
    
        CLOSE p_Cursor;
    END;
    

    But I highly recommend that you consider trying to merge as much of your SQL before considering the approach of cursor.

    HTH

    David

  • ORA-06508, procedure cannot call the procedure of package

    I have a large stored procedure that calls a package (procedure) that manages a number of procedures to determine whether the process can continue or not.  (It checks authorization of the student to enroll in a class).  We have a web process calling the stored procedure, and that works fine.  What does not work, is a call to the package.  Oracle returned ORA-06508: PL? SQL: could not find program unit called.

    I have included instructions for debugging, so I know that it is the specific call to a procedure in the package fails with ORA-06508.  Thinking it's perhaps something in the package, I inserted a debug statement as the first line in the procedure called in the package.    (Debugging instructions call a procedure inserts of rows in a table of debugging with independent validation).

    When I log in the user account with sqlplus and run a test, everything works fine.  But when the web process is running under the same user, the process fails to call the procedure of package and fails with ORA-06508.

    It seems as if the web process runs with the rights of the appellant, or a role is not granted.

    Can someone help me understand what the problem is?

    offered hv, I appreciate your comments.

    We solved the problem: remove the package that couldn't be cited, then re-create.   That's all!

    Apparently, something in the database was tangled upward.   The server recently had problems with disk space, then it might have been related to that.  But we'll never know for sure.

    The stored procedure and packaging (procedures) which he called were owned by the same schema, and there is no mechanism that I can find to prevent one of the other appellant.  But that was the case - Oracle threw the ORA-06508 exception when the stored procedure called the package procedure.

    I replaced the stored procedure and package several times fine-tuning debugging code, but this has not fixed the problem.

    Finally let it drop and then re-create the package, it's which solved the problem.

    Regarding requests to view the code, there is no way that I could reproduce the problem, since the error that occurred was against the permissions and rules which packages run and the procedures of the Oracle.  Thanks for all the tips and suggestions.

  • How to call the procedure on the page of the ofa

    Hi all

    I have a button.when I click this button need to call the procedure and should return the values.i tried with below code.am is error.i am passing two parameters to the procedure.please suggest me where I made a mistake in the code.

    error while calling procedure.PNG

    code in am

    -------------

    public String calprorate (String laseid, String billingid)

    {

    OADBTransaction oadbtransaction = (OADBTransaction) getTransaction ();

    OADBTransactionImpl oadbtransactionimpl = (OADBTransactionImpl) getTransaction ();

    String retValues;

    System.out.println ("number:" + laseid);

    StringBuffer str = new StringBuffer();

    Str.Append ("BEGIN");

    Str.Append (LEASE_PRORATE_PKG ".") LEASE_PRORATE_PROC1 (»);

    Str.Append ("p_lease_id = >: 1");

    Str.Append ("p_billing_id = >: 2");

    Str.Append ("P_PRORATE = >: 3");

    System.out.println ("params");

    Str.Append (»); «) ;

    Str.Append ("END");

    System.out.println ("End");

    OracleCallableStatement oraclecallablestatement =

    (OracleCallableStatement) oadbtransaction.createCallableStatement (str.toString (), 1);

    System.out.println ("Oracle");

    try {}

    oraclecallablestatement.setString(1,laseid);

    oraclecallablestatement.setString(2,billingid);

    oraclecallablestatement.setInt (1, Integer.parseInt (laseid));

    oraclecallablestatement.setInt (2, Integer.parseInt (billingid));

    System.out.println ("param");

    oraclecallablestatement.registerOutParameter (3, Types.VARCHAR);

    System.out.println("3");

    oraclecallablestatement. Execute();

    System.out.println ("exe");

    retValues = oraclecallablestatement.getString (3);

    }

    catch (System.Exception e)

    {

    System.out.println ("delivery");

    throw OAException.wrapperException (e);

    }

    Return retValues;

    System.out.println ("End");

    }

    code co:

    -------------

    If (pageContext.getParameter ("Calc")! = null) {}

    Vo1 OAViewObject = (OAViewObject) am.findViewObject ("AddonBillingVO");

    System.out.println ("VO");

    {if(VO1!=null)}

    CNT int = vo1.getRowCount ();

    System.out.println ("count:" + cnt);

    If (cnt > 0)

    {

    RowSetIterator rs = vo1.createRowSetIterator("empIterator");

    System.out.println ("EMP");

    If (rs! = null)

    {

    While (rs.hasNext ())

    {

    AddonBillingVORowImpl line = rs.next ((AddonBillingVORowImpl));

    System.out.println ("impl");

    If (line! = null)

    {

    String laseid = row.getAttribute("LeaseId").toString ();

    System.out.println (laseid);

    String billingid = row.getAttribute("AddonBillingId").toString ();

    [Serializable] param = {}

    laseid, billingid

    };

    String newupc = (String) am.invokeMethod ("calprorate", param);

    }

    }

    Khalil.

    You can paste your spec procedure here?

    Also see: Oracle tips of Johny: OAF: sample code to call the PL/SQL of OA Framework procedure

  • How to call the procedure type table

    Hi I have the below requirement

    Created in the sub table type

    CREATE or REPLACE the TYPE char_type IS the TABLE OF VARCHAR2 (4000);

    create or replace procedure test_proc_type (p_type char_type) is

    Start

    I'm looping 1.p_type.count

    dbms_output.put_line (p_type (i));

    end loop;

    end;

    How to call the procedure with parameter as a type!

    SQL> create or replace type  char_type as table of varchar2(4000)
      2  /
    
    Type created.
    
    SQL> create or replace procedure test_proc_type (p_type char_type)
      2  is
      3  begin
      4    for i in 1..p_type.count loop
      5      dbms_output.put_line (p_type(i) ) ;
      6    end loop;
      7  end;
      8  /
    
    Procedure created.
    
    SQL> set serveroutput on
    SQL>
    SQL> exec test_proc_type(char_type('A','B','C','D','E'))
    A
    B
    C
    D
    E
    
    PL/SQL procedure successfully completed.
    
    SQL>
    
  • Can we call the procedure inside the function?

    Hello

    Can we call the procedure inside the function?

    Thank you
    Brij

    845712 wrote:

    Can we call the procedure inside the function?

    Strange question to ask.

    Yes. This is the standard behavior in most (if not all) procedural and object oriented languages.

    A procedure, function or a method is a unit of code.

    You can call one of the other units. Units can call themselves (recursion). Technically, this means simply by pushing the battery current (to save the stack of the current device memory), the call to the new unit and then popping up battery when control is returned to the unity of the appellant.

    There are very few exceptions to this. The only one that comes to mind programming languages I've used through the years, is natural 1 - could not call a new unit of code to replace the existing one in memory. If no call-and-return was possible.

    Exactly what did you ask this question? Some newcomers to confused Oracle SQL and PL/SQL - two different languages aside server. And then also mistaken for PL/SQL client command vocabulary of SQL * more.

    You will need to make sure that understand the basics of programming (applies to most current programming languages) and Oracle concepts.

  • Call the procedure to set the context before interactive report refreshes the data

    Hi guys,.

    I have a question mind an interactive report which takes the data in a view.

    The problem is that whenever I take the data from the database I need to define a context (user name and password) before running the query so the view will be taken into account the context and return only the lines that I have access.

    Everything works fine when I'm first loading of the page: I have first to define the context, then load all the data I need on the page, including the IR. But when I try to apply IR filters, or even don't go to the next page no data is returned. I believe this happens because the context is not defined before the execution of the query to load the data and I don't seem to find a way to put it.

    I tried to add a dynamic action on some events on IR (change, clicking, etc.) that executes the procedure to set the context, but without success - even if the event is raised, the report still doesn't return any data.

    Can someone help me with this issue please?

    Florin

    Use the attributes of application security Code PL/SQL of the initialization/cleanup of the database Session to do this: http://docs.oracle.com/cd/E37097_01/doc/doc.42/e35125/bldr_attr.htm#HTMDB28929

  • How to call the procedure Oracle in ODI

    Hello

    I use ODI 10 g.

    Before you run the interface in a package, I wanted to place my procedure.

    I created the procedure in d/b (target)

    CREATE OR REPLACE PROCEDURE TEST_MY_NEW_PROCE
    AS
    BEGIN
    REMOVE FROM EMPLOYEE_TABLE
    WHERE EMPLOPYEE_ID LIKE '% P ';
    COMMIT;
    END;
    /

    The procedure works well in the target database.

    Now, before the execution of my interface, I want to run this procedure in my package. So can some please help me how to call this oracle (creation in target schema) ODI procedure and run it.

    Thank you.

    Hi, GRK,.

    You can create an ODI procedure, add one step, choose Oracle as technology and your target schema.
    Then just call it through a pl/sql block:

    BEGIN
     TEST_MY_NEW_PROCE;
    END;
    

    In your package, then drag this ODI procedure.

    Kind regards
    JeromeFr

  • Call the procedure this file download, but not from the URL

    Hello

    Oracle 11g, Apex 4.1.1.00.23.

    I have a procedure that generates a CSV of a query (BLOB). The query uses the apex collections.
    As it seems impossible to use collections of the apex outside Apex, I can't call this procedure from the URL to download the file (the query fails).

    How can I call my procedure on click of a button, without reloading the page, and without calling the URL ?

    I have some ideas like the creation of a new page, with a conditional header process that calls my procedure to download the file, then call it in a popup, etc... but I need a simple solution...

    Thank you.

    Yann.

    PS: actually, I need the same functionality when you change a process, let us say a process page, in the source attribute, you link < police = "courier" > [Download Source] < / font >, this link simply calls < police = "courier" > javascript:doSubmit('DOWNLOAD') < / font >, but it seems that the page is not reloaded. That's exactly what I need, it does not call for any procedure in the URL, and it does not reload the page.

    Use an application process. These run in the security model for APEX, including the use of the collections.

  • Problems trying to call the procedure in a PL/SQL package.

    We use BI Publisher 10.1.3.4.1.

    I am trying to call a procedure in a package by using a data model, as I read it is the best way to do it.

    Here's the package. Very straightforward, just insertion of a row in a table to try this out. I tested the procedure and that it works correctly.

    -----
    CREATE OR REPLACE PACKAGE JM_PKG_OBIEE_ETL_TEST

    -Declarations of function and public procedure
    PROCEDURE INSERT_TEST_ROW;


    END JM_PKG_OBIEE_ETL_TEST;
    /
    CREATE OR REPLACE PACKAGE BODY JM_PKG_OBIEE_ETL_TEST

    -Function and procedure implementations
    PROCEDURE INSERT_TEST_ROW IS

    NUMBER OF NEXT_ID;

    BEGIN

    SELECT COUNT ()) + 1 IN EDDWMAN NEXT_ID. JM_OBIEE_ETL_TEST;

    INSERT INTO EDDWMAN. JM_OBIEE_ETL_TEST
    (ID, VALUE, DATE_STAMP)
    VALUES
    (NEXT_ID, 'Test' |) NEXT_ID, SYSDATE);

    COMMIT;

    EXCEPTION
    WHILE OTHERS THEN
    RAISE_APPLICATION_ERROR (-20001,
    "An error occurred"; SQLCODE.
    "- ERROR -" | SQLERRM);

    END INSERT_TEST_ROW;

    END JM_PKG_OBIEE_ETL_TEST;
    -----

    Here is the data model that I use. When I run it, I get a syntax error. If I change the "defaultPackage' to"defaultPackage", thus eliminating the appeal of the package, the data model works very well and I get an xml output of what is in the table.

    -----
    < name of dataTemplate = 'test' than one dataSourceRef = 'Oracle BI EE"defaultpackage ="JM_PKG_OBIEE_ETL_TEST">
    < name dataTrigger = source "beforeReport" = "JM_PKG_OBIEE_ETL_TEST. INSERT_TEST_ROW "/ >"
    < dataQuery >
    < SQLStatement instance name = "test_results" >
    <! [CDATA [SELECT ID, saw_2, DATE_STAMP SDS saw_3 VALUE saw_1. JM_OBIEE_ETL_TEST]] >
    < / sqlStatement >
    < / dataQuery >
    < dataStructure >
    < name of group = "G_TEST_RESULTS" source = "test_results" >
    < element name = "test_ID" value = "saw_1" / >
    < element name = "test_value" value = "saw_2" / >
    < element name = "test_DATE_STAMP" value = "saw_3" / >
    < / Group >
    < / dataStructure >
    < / dataTemplate >
    -----

    Any suggestions? Y at - it configuration settings that can be disabling package calls? This package is located in the same schema as the table is in and I can see the data in this table to OBIEE & BI Publisher.

    Thoughts?

    Published by: Jared Moe on June 30, 2011 12:42

    Published by: Jared Moe on June 30, 2011 12:45

    Yes you must change the procedure in function first. In addition, even if you do not use parameters here if passing them in you must also declare their in the package specification in the exact order you have set them up in your data source. Change your name to BeforeReportTrigger function (and note the case-sensitive characters). Here is the code that I modified.












    I hope this helps.

    Steve

    Published by: Steve P on July 1, 2011 14:12

    Published by: Steve P on July 1, 2011 14:14

    Published by: Steve P on July 1, 2011 14:14

  • CALL THE PROCEDURE IN THE SQL STATEMENT

    Why we cannot call a procedure inside the SQL statement?

    Hello

    Usually when you select an item should return you data. In the case of a procedure, you cannot return any return value from the procedure directly it has to be done through some settings and to access these settings, you cannot use a simple sql statement. Where as in a function, you must return one of data that can be easily obtained accordingly.

    see you soon

    VT

  • Cannot configure DBAdapter to call the procedure that takes no parameters

    Hello

    I created a test as a package below:

    create or replace package Tester
    as
    Main1 procedure;
    procedure (x VARCHAR2) Main2;

    end;

    create or replace package body Tester
    as

    procedure Main1
    is
    Start
    insert into ziptest values (' Main', sysdate);
    commit;
    end;

    procedure (x VARCHAR2) Main2
    is
    Start
    insert into ziptest values (' in Main2 :'|| x, sysdate);
    commit;
    end;

    end;
    ----------------------------------------
    When I try to configure a DB adapter to call the Main1 procedure, that I'll meet with the following error:
    An error occurred while getting stored procedures. Verify that the database connection is valid.

    If I try to configure the DB adapter to call Main2, it works without problem.
    In addition, this occurs only when the procedure is in a package. If the procedure is independent, no error is delivered.

    Is this a known bug or am I missing something. I use Jdev 10.1.3.4 and SOA Suite 10.1.3.4.

    Kind regards

    Amit

    Hi Amit,

    This is a bug in the wizard of DBAdapter. Try to update BPEL for the latest available patch, and if this does not work here workaround has been tested to work on 10.1.3.1 too!

    1. modify "Main1' to"Main1 (dummy IN VARCHAR2)"in your package.
    2. use the wizard of DBAdapter as ususal to create a partner link that hits this procedure has changed.
    3. change your procedure "Main1" back to the way it was IE without any parameters.
    4. in your BPEL process file, find the file .xsd to Main1 generated by the wizard in step 2. Replace ... inside the for the "InputParameters" element with an emty tag.

    Now, go ahead and invoke this link partner as usual. It would work! ;)

    Kind regards
    Ravi

  • How to call the procedure in the package

    Hi all!

    The situation!

    I received a package with body priview 'Change_utility '.
    In this package, I had procedure, changing the data when triger calls a package, it is all ok and working

    Now, I need to call a procedure in a single package gave him.

    I need to run the sta_death procedure in the 'Change_utility' package with no code 112233-4455

    How do I run that?


    Thanks for the help!

    ID

    Maybe (guessing)

    begin
    
      change_utility.sta_death('112233-4455');
    
    end;
    

    Concerning

    Etbin

  • How to call the procedure in the process

    Hello

    I have create procedure abc.
    How can I call procedure abc in the process in the processing of the Page.
    I want to call this procedure when I press the "submit" button.

    Thank you

    Hello

    Yes, that is correct

    Kind regards
    Jari

  • error Oracle parse_list could call the procedure

    I get the error message "wrong number or type of arguments to call the"parse_list"procedure in Oracle 'Parse_List' package in Oracle 9i.» The parse_list procedure returns an array of strings and I try to access the table. Can someone tell me what the problem with my call to parse_list below? The code is OK if I remove the call. I have also included my code after the description of the procedure for packaging.

    = MY FUNCTION CALL =.
    create or replace function test_parse_list
    return VARCHAR2

    is
    type ARR_STR is table of the varchar2 (32767) index directory.
    Table ARR_STR.
    char DELIM: = ', ';
    String varchar2 (100): = 'a, b, c, d;

    Start
    Array (1): = null;
    Parse_List.parse_list (String, delim, Array);
    return array (1);
    end;

    = DESCRIPTION OF THE ORACLE PACKAGE PROCEDURE =.
    create or replace package parse_list
    is
    -Table used to analyze the delimited record tank with parse_list
    TYPE ARR_STR IS TABLE OF THE VARCHAR2 (32767) INDEX DIRECTORY.

    -load an array of string with values scanned from a list delimited by the tank
    -given a string or a file to be reviewed, the single-character delimiter (for example, ',')
    -first entry is in element 1
    -Treaty the single area as NULL
    PROCEDURE parse_list)
    P_STR IN VARCHAR2
    p_delim in TANK
    p_arr to ARR_STR);
    -load an array of string with values scanned from a list delimited by the tank
    -given a string or a file to be reviewed, the single-character delimiter (for example, ',')
    -first entry is in element 1
    -Treaty the single area as NULL
    END;
    ========================================

    Hello

    Welcome to the forum!

    The p_arr argument must be the type defined in the package.
    You cannot substitute your own type, even if the name and the definition are identical.

    Try this:

    create or replace function test_parse_list
    return VARCHAR2
    
    is
       array xyz.ARR_STR;
       ...
    

    where xyz is the name of the package. (I see no parse_list in the Oracle supplied packages 9 manual).

Maybe you are looking for