Database trigger in program

hai
is it possible to fire a method or execute set of code in java application when updation,insertion or deletion done in database.

from inside oracle, can rmi, socket, jms etc out on a trigger.
old forum link seems to have been removed.

Similar Messages

  • Database Trigger in ABAP Program

    Hi experts,
    Is it possible to define a database trigger in an ABAP program, to be triggered when the data from a database table is modified?
    Thanks,
    Nuno Afonso

    I doubt it, but if it's possible, I would NOT use it. Remember the application server assumes the role of the DBMS sometimes, and you will never be absolutely sure if your trigger will be used or not.
    You can also define a TRIGGER for your Z-tables using the DBMS, but I will only recommend it if you are using ONLY z-tables. For standard tables, I would look for an alternate method, ie EXITs.
    And if it's a Z-Table, you can just control its inputs by permissions (don't allow users to maintain it, just make a dialog to do it, and the dialog program would be the "trigger" guy)

  • STORED PROCEDURE & DATABASE TRIGGER

    제품 : FORMS
    작성날짜 : 1995-11-07
    * STORED PROCEDURE
    1. Oracle Forms 4.5에서는 PL/SQL Code를 Server-Side에 저장하거나 Forms 내 Trigger, Procedure로 갖을 수도 있다.
    다음과 같은 경우 Procedure를 Database Server에 저장하는 방법을 선택하는
    것이 좋다.
    - Procedure가 Standard한 기능을 제공하여 다른 Tool이 공유할 수 있을 때.
    - Procedure가 중요한 DML 기능을 가질 경우.
    - Oracle Forms 4.5에서는 PL/SQL의 Version을 1.1까지 지원하므로, PL/SQL
    Version 2.X 의 기능이 필요한 경우.
    2. Stored Procedure의 제한사항
    (1) Server가 7.0 이상이어야 한다.
    (2) Pass되는 Variable은 2000 Byte이하이어야 한다.
    - 2000이 넘으면 Truncate가 되고, PL/SQL에서 Value_Error Exception이
    발생한다.
    (3) Menu PL/SQL에서는 Stored Procedure와 Function을 부를 수 없다.
    (4) Stored Subprogram의 정의가 바뀐 경우, Forms를 다시 Server와 Connect
    하기 전에는 영향을 주지 않는다.
    3. Oracle 7 Server 에서 제공하는 Standard Package들
    - dbms_alert
    - dbms_ddl
    - dbms_describe
    - dbms_lock
    - dbms_mail
    - dbms_output
    - dbms_pipe
    - dbms_session
    - dbms_snapshot
    - dbms_standard
    - dbms_transaction
    - dbms_utility
    < Oracle7 Developers Guide 참조>
    4. Calling Stored Procedures
    (1) Database Procedure는 Server-Side PL/SQL Engine에 의해 실행되도록
    Design된 PL/SQL Block이다.
    (2) Stored Procedure를 Call하기 위해서는 EXECUTE Privilege가 필요하다.
    (3) Server-Side Procedure와 Forms에서의 PL/SQL의 중요한 차이점은
    Server-Side 에서는 Forms의 Bind Variable (:Block_Name.Item_Name 등)
    을 인식하지 못한다는 것이다.
    (4) Parameter/Return이 가능한 Data Type
    - VARCHAR2 : Maximum of Varchar2(2000)
    - NUMBER
    - DATE
    - BOOLEAN
    제한사항
    - TABLE%ROWTYPE, TABLE.COLUMN%ROWTYPE으로 정의된 것은 Reference가
    안된다.
    - Unsupported Parameter나 Return Value를 사용하면 다음의 Error가
    발생한다.
    * PL/SQL error 313 at line xxx, column yyy 'PROCNAME'
    not declared in this scope.
    * PL/SQL error 201 at line xxx, column yyy identifier 'FUNCTNAME'
    must be declared.
    (5) Formal Parameter의 Default Value
    - Defulat Value는 제공하지 않는다.
    - User가 임의로 줄 수 있다.
    - Procedure Private_Test(a in VARCHAR2 := 'Hello' b in
    VARCHAR2 := 'There') IS
    BEGIN
    Dbms_Output.Put_Line(a);
    Dbms_Output.Put_Line(b);
    END;
    (6) 다른 User의 Stored Subprogram이나 Remote Database를 Call하려면
    - User Name이나 Database Link명을 숨기기 위하여 Synonym을 생성하여야
    한다.
    - CREATE SYNONYM lib_hr_syn FOR libowner.lib_hr;
    - Program에서 Call할 때에는 ss_num ;= lib_hr_syn.get_ssn(:EMP.EMPNO);
    5. PL/SQL Compiler가 해당 Procedure를 찾는 순서
    (1) Current PL/SQL Block 내에 정의되어 있는가?
    (2) Standard PL/SQL Command인가?
    (3) Oracle Forms 내의 Built-in Procedure 혹은 Function인가?
    (4) User_Named Procedure 혹은 Function인가?
    (5) Server-side에 정의된 DBMS_STANDARD Package인가?
    (6) Current user가 Server-Side의 어떤 Procedure나 Function을 Access
    하는가?
    * 이상의 질문에 대하여 전부 'NO'라는 대답이 나오면 Compiler는 다음과 같은
    Error Message를 준다.
    - PL/SQL error 313 at line xxx, column yyy 'PROCNAME' not declared in
    this scope.
    - PL/SQL error 201 at line xxx, column yyy identifier 'FUNCTNAME'
    must be declared.
    * DATABASE TRIGGER
    1. Database Trigger는 Forms에서의 Trigger와 개념적으로 거의 동일하다.
    차이점은 Trigger가 Fire되는 원인을 제공하는 사건과 후속코드가 실행되는
    장소가 틀린 것이다.
    2. Database Trigger는 Table과 연관된 PL/SQL Block들이다. Table에 대한
    UPDATE, INSERT, DELETE 등의 행위에 의해 Fire된다.
    3. Error 발생 시에는 RAISE_APPLICATION_ERROR Built-In Procedure를 사용하
    여 Error를 표시한다.
    RAISE_APPLICATION_ERROR Procedure에서는 Error Number가 20000 - 20999의
    Range를 가진다.
    4. Creating & Editing Database Triggers
    아래와 같은 적절한 권한이 주어진다면 Forms Designer Mode에서 Database
    Trigger를 직접 Create, Edit, Compile, Browse 할 수 있다.
    - Execute Privilege, Create Privilege, Compile Privilege,
    Drop Privilege
    * Create하려면
    - Navigator에서 Database Objects와 Table Nodes를 Expand한다.
    - 원하는 Table을 선택하고 Expand한다.
    - Triggers Nodes를 선택하고 Menu Bar의 Navigator*Create를 선택한다.
    - Database Trigger Editor에서 작성, compile한다.
    * Edit 하려면
    - Navigator에서 Database Objects와 Table Nodes를 Expand한다.
    - 원하는 Table을 선택하고 Expand한다.
    - 원하는 Trigger에서 Double-Click하면 Editor가 나타난다.
    - Database Trigger Editor에서 변경, compile한다.

    not possible via forms
    you can debug it on SQL Developer by using manual INSERT Updates commands

  • Need to call an application with in  Database trigger

    Dear all
    I have created a database trigger that reads the new values inserted on my table and append the record on a text file on the operationg system.
    I have a software that convert this text file to binary file.
    I can call this software using a command prompt
    I need to issue this command prompt from within the database trigger
    I need to Know is there a package or plsql code that can call an application.
    We can do this easly on the form builder using the comman HOST
    But I need to issue this command from within SQL PLUS
    is there a way
    please help
    thanks in advance

    another simple way is to write a C program with an exec function that calls the external program.
    The C function can be called by the Oracle server as an extproc (like a PL/SQL funtion call).
    Check for the extproc Oracle documentation:
    http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b15658/ldr_demo.htm
    Sample programs you will find in your $ORACLE_HOME/plsql/demo directory.
    Kind regards
    Karsten

  • How to determine logical database in a program?

    Hello guys!
    How to determine logical database in a program on Eclipse?
    I have not found any options:
    Thanks!

    Welcome to SDN
    Check the table RSOSFIELDMAP
    Assign points if useful
    Regards
    N Ganesh

  • Multiple Rows Update / Refresh Toplink Query when database trigger involved

    Hi everybody!
    I have two easy troubles for you; the platform is the same as the SRDemo Toplink version.
    1.     Multiple Rows Update: I want to update with mergeEntity method, multiple rows for an isolated table; that method receives a parameter that I try to bind with the iterator "dataProvider" but it only merges the first row, not all, any other combination returns an error.
    What I want to do is to have a form (like tabular forms in Apex) that lets me update multiple rows in a single page. ¿May anyone tell me how to do it?
    2.     Refresh Toplink Named Query: I have a list on a page with two columns. From another page, a button does an action that fires a database trigger that updates one of the columns on the list´s page. When I go back to the list, it is not updated; however, the CacheResults´s property is set to false on the iterator.
    Thanks in advance,
    Alejandro T

    I didn't use it (yet), but - you might take a look. You'll find a [url http://www.oracle.com/technetwork/developer-tools/apex/application-express/apex-plug-ins-182042.html]Timer plug-in on this page. It is a dynamic action which allows you to periodically fire other dynamic actions in the browser. For example use the timer to refresh a region every five minutes. You can perform any dynamic action you want using this infrastructure.So I was thinking: you might use it to run a dynamic action which would check whether something changed in that table (I suppose you'll know the way) (for example, a database trigger might set a flag in some table, timestamp or similar), and - if you find that something really changed - refresh the page.
    As I said, I never used it so that's pure theory. Someone else might know better, though.

  • How to Get  the SSO Logged user information in database trigger

    I need to track which SSO user is inserting data into a table , so how can i get the information of that user in a database trigger on that table
    thanks

    Try using portal30.wwctx_api.get_user returns a varchar2 (PUBLIC) or the Username that is logged in
    I need to track which SSO user is inserting data into a table , so how can i get the information of that user in a database trigger on that table
    thanks

  • How to get SSO logged user information in a database trigger

    my database is 9i
    my application server is 9i too
    I need to track which SSO user is inserting data into a table , so how can i get the information of that user in a database trigger on that table
    thanks

    Hi,
    The only way I could figure out how to get it was to import the com.sap.security.api.
    1. From Window>Preferences>Java-->Classpath Variables, set up a variable called WEBAS_HOME pointing to:
    <drive>/usr/sap/<SID>/jc00/j2ee/cluster/server0/
    2. Right click on properties of your Dynpro Project->Properties->Java Build Path->Libraries and click "Add Variable." 
    3. Select WEBAS_HOME and click "Extend"
    4. Select /bin/ext/com.sap.api.sda/com.sap.security.api.jar and click OK.
    If you don't have access to a portal directory, you will have to get this jar file and copy it to your workspace to add to your build path instead of the above steps.
    Then in your code:
    import com.sap.security.api.IUser;
    import com.sap.security.api.IUserAccount;
      public void GetLogonID( )
         String LogonID;
         try {
              /*     create an user object from the current user */
              IWDClientUser wdUser = WDClientUser.getCurrentUser();
              IUser user = wdUser.getSAPUser();
              if (user != null) {
                   IUserAccount acct = user.getUserAccounts()[0];
                   if (acct != null) {
                        LogonID = acct.getLogonUid();
                   } else
                        LogonID = "acct null";
              } else {
                   LogonID = "user null";
              wdContext.currentContextElement().setDisplayName(user.getFirstName() + " " + user.getLastName());
              wdContext.currentContextElement().setLogonID(LogonID.toUpperCase());
         } catch (Exception e) {
              e.printStackTrace();
    Hope this helps...  I had to search several places before I found all the necessary stuff.  Maybe I can get my first points!
    Thanks,
    Andrew

  • Report in PDF format and email it to some clients, using  Database Trigger

    Hi
    Is it possible to run a report in PDF format ad email it to some clients after a specific event through Database Trigger. For example whenever a client makes an entry into order entry table (through entry form), a trigger should execute on Orders table, this trigger should execute or generate a PDF formatted report and finally mail it to Sales team?
    I have
    ORAS 10g(10.1.2.0.2)
    utl_mail configured.

    In Reportsconfig.properties file the http port is 7778,
    now the output is like this...
    SQL> /
    * WELCOME TO EVENT-BASED-REPORTING API *
    * API-Version : 9i *
    * (C) Oracle Corporation, 2000 - 2002 *
    * Debugging turned ON **************************
    *** Length of Paramlist : 1
    OK : Parameter added : GATEWAY=http://myserver.com:7778/reports/rwservlet
    *** Length of Paramlist : 2
    OK : Parameter added : SERVER=rep_myserver_oracleas2
    *** Length of Paramlist : 3
    OK : Parameter added : REPORT=D:\Reports\emp.rdf
    *** Length of Paramlist : 4
    OK : Parameter added : USERID=abc/xyz@mydb
    *** Length of Paramlist : 5
    OK : Parameter added : DESTYPE=mail
    *** Length of Paramlist : 6
    OK : Parameter added : DESFORMAT=PDF
    *** Length of Paramlist : 7
    OK : Parameter added : [email protected]
    Starting run_report: building url
    *** Building URL (RUN_REPORT)
    OK : URL built :
    http://myserver.com:7778/reports/rwservlet?SERVER=rep_myserver_oracleas2&REPO
    RT=D%3A%CReports%5Cemp.rdf&USERID=abc%2Fxyz%40mydb&DESTYPE=mail&D
    ESFORMAT=PDF&DESNAME=khan.emran84%40gmail.com&statusformat=xml
    *** Submitting HTTP Request
    *** using URL
    :http://myserver.com:7778/reports/rwservlet?SERVER=rep_myserver_oracleas2&REP
    ORT=D%3A%5CReports%5Cemp.rdf&USERID=abc%2Fxyz%40mydb&DESTYPE=mail&
    DESFORMAT=PDF&DESNAME=khan.emran84%40gmail.com&statusformat=xml
    OK : Request submitted - Return stream : <?xml version = '1.0' encoding =
    'ISO-8859-1' standalone = 'yes'?>
    <serverQueues>
    <error code="50159"
    component="REP" message="Executed successfully but there were some errors when
    distribute the output"/>
    <
    OK : Request submitted - Length of stream : 229
    *** XML-Parsed - Following Structure discovered :
    *** Checking elements!
    serverQueues ()
    *** Checking attributes!
    error
    *** Checking attributes!
    __code = 50159
    __component = REP
    __message = Executed successfully but there were some errors when distribute the
    output
    *** Finished Parsing XML
    Getting value for element: job
    Getting value for element: error
    *** Requesting value for Attribute error.component [REP]
    Getting value for element: error
    *** Requesting value for Attribute error.code [50159]
    Getting value for element: error
    *** Requesting value for Attribute error.message [Executed successfully but    
    there were some errors when distribute the output]
    REP-50159:Executed successfully but there were some errors when distribute the
    output
    declare
    ERROR at line 1:
    ORA-20999:
    ORA-06512: at "NRSP.SRW", line 264
    ORA-06512: at "NRSP.SRW", line 799
    ORA-06512: at line 15

  • How can I create a pdf-report in a database trigger

    Hi,
    how can I create a pdf-file with Reports 9i in a database trigger ?
    Where can I find informations about it?
    Thanks
    Friedhold

    Here would be the place to start.
    If you have existing reports to call, take a look at the JRC

  • How can I obtain an specific message raised by a database trigger

    Dear friends,
    if I have a database trigger and I want to show an error message which was raised from a database trigger to a form, I can do it by raising an application error inside database trigger, and by showing DBMS_ERROR_TEXT inside ON-ERROR trigger. This is ok for me.
    But how can I do if I want to show a specific message? Let's say I have a BEFORE INSERT table trigger, and I want to verify whether data was correctly informed (for example, "user name must be entered"). If I raise an application error, I see a very big error message which includes both my personal error message and database message.
    Surely I can do a SUBSTR in this message, but can't I do something easier? Let's say I put all error messages in a variable:
    (Let's suppose it's a BEFORE INSERT trigger code, which is related to my table)
    if :NEW.user_name is null then
    p_error_message := 'User name must be entered.';
    end if;
    if p_error_message is not null then
    raise_application_error (-20000, p_error_message);
    end if;
    ... with this p_error_message being shown to final user, with no need to edit it via PL/SQL instructions like SUBSTR. Is this possible? If not, I'll be quite satisfied with SUBSTR because it fits my needs somehow.
    Best regards,

    raise_application_error will be used for raise errors on form.here i'm providing u the example
    CREATE TRIGGER at AFTER UPDATE OR DELETE OR INSERT ON emp
    for each row
    declare
    v_1 number
    begin
    select empno into v_1 from emp where empno=7369 ;
    exception when no_data_found then
    RAISE_APPLICATION_ERROR(-20001,'No data found'||sqlerrm);
    END;
    now when you insert data on emp table through form. if value does not found of selected empno then No data found will be shown on form
    Edited by: SKYNIAZI on Mar 20, 2009 12:19 PM
    Edited by: SKYNIAZI on Mar 20, 2009 12:56 PM

  • How to specify when clause in a database trigger

    I would like to create a database trigger that only fires on database create statements. In particular, it only needs to fire when tables with a specific prefix fire.
    I'd like to be able to specify something in the when clause along the lines of :
    CREATE OR REPLACE
    TRIGGER CAPTURE_STATS
         after CREATE ON rtrei.schema
         WHEN ( NEW.table_name like 'RT_FOO%' )
    begin
    add_stats_capture( :new.min_range, :new.max_range);
    end;
    It looks like I should be able to use a when as part of a database trigger, but I have no idea what new would be defined to be so that I could use it... perhaps it is an object and the clause would look something like
    when (new.objecttype = 'TABLE' and new.name like 'RT_FOO%')?
    Any ideas? I've searched through the docs, but have not been able to find anything relevant.
    thanks very much,
    Robin

    You can use the WHEN clause with DDL triggers. You can move Todd's IF-THEN clause up into the WHEN clause.
    See http://download-west.oracle.com/docs/cd/B14117_01/appdev.101/b10795/adfns_ev.htm for all of the System-Defined Event Attributes.
    CREATE OR REPLACE TRIGGER capture_stats
    AFTER CREATE ON SCHEMA
    WHEN (ora_dict_obj_type = 'TABLE' AND ora_dict_obj_name LIKE 'RT_FOO%')
    BEGIN
            --Do whatever here.
    END capture_stats;

  • Is there an AUDIT option like AFTER SERVERERROR database trigger?

    I want to log any and every error-exception in a test database for a period.
    I have seen DBMS_UTILITY.FORMAT_ERROR_BACKTRACE article published on Oracle Magazine;
    http://www.oracle.com/technology/oramag/oracle/05-mar/o25plsql.html
    But before trying to build a custom application like this one;
    http://apex.oracle.com/pls/otn/f?p=2853:4:1160653345033883::NO::P4_QA_ID:5922
    1- I wanted to be sure if there is a specific WHENEVER NOT SUCCESSFUL Audit option for this need?
    2- Also is there a way to capture NO_DATA_FOUND exception with AFTER SERVERERROR database trigger?
    Thank you,
    Best regards.

    some stuff like following;
    1)
    -- the right one is conn hr/hr
    conn hr/eychar
    2)
    -- the right one is grant select on employees to public;
    grant select onnnn employees to public;
    3)
    create or replace procedure p1 as
    begin
    raise_Application_error(-20001, 'catch me if you can');
    end;
    exec p1;
    again thank you for your interest Michaels.

  • Trigger a program immediately after the Payment Run F110

    Hi All,
    How to trigger a program immediately after the Payment Run F110.
    Thanks.

    Hi,
    In general payment media programs are executed immediately after the payment run.
    You can execute payment media programs using transaction code SA38 or you can enter appropriate variants for payment media programs in printout/date medium tab while executing payment run in F110 so that they are run automatically along with payment run.
    Thanks!
    Raju
    Edited by: M V Narayana Raju on Sep 18, 2010 2:40 AM

  • Primary Key - Generated by database TRIGGER

    Hi,
    I have a form with a block that is attached to a table. So far, nothing fancy :-)
    The Primary is generated with an ORACLE SEQUENCE. That is done at the TABLE level with a DATABASE trigger.
    So in the form, the primary field is not populated.
    Works fine. But if the user wants to UPDATE the forms content, right after they did an INITIAL commit, THEY CAN'T !!!!!!!!!!!
    How can I code this in the form?
    Is there a way to syncronize (populate) the primary key in the form with it's table content?
    If so, how do I query the table if I don't have the primary key value ?
    Thanks for ANY advise,
    Marc.

    Another solution is to use both a database trigger and a PRE-INSERT trigger in Forms.
    The database trigger should be something like
    CREATE TRIGGER INS_TABLENAME BEFORE INSERT ON TABLENAME
    FOR EACH ROW WHEN (new.ID IS NULL)
    BEGIN
    SELECT TABLENAME_SEQ.nextval INTO :new.ID FROM DUAL;
    END;
    and the PRE-INSERT trigger should be something like:
    SELECT TABLENAME_SEQ.nextval INTO :blockname.ID FROM DUAL;
    This way one solves the problem of DML RETURNING VALUE not working in Forms with Oracle version > 8 (does it work on version 8 as it is said to be? - i have not tested it anyway) and the use of other applications (SQL*Plus, JAVA, etc) without writing any code.

Maybe you are looking for

  • Can't order playli

    I'm using Creative MediaSource to organize my new Vision:M and suddenly I can't change the list order of playlists by the usual drag and drop method. The icon still changes to show where I'm moving to, but once I let go, nothing happens. Its a minor

  • Condition not working in the query.

    Hello Gurus, When I apply a condition and select the characterisitc assignment as "All characteristics in the drilldown independently", the report is not showing any records. When I apply to one or more characteristics it displays records but the out

  • How to add new assignment block in opportunity

    Hi,Experts. I'm a beginer of SAP CRM. I need to add/create a new assignment block similar to existing assignment block 'Details' and display enhancement items in Opportunity screen with SAP crm 2007. I have created new view using Wizard in BSP_WD_CMP

  • MaxL Spool Options

    MaxL Help for the Spool command says: ------------------------------------Log the output of a MaxL Shell session to a file. Send standard output, informational messages, error messages, and/or warning messages generated by the execution of MaxL state

  • N8: "Data Use in Home Network" changes automatical...

    I have selcted the "Data Use in Home Network"  to be "Always Ask". But i have no Idea why this option changes back to "Automatic". Some times i could not even browse GPRS data after this change happens in my N8. I have to end up restarting the Phone.