How to call a package in a trigger

I have package that is called via a "Submit" in a from used to enter daily production. We are implementing a barcoding system that will automatically populate the tables behind this form (one header and one line level table). I need to write a trigger or something that fires up the code behind the 'Submit' process whenever these tables are updated.
Is there a way to do this by calling the package in a trigger?
Please help.
Thanks
Edited by: asgar_amin on Feb 3, 2009 10:50 AM

I'm not quite sure what your requirement is.
Do you want to know which forms-trigger you can use to call your submit-package, or do you want to know how to call the submit-package from a database-trigger?
If the second one, it depends on what parameters your package-procedur/function gets as IN-parameters. Is it the ID of the header-record, the detail-record or no parameter at all.
Depending on that you could either use a AFTER-STATEMENT-trigger on either Header or lines-tables, or if you have to gather the ids a combination of a BEFORE-STATEMENT, an AFTER-INSERT FOR EACH ROW and an AFTER-STATEMENT-trigger.
To go more into detail, please provide some more information.

Similar Messages

  • How to call a package from the Report in Oracle Application Express

    How to call a package from the Report in Oracle Application Express

    Hello,
    What do you mean? Something like SELECT mypackage.function( par1, par2) from dual?
    Or do you want to execute a procedure when something happens on the page, like clicking a button?
    Greetings,
    Roel
    http://roelhartman.blogspot.com/
    You can reward this reply by marking it as either Helpful or Correct ;-)

  • How to call a package with ADO?

    I have designed a package which include a procedure. And I have a program coded in ASP.
    How to call this package with ADO. Please give a sample.

    Hi,
    I persume that you are facing this problem when u try to code in VB. If that is the case here comes the code.........
    OraDatabase.Parameters.Add "A_NBR_NEWSID", A_NBR_NEWSID, ORAPARM_INPUT, 2
    OraDatabase.Parameters.Add "A_NBR_TOPICID", A_NBR_TOPICID, ORAPARM_INPUT, 2
    OraDatabase.Parameters.Add "A_NBR_USERID", A_NBR_USERID, ORAPARM_INPUT, 2
    OraDatabase.Parameters.Add "result", 0, ORAPARM_OUTPUT
    OraDatabase.Parameters("result").serverType = 2
    OraDatabase.ExecuteSQL ("declare result Number; Begin :result := PKG_CONTENT_MANAGEMENT.FUN_GET_NEWS_PERM_BY_USERID(:A_NBR_NEWSID, :A_NBR_TOPICID, :A_NBR_USERID); end;")
    OraDatabase.Parameters.Remove "A_NBR_NEWSID"
    OraDatabase.Parameters.Remove "A_NBR_TOPICID"
    OraDatabase.Parameters.Remove "A_NBR_USERID"
    FUN_GET_NEWS_PERM_BY_USERID = OraDatabase.Parameters("result").Value
    OraDatabase.Parameters.Remove "result"
    Hope this clear your doubt..
    Raj

  • How to call a package from a different instance?

    Dear all:
    how to call a package from a different instance?
    for example:
    package A belongs to instance A1
    package B belongs to instance B1
    Now I want to call the package B in instance A1, how can I do ? my environment is oracle 10g
    Regards
    Terry

    Terry Chen wrote:
    Dear all:
    how to call a package from a different instance?
    for example:
    package A belongs to instance A1
    package B belongs to instance B1
    Now I want to call the package B in instance A1, how can I do ? my environment is oracle 10g
    First you have to create create dblink in A1 database as below
    CREATE DATABASE LINK INSA1
       CONNECT TO USER_NAME IDENTIFIED BY <pass>
       USING 'B!' Then you can execute exec pack_b@INSA1;

  • How to call a package in Oracle

    I'm trying to call a package in oracle
    (this is the oracle way of calling it :
    begin pck$xl.get_year_low_high_to_date(:compid, 20010801 , 20020108 ",:year_low,:year_high,:year_average,:low_date,:high_date); end;)
    but i can't get it right.
    I'm new to package calling in Oracle from Java, till now i only worked with SQL statements without parameters of that kind, can someone help me with this?
    ps the ":compid" is a parameter i have to fill in and provide...
    thank you very much

    ok here is a test i do...
    but still doesn't work something about the bindvariables (check errorlog). I know a bit jdbc and i understant what you mean, but the problem is i don't know how this should go :(
    please advise
    import java.sql.*;
    import java.util.*;
    import java.text.*;
    import java.io.*;
    * @author  U97488
    public class test {
        public static void main(String[] args) {
            try{
                ConnectionSherpa cs = ConnectionSherpa.getInstance("ConnectionSherpa");
                Connection conn = cs.getConnObj();
                String sSQL = "begin?; pck$xl.get_year_low_high_to_date(?, 20010801, 20020801 ,:year_low,:year_high,:year_average,:low_date,:high_date); end;";
                CallableStatement stmt = conn.prepareCall(sSQL);
                stmt.setString(1, "BRU10");
                System.out.println(stmt.toString());
                if(stmt.execute(sSQL)){
                    System.out.println(stmt.getString(2));
            }catch (Exception e){
                e.printStackTrace();
    }StackTrace:
    java.sql.SQLException: ORA-06550: Regel 1, kolom 6:
    PLS-00110: Bindvariabele '1' is niet toegestaan in deze context..
            at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:180)
            at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:208)
            at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:543)
            at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1451)
            at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:862)
            at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:1839)
            at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1764)
            at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2354)
            at oracle.jdbc.driver.OracleStatement.execute(OracleStatement.java:909)
            at com.kbcsecurities.taminoupdate.servlets.test.main(test.java:28)

  • How to call a function from a trigger in a forms

    Hi,
    I have a conversion function already stored in Program Units.
    Now, how do I call it from a field trigger ?
    Thanks very much.
    Thuy
    null

    Thuy (guest) wrote:
    : Hi,
    : I have a conversion function already stored in Program Units.
    : Now, how do I call it from a field trigger ?
    : Thanks very much.
    : Thuy
    assume the conversio function is f .
    Therefore f(x) will return a value into a variable hence
    IN THE FIELD TRIGGER
    declare
    v datatype(presecion);
    begin
    v:=f(x);
    end ;
    null

  • How to call a package from within a package

    How would I call a package from within a package and pass variables to it. For instance I am trying to pass variables to a log package from another package when a user inserts or updates a table

    First, technical questions need to be addressed to one of the technical forums. Products | Database | SQL & PL/SQL would be appropriate for this question. Please direct any followup to that forum.
    Second, you cannot call a package; a package is a collection of stored procedures and functions. You can call a packaged function or procedure from another package simply by specifying the package name and the procedure
    CREATE OR REPLACE PACKAGE pkgA
    AS
      PROCEDURE callPkgB;
    END;
    CREATE OR REPLACE PACKAGE BODY pkgA
    AS
      CREATE PROCEDURE callPkgB
      AS
      BEGIN
        pkgB.someProcedure( 'Some argument' );
      END callPkgB;
    END pkgA;In general, any packaged procedure can be called by specifying the schema, package, and procedure name, i.e.
    EXEC mySchema.myPackage.myProcedurethough the schema and package can be omitted if the calling procedure is in the same schema or package.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • How to call a package with OO4O?

    I have designed a package which execute a procedure.
    How can I call it with OO4O?
    Please give me a sample code.

    Hi,
    I persume that you are facing this problem when u try to code in VB. If that is the case here comes the code.........
    OraDatabase.Parameters.Add "A_NBR_NEWSID", A_NBR_NEWSID, ORAPARM_INPUT, 2
    OraDatabase.Parameters.Add "A_NBR_TOPICID", A_NBR_TOPICID, ORAPARM_INPUT, 2
    OraDatabase.Parameters.Add "A_NBR_USERID", A_NBR_USERID, ORAPARM_INPUT, 2
    OraDatabase.Parameters.Add "result", 0, ORAPARM_OUTPUT
    OraDatabase.Parameters("result").serverType = 2
    OraDatabase.ExecuteSQL ("declare result Number; Begin :result := PKG_CONTENT_MANAGEMENT.FUN_GET_NEWS_PERM_BY_USERID(:A_NBR_NEWSID, :A_NBR_TOPICID, :A_NBR_USERID); end;")
    OraDatabase.Parameters.Remove "A_NBR_NEWSID"
    OraDatabase.Parameters.Remove "A_NBR_TOPICID"
    OraDatabase.Parameters.Remove "A_NBR_USERID"
    FUN_GET_NEWS_PERM_BY_USERID = OraDatabase.Parameters("result").Value
    OraDatabase.Parameters.Remove "result"
    Hope this clear your doubt..
    Raj

  • How to call a procedure inside a trigger?

    hi people,
    I have a trigger which cals a stored proc named PY.but i couldn get dis trigger worked out.can u pls sugges me?.the trigger is as follows.
    create or replace trigger ts after insert on s
    for each row
    begin
    call py
    if this trigger gets successfully created its enough for me.gimme some ideas.Thanks in advance.
    regards
    VIDS

    Hi,
    create or replace trigger ts after insert on s
    for each row
    begin
    call py
    just call 'py' no need of calling 'call py'.....
    create or replace trigger ts after insert on s
    for each row
    begin
    py;
    If it helps mark question as anwered or helpfull....
    Thanks,
    Pavan

  • HOW TO CALL A PACKAGE VARIABLE INTO ODI

    Hi,
    Please help me with a solution for capturing a variable from a package into odi. I have seen the solution given by cezar in odiexperts.com but we are not looking for a package creation thru odi. Please suggest any other method.
    Thanks
    Venkat

    Pass it to the SP as a variable
    - there are examples in the cf docs

  • How to call oracle package periodically (JOB)

    Hi All,
    My requirement is that, I have created a package and i want to run the package periodically (job) every 5mins.
    can any one help me in this?
    Thanks,
    SIvaprasad

    I'm posting the first scenario,
    You can check that ->
    satyaki>
    satyaki>select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
    PL/SQL Release 10.2.0.3.0 - Production
    CORE    10.2.0.3.0      Production
    TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
    NLSRTL Version 10.2.0.3.0 - Production
    Elapsed: 00:00:00.01
    satyaki>
    satyaki>
    satyaki>create table test_job_stat
      2      (
      3        cola   varchar2(30)
      4      );
    Table created.
    Elapsed: 00:00:00.66
    satyaki>
    satyaki>
    satyaki>select * from test_job_stat;
    no rows selected
    Elapsed: 00:00:00.10
    satyaki>
    satyaki>
    satyaki>create or replace package test_sa
      2  is
      3    procedure test_a;
      4    procedure test_b;
      5  end;
      6  /
    Package created.
    Elapsed: 00:00:00.03
    satyaki>
    satyaki>
    satyaki>create or replace package body test_sa
      2  is
      3    procedure test_a
      4    is
      5    begin
      6      insert into test_job_stat values('Inside A');
      7    end;
      8   
      9    procedure test_b
    10    is
    11    begin
    12      insert into test_job_stat values('Inside B');
    13    end;
    14  end;
    15  /
    Package body created.
    Elapsed: 00:00:00.16
    satyaki>
    satyaki>
    satyaki>variable jobno number;
    satyaki>
    satyaki>begin
      2  dbms_job.submit(
      3                  :jobno,
      4                  'BEGIN test_sa.test_b; END;',
      5                  INTERVAL => 'SYSDATE + 2/86400'
      6                 );
      7  commit;
      8  end;
      9  /
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.05
    satyaki>
    satyaki>
    satyaki>select * from test_job_stat;
    COLA
    Inside B
    Inside B
    Elapsed: 00:00:00.07
    satyaki>/
    COLA
    Inside B
    Inside B
    Inside B
    Elapsed: 00:00:00.05
    satyaki>/
    COLA
    Inside B
    Inside B
    Inside B
    Elapsed: 00:00:00.08
    satyaki>/
    COLA
    Inside B
    Inside B
    Inside B
    Inside B
    Elapsed: 00:00:00.10
    satyaki>
    satyaki>print jobno
         JOBNO
            22
    satyaki>
    satyaki>
    satyaki>exec dbms_job.remove(22);
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.03
    satyaki>
    satyaki>
    satyaki>select * from test_job_stat;
    COLA
    Inside B
    Inside B
    Inside B
    Inside B
    Inside B
    Inside B
    Inside B
    Inside B
    Inside B
    9 rows selected.
    Elapsed: 00:00:00.13
    satyaki>/
    COLA
    Inside B
    Inside B
    Inside B
    Inside B
    Inside B
    Inside B
    Inside B
    Inside B
    Inside B
    9 rows selected.
    Elapsed: 00:00:00.13
    satyaki>/
    COLA
    Inside B
    Inside B
    Inside B
    Inside B
    Inside B
    Inside B
    Inside B
    Inside B
    Inside B
    9 rows selected.
    Elapsed: 00:00:00.12
    satyaki>Hope this will give you one basic idea.
    Regards.
    Satyaki De.

  • Calling a package  in Data template

    Hi All ,
    I am using Data template for XML generation and want to call a PL/SQL package.I have gone through some of the threads on the topic.
    I have some doubts in this regard :
    1)Can we have procedures inside package or its just the functions that can be called.
    2)Does the package gets executed every time we generate the report.(It got executed for me just once).
    3)The parameters defined in the data tamplte can be passed to the PAckage as well?
    4) Is this supported on BIP 10.1.3.2 or XML publisher 5.6.2?
    Thanks!!

    Thanks for your detailed answer!!
    I am trying to call a package just to understand how it works .This package just inserts a row in "suppliers" table.I ma calling this package through 'beforeReprot' trigger and querying the table after that.
    I have written a package "test_pack" :
    create or replace
    package test_pack as
    function test_insert_fun return boolean;
    end test_pack;
    create or replace
    package body test_pack as
    function test_insert_fun return boolean is
    begin
    insert into suppliers values (1,'p1','p2');
    return (TRUE);
    end;
    end test_pack;
    Data Template :
    <dataTemplate name="test" dataSourceRef="demo" defaultpackage="test_pack">
         <dataQuery>
              <sqlStatement name="Q1">
                   <![CDATA[SELECT * from suppliers]]>
              </sqlStatement>
         </dataQuery>
         <dataTrigger name="beforeReport" source="test_pack.test_insert_fun()"/>
    </dataTemplate>
    However after this , when I try to view data , I amnot seeing any output.When i go nad check the suppliers table in db, i dont see any values.
    I believe this package should be executed everytime i view the data.
    Please advice!!

  • Calling Procedure/Package in shell script

    how to call a package / procedure in a unix shell scripts. also how to schedule jobs in shell scripts.

    That's usually accomplished by run sqlplus from shell script.
    http://www.oracle-base.com/articles/misc/OracleShellScripting.php
    Crontab can be used to schedule jobs in unix.
    http://www.adminschoice.com/docs/crontab.htm

  • How to call or not call a Trigger in same table based on condition?

    Hi
    How to call or not call a Trigger in below situations..
    If a table contains a record of same value i.e,
    [i[u]]ID
    1
    1
    3
    In above ID 1 is repeated for two times.
    In this situations i don't want to call a trigger..
    But, the value ID is for 3, now i want to fire a trigger.
    Based on this i want to delete in another table.
    How can I check it?
    Thanks

    Thanks for ur reply..
    The below is my scnario..
    I am having two table
    employee
    Id empcol
    101 111
    101 222
    102 444
    Department
    id deptcol
    101 457
    101 678
    102 543
    The above is my table structure no one column is PK, so i m not able create FK.
    When I am deleting from employee where id =101 and empcol=111,
    the above record is deleted.
    At present I am using After Update Trigger..
    So trigger is called and delete the id 101 in Department table.
    In my scenario i can't delete a record in Department table
    bcoz i am having id morethan 101 in employee table.
    If employee table contains one ID like 102 the Trigger should works.
    How can I check the condition After delete on employee table it contains morethan same employee id?
    The below is my Trigger..
    CREATE OR REPLACE TRIGGER CALL_TRIGGER
    AFTER DELETE ON Employee
    FOR EACH ROW
    DECLARE
    count_id pls_integer;
    BEGIN
    SELECT COUNT(*) INTO count_id from Employee WHERE ID <>:new.ID;
    IF( count_id >1) THEN
    DELETE FROM Depratment where ID=:old.ID;
    END IF;
    END;
    I am geting an error ORA-04091 table is mutuating, trigger cannot seen it.
    I had tried with package and package body also.. But no luck.
    Thanks

  • Call a Package in another schema  from a Trigger?

    Is there a method to call a package procedure from a trigger when the package exists within a different schema than the trigger (table)?
    Do you need a dblink to execute a procedure in a different schema within the same database?

    Hello,
    you need execute prvilege given to target schema on source package and you can create synonym in target schema as well. And you don't need dblink if the procedure resides in same schema or different schema in same database
    CREATE OR REPLACE TRIGGER myschema.test_trg
       BEFORE INSERT OR DELETE OR UPDATE
       ON test_table
       REFERENCING NEW AS new OLD AS old
       FOR EACH ROW
    DECLARE
    BEGIN
       -- How to pass parameters
       otherschema.mypkg.myproc (:new.id, :new.code);
    END;
    /Regards

Maybe you are looking for

  • Install two instances in Solaris 9 + Oracle 10.2

    Hi all, I am trying to install portal DEV and QAS(NW 7.0) in same Sun Solaris box, I have finished the DEV installation with 'Central System Installation' option. It ran OK. I try to install QAS in it with same option 'Central System Instalation', wh

  • Proxy Problem The proxy server is refusing connections

    I run Windows XP. I did have a Cybot backdoor Activity attack intercepted by Norton Internet Security and I used the Norton NPE to remove it from the computer. I do not know if this caused the proxy problem or not. There is no proxy problem connectin

  • Mouse recommendations

    Hello All I have had it with my mighty mouse track ball... I am always fighting with this thing trying to get it to scroll down, I have cleaned it and, clean it everyday .. it seems to have a mind of its own when it wants to work, I'm really thinking

  • HDMI suddenly non functional on S531

    Hi I'm using a S531 for presentation work. It worked excellent until a few days ago. PC and Projector don't recognise each other anymore.  The beamer and cables are fine as another laptop does work. I know how to switch to the beamer (Fn+F7) and stuf

  • Can not add Roles Server 2012 Standard R2

    Every time I try and add the DFS Namespace and replication roles it says the server requires a re-boot.  I check to ensure the version of server is activated and it is. I rebooted twice, checked for critical updates which there was none and tried aga