Dynamically Created Trigger

I have a Java application using Business Components. The connection was created using the connection wizard and a standard userid, password is passed to the connection. The application is deployed and launched using JWS. I dynamically create the JNLP tag in a JSP file and pass in the current user identification as a system resource. The html page that holds the link to the JSP page is protected under SSO so I can validate the user id and I know when the application is launched that it is launched by a valid user. The application is launched and I can retrieve the user id by calling System.getProperty(userID).
So - Now that I have the user ID I would like to pass this on to the database for tracking purposes. Every time I insert/update on a table I would like a trigger that sets the userid and current date for that record.
I have the trigger written for the current date - that was easy enough..
TRIGGER "SPECIES"."PLANTCOMMITDT" BEFORE INSERT OR UPDATE ON "SPECIES"."PLANT"
REFERENCING OLD AS OLD NEW AS NEW
FOR EACH ROW
BEGIN
:new.Commitdt:=SYSDATE;
END;
The problem is how can I add the userid to this trigger? I have the userid but in the application - not in the database. Can you dynamically create a trigger? So I can pass in the userid from the application?
Any help would be appreciated!

hi,
Could you please log this issue as a bug . The bug form requests for appropriate info to reproduce the bug.
Bug report url:
http://developers.sun.com/prodtech/javatools/jscreator/support/index.jsp
Click on Bug Report / Feature Request
Thanks
K

Similar Messages

  • Execute create trigger script in a procedure

    Is it possible to create a trigger with pl/sql?
    I have made a procedure thats makes the create or replace trigger statement.
    (when i copy and past the statement the trigger is created succesvol)
    How can i execute the create trigger statement on the end of the procedure?
    Thanks.

    Well, then proceed with dynamic SQL.
    Or, in my opinion much better: produce a SQL script with variables for table name and trigger name.
    Then run this script with the appropriate values every time you have created a table.
    Cheers,
    Guido
    Edited by: Guido on Oct 22, 2008 10:30 AM

  • Dynamically creating a Record Group based on Previously entered Record Grou

    Forms [32 Bit] Version 10.1.2.3.0 (Production)
    Hi,
    I know how to dynamically create a record group based on a query and putting the code in When new form instance.
    My query is. I have a form which has multiple Record Groups and the user wants to dynamically create subsequent groups based on previous groups.
    For example
    I have a record group with selects a Location,
    when the user selects the Location from a list of values
    the 2nd record group called 'Cost Centres' will have to filter out only those with the locations selected above.
    How can I populate the 2nd record group at run-time when I do not know what site the user will select?
    If I simply populate in when new form instance as in location and just select everything, the list of values populates.
    CC field is a LIST ITEM and the list style is a POP LIST, it is not required.
    I have put the code in the Location field in the when-list-changed trigger.
    I am getting this error:
    frm-41337: cannot populate the list from the record group
    here is the code:
    DECLARE
    v_recsql Varchar2(1000); -- The SQL for creating the Record Group.
    v_recgrp RecordGroup; -- Record Group
    v_status Number; -- Return Value of Populate_Group function.
    c_where VARCHAR2(1000);
    BEGIN
         IF :location = '1' THEN
              c_where := ' substr(cost_centre,1,2) in (''01'',''02'')';
         ELSIF :location  = '2' THEN
              c_where := ' substr(cost_centre,1,2) in (''02'',''03'')';
         ELSIF :location   = '3' THEN
              c_where := ' substr(cost_centre,1,2) in (''01'',''11'',''07'')';
                   ELSE
              c_where :=  ' 1=1'; --EVERYTHING
         END IF;
    v_recsql := 'SELECT cost_centre, description  FROM   cost_centres  where '||c_where;
    -- Create the Record Group
    v_recgrp := CREATE_GROUP_FROM_QUERY('v_recgrp', v_recsql);
    IF NOT ID_NULL(v_recgrp)
    THEN -- No Error, record group has been successfully created.
    -- Populate Record Group
    v_status := POPULATE_GROUP('v_recgrp');
    IF v_status = 0
    THEN -- No Error. Record Group has been Populated.
    POPULATE_LIST('block.CC', 'v_recgrp');
    END IF; -- IF v_status = 0
    -- Delete the Record Group as it is no longer needed.
    DELETE_GROUP('v_recgrp');
    END IF; -- IF NOT ID_NULL(v_recgrp)
    END;thanks for your assistance.

    Hi,
    Once record status gets change for block you can not populate/repopulate the list item. Keep those list items as non-database item with different names and create different items as database orignal items. Than assign the values in WHEN-LIST-CHANGE trigger to the actual database items.
    -Ammad

  • Futureproof and dynamically created button

    I have been looking solution how to make buttons dynamically so that I can fetch dynamically values for buttons:
    - value,onclick,class,type,request
    This excellent page has very closely what I am looking: http://www.laureston.ca/2012/04/20/simple-workflow-implementation-in-apex/
    but I have challenges getting the escaped special characters to work especially for the apex.submit - part.
    Maybe that is just because 'copy-pasting' the plsql-region code from www-page didn't work out of the box
    Application Express 4.2.3.00.08
    Because dealing with the escape chars make the page easily break and there are now the new dynamic actions, I need to check what would be futureproof way of dynamically creating the buttons.
    If this is anyway the most practical way to proceed, then where I should look for further information about htp.p(....) button creation examples with rich escapes?
    Made small test page, where you can see one of my trials trying to get the escapes right.
    user test
    pass test
    http://apex.oracle.com/pls/apex/f?p=1403:2
    rgrds paavo
    --below the code for dynamic plsql region -- very likely the escape chars are not copypasted and shown correctly:
    DECLARE
    --PL/SQL Dynamic Region
    --thisworks too??
      v_showme varchar2(3000);
    BEGIN
      for c in (select sysdate||'asdasd;asdasas'  as button_label
                , 'PIMREQUEST'  as button_request
                , 'button-gray' as button_class
                , 'button'      as button_type
                , 'P38_XPIMPOM' as button_setme
                , 'JUUSTOA'     as button_setme_value
                from dual) loop
    htp.p('<button value='''||c.button_label||''' onclick=\"apex.submit('''||c.button_request||''');'' class='''||c.button_class||''' type='''||c.button_type||'''>
    <span>'||c.button_label||'</span>
    </button>');
      end loop;
    END;

    Hi Paavo,
    Your right about the button_id. It's value comes from an input parameter. The button won't show up in the "When button pressed"-list_of_values. This is not only because you write the id yourself, but more because the entire button is created on the fly. The button isn't stored internal in an apex table, that's why it won't show up in a list of values.
    If you want to trigger a dynamic action with the button, you can use a jQuery selector as triggering element. Here you can refer to the button_id using the '#' as jQuery marker for ID, e.g. '#myButton'.
    What the button that you render does, depends on what you put in the p_link parameter. A normal save button would submit the page with condition 'SAVE', you can do that by setting p_link to 'apex.submit("SAVE")'. If the button should do a page redirect, you set p_link to 'http://www.page2go.com', or whatever url you wish to redirect to.
    The text you put in the button attributes is added as HTML element definition, so if you set p_attrs to 'alt="alternate text"', that will be added to the html of your button.
    An example for a conditional button call could be:
          if p_order_id is null
          then
            create_button
              ( p_id        => 'newOrder'
              , p_link    => 'javascript:apex.submit("CREATE"');'
              , p_label     => 'New Order'
              , p_css       => 'customButton'
          else
            create_button
              ( p_id        => 'updateOrder'
              , p_link    => 'javascript:apex.submit("SAVE"');'
              , p_label     => 'Update Order'
              , p_css       => 'customButton'
          end if;     
    This would create a 'CREATE' button for a new order (p_order_id is null), or a 'SAVE' button for an existing order.
    Regarding your ps: if you mean can you conditionaly create a button using dynamic actions? Then the answer would be yes. Yes you can use the create_button procedure in a dynamic action, however by writing it as stored procedure in the database, or in a database package, you can easily reuse your code and still have only one version of your procedure that you need to maintain.
    Regards,
    Vincent
    http://vincentdeelen.blogspot.com

  • Dynamically create (global) variables

    Hi,
    Is it in anyway possible to dynamically create variables, like you can do in Forms:
    DEFAULT_VALUE('test', v_test);
    with v_test holding the variable, like 'GLOBAL.TEST'. Forms would then create me the variable as it doesn't exist yet, assigning the given value.
    Like this I could read my variables' names from a DB table, dynamically create them, and assign their values. Inside the report I would then use them as lexical references.
    I know I can create parameters inside the report achieving the same, but we need the table-approach for our translations. Getting rid of the parameters' overhead would be great!
    Any suggestions appreciated,
    K.

    Where the lov is attached set the VALIDATE FROM LIST property to YES and craate one trigger for each field called WHEN-VALIDATE-ITEM and use the code as below...
    IF GET_ITEM_PROPERTY('FORM_FIELD_NAME',ITEM_IS_VALID)='FALSE' THEN
      :FORM_FIELD_NAME:=:GLOBAL.EmpCode;
    END IF;
    Don't forget to set NULL for global variable in KEY-LISTVAL trigger after assigning value to the form's field.
    HTH.
    -Ammad
    Edited by: Ammad Ahmed on Nov 8, 2010 4:33 PM

  • Create trigger within PL/SQL

    I have a procedure that creates a trigger. When I execute the procedure I get an error: ORA-01031, however, when I copy and paste the create trigger command, it executes and will create the trigger without any problems. What is causing the 'insufficient privileges' error when it attempts to create it within a procedure?
    Here is the stream of commands SQLPlus that shows what I am getting:
    SQL> CREATE OR REPLACE PROCEDURE prc_create_trigger
    2 (Table_Name in varchar2)
    3 IS
    4 v_create_trigger VARCHAR2(4000);
    5 BEGIN
    6 v_create_trigger := 'CREATE OR REPLACE TRIGGER trg_pauls_table ';
    7 v_create_trigger := v_create_trigger || 'AFTER INSERT ON ' || table_name || ' ';
    8 v_create_trigger := v_create_trigger || 'REFERENCING NEW AS newrow OLD AS oldrow FOR EACH ROW ';
    9 v_create_trigger := v_create_trigger || 'DECLARE ';
    10 v_create_trigger := v_create_trigger || ' v_text varchar2(20);';
    11 v_create_trigger := v_create_trigger || 'BEGIN';
    12 v_create_trigger := v_create_trigger || ' v_text := ''Inserted Row'';';
    13 v_create_trigger := v_create_trigger || ' dbms_output.put_line(v_text);';
    14 v_create_trigger := v_create_trigger || 'END;';
    15
    16 DBMS_OUTPUT.put_line(v_create_trigger);
    17
    18 --
    19 execute IMMEDIATE v_create_trigger;
    20 END;
    21 /
    Procedure created.
    SQL> exec prc_create_trigger('pauls_table');
    CREATE OR REPLACE TRIGGER trg_pauls_table AFTER INSERT ON pauls_table
    REFERENCING NEW AS newrow OLD AS oldrow FOR EACH ROW DECLARE v_text
    varchar2(20);BEGIN v_text := 'Inserted Row';
    dbms_output.put_line(v_text);END;
    BEGIN prc_create_trigger('pauls_table'); END;
    ERROR at line 1:
    ORA-01031: insufficient privileges
    ORA-06512: at "BAAN.PRC_CREATE_TRIGGER", line 20
    ORA-06512: at line 1
    SQL> CREATE OR REPLACE TRIGGER trg_pauls_table AFTER INSERT ON pauls_table
    2 REFERENCING NEW AS newrow OLD AS oldrow FOR EACH ROW DECLARE v_text
    3 varchar2(20);BEGIN v_text := 'Inserted Row';
    4 dbms_output.put_line(v_text);END;
    5 /
    Trigger created.
    I am wanting to do this because I need to create this trigger dynamically when a table has been created. This trigger is simply for testing the procedure.
    Thank you for your assistance.
    Paul

    Why does the application need to drop and re-create tables in the first place? What is the purpose of this "re-org"? If it accomplishes anything useful, it's likely that there is some flaw in the application architecture/ design/ implementation that could be fixed once to remedy whatever problem this drop & rebuild option attempts to solve. If there really is a need to reorganize a table regularly, could the application at least be modified to use one of the various approaches Oracle provides for this sort of thing?
    The "re-org" process you're describing is, at best, a hack. A trigger on the TABLES_TO_BE_REORGED table that creates triggers on whatever table name was deleted from this table is, at best, a hack. Layering one hack on top of another is likely to cause lots of pain.
    For one thing, a trigger cannot commit. But DDL implicitly commits before and after the DDL is executed. So you cannot create a trigger within another trigger. You could have a trigger that creates a job that later runs and creates the new trigger, but that's adding an extra layer of asynchronisity to a problem that is already likely over-engineered. You could also declare the trigger that creates the trigger to be an autonomous transaction, but that would cause horrible problems if the re-org process ever were to encounter and exception and have to roll back.
    Justin

  • Problem with embeding the same view in dynamically created view container

    Hello Experts,
                  I am getiing a dump when i try to embed the same view inside the dynamically created view container of
    dynamically created tabs of a tabstrip
    The requirement go like this, i have 2 views in which i have have to embed the 2nd view to view1 where i have an empty
    tabstrip without tabs. During runtime i create tabs as well as view containers accordingly and then try to embed view2 in tabs.
    I have put the below mentioned code in HANDLEIN,
      DATA: lref_vcntlr  TYPE REF TO if_wd_view_controller,
            lref_comp    TYPE REF TO if_wd_component_usage,
            lv_embed_pos TYPE string.
      lref_vcntlr = wd_this->wd_get_api( ).
      lv_embed_pos = 'FILE_PERS_EDIT/VC_GENERAL'.
      TRY.
          CALL METHOD lref_vcntlr->do_dynamic_navigation
            EXPORTING
              source_window_name        = 'FILE_PERSISTENCE_WND'          " Window
              source_vusage_name        = 'FILE_PERS_EDIT_USAGE_1'       " Source View usage
              source_plug_name          = 'TO_EDIT_LAYOUT'                       " Outbound plug
              target_view_name          = 'PERS_EDIT_LAYOUT'                  " Second view to be embedded
              target_plug_name          = 'IN'                                                  " Second view inboun plug
              target_embedding_position = lv_embed_pos
            RECEIVING
              component_usage           = lref_comp.
        CATCH cx_wd_runtime_repository .
      ENDTRY.
      wd_this->fire_to_edit_layout_plg( ).
    This works fine for the first time.
    However onaction tab select i change the embeding position( 'FILE_PERS_EDIT/view container name of different tab') of the view2 an try to embed view2 in a different tab.
    At this point i get a dump stating View2 already present in the window 'FILE_PERSISTENCE_WND' of component.
    I think, the view2 embediing has to be removed before i add the view2 in a different tab
    Kindly let me know how to remove view2 embedding from tab1 before i add a view2 to a different tab or is there any other
    means to handle this problem?
    Thanks & Best Regards,
    Srini.

    Hello Srini,
    I found a solution to your problem, because I had a similar task.
    In WDDOINIT I changed the method do_dynamic_navigation to if_wd_navigation_services_new~prepare_dynamic_navigation:
    DATA:
        l_view_controller_api TYPE REF TO if_wd_view_controller.
      l_view_controller_api = wd_this->wd_get_api( ).
      TRY.
          CALL METHOD l_view_controller_api->if_wd_navigation_services_new~prepare_dynamic_navigation
            EXPORTING
              source_window_name        = 'WDW_MAIN'
              source_vusage_name        = 'VW_SUB_USAGE_1'
              source_plug_name          = 'TO_VW_CONTENT'
              target_component_name     = 'ZTEST_DYNAMIC'
              target_view_name          = 'VW_CONTENT'
              target_plug_name          = 'DEFAULT'
              target_embedding_position = 'VW_MAIN/VC_TAB.VW_SUB/TAB1_VC'
            RECEIVING
              repository_handle         = wd_this->g_rep_handle.
        CATCH cx_wd_runtime_repository .
      ENDTRY.
      wd_this->fire_to_vw_content_plg( param1 = 'TAB1' ).
    In the action I first deleted the navigation targets, then navigated to the empty-view and last I called my target view:
      DATA:
        lv_position           TYPE string,
        l_view_controller_api TYPE REF TO if_wd_view_controller,
        lr_view_usage         TYPE REF TO if_wd_rr_view_usage,
        lr_view_***_t         TYPE wdrr_vca_objects,
        lr_view_***           LIKE LINE OF lr_view_***_t.
      l_view_controller_api = wd_this->wd_get_api( ).
      lr_view_usage = wd_this->g_view->get_view_usage( ).
      lr_view_usage->delete_all_navigation_targets( plug_name = 'TO_VW_CONTENT' ).
      CLEAR lv_position.
      CONCATENATE 'VW_MAIN/VC_TAB.VW_SUB/' old_tab '_VC' INTO lv_position.
      TRY.
          l_view_controller_api->if_wd_navigation_services_new~do_dynamic_navigation(
          source_window_name = 'WDW_MAIN'
          source_vusage_name = 'VW_SUB_USAGE_1'
          source_plug_name   = 'TO_EMPTYVIEW'
          target_component_name = 'ZTEST_DYNAMIC'
          target_view_name   = 'EMPTYVIEW'
          target_plug_name   = 'DEFAULT'
          target_embedding_position = lv_position ).
        CATCH cx_wd_runtime_repository.
      ENDTRY.
      CLEAR lv_position.
      CONCATENATE 'VW_MAIN/VC_TAB.VW_SUB/' tab '_VC' INTO lv_position.
      TRY.
          wd_this->g_rep_handle = l_view_controller_api->if_wd_navigation_services_new~prepare_dynamic_navigation(
            source_window_name = 'WDW_MAIN'
            source_vusage_name = 'VW_SUB_USAGE_1'
            source_plug_name   = 'TO_VW_CONTENT'
            target_component_name = 'ZTEST_DYNAMIC'
            target_view_name   = 'VW_CONTENT'
            target_plug_name   = 'DEFAULT'
            target_embedding_position = lv_position ).
        CATCH cx_wd_runtime_repository.
      ENDTRY.
      wd_this->fire_to_vw_content_plg( param1 = tab ).
    Ann.: I my example, I had 3 views: VW_MAIN which embedds VW_SUB. VW_SUB has the tabs in it and VW_SUB embedds VW_CONTENT.
    BR,
    Roland

  • Is there a way to use a statically defined appearance stream in a dynamically created annotation?

    Hello,
    I want to create a document with cascading 'popups'.  Not the built-in text-only popup, but an annotation containing an appearance stream that defines text and images.  I'm currently using widget annotations based on a pushbutton field.
    Each page in my document has many citations that refer to other pages in the document.  When a user hovers over the citation, I want a 'popup' to appear containing a depiction of the destination.  However, as the destination will itself have citations, I also want the 'popup' to contain citations that the user can hover over, triggering another popup, etc.  In this way, a user could navigate throughout the document without leaving the page or even clicking the mouse.
    Obviously, with even a modest number of citations per page, pre-calculating and statically defining all of these widgets causes a combinatorial explosion, making the document sluggish and very large.
    Instead, I'd like to statically define appearance streams once per document, and then dynamically create annotations and assign the appropriate appearance stream using JS as the user navigates.
    So far I've created a named AP in the names dictionary, but I haven't been able to use it to dynamically set an appearance stream of a dynamically created widget annotation.
    Also, I've called Doc.getIcon(), passing in the named AP, which returns an Icon object.  However, after field.buttonSetIcon() and passing in the named AP, the button does not display the icon.
    Is there a way to use a statically defined appearance stream in a dynamically created annotation?
    Thank you,
    Dave

    Hi George, I've gotten named APs to work, and I expect hidden buttons will follow.  Thank you very much!
    Quick follow-up - I will have many documents embedded within the same pdf file, and some of these documents will contain identical popups.  However, I don't want to store identical icons in each document on account of file size.
    Instead, I'd like to store one instance of each icon for all documents in the file.
    Can I store all of the icons in a single document, and then access them by calling <DocName>.getField().getIcon() from any document in the file?
    Thank you again,
    Dave

  • Use of "DBA_OBJECTS" in "AFTER CREATE" Trigger

    Hi,
    We would like to store some extra information about our objects we have in the database. To do so we tought of the idea of creating a 'documenting' table containing an object_id that references to the object_id from the view dba_views.
    Now we want to automatically create a new record in our documenting table when a new object is created, in the first stage this should only contain the object_id
    To accomplish this we are using an 'AFTER CREATE' trigger, but when this trigger fires and the code searches for the new object_id in dba_objects, it does not return any records and generates an error. Likely because when the trigger is executed, the view is not yet updated?
    create or replace
    TRIGGER TRG_TEST
    AFTER CREATE ON SCOTT.SCHEMA
    DECLARE
    tmp VARCHAR2(50);
    BEGIN
    dbms_output.put_line(ora_dict_obj_name);
    select object_id
    into tmp
    from dba_objects
    where object_name = ora_dict_obj_name;
    dbms_output.put_line(tmp);
    END;
    Error report:
    ORA-04088: Fout bij uitvoering van trigger 'SCOTT.TRG_TEST'.
    ORA-01403: Geen gegevens gevonden.
    ORA-06512: in regel 6
    04088. 00000 - "error during execution of trigger '%s.%s'"
    *Cause:    A runtime error occurred during execution of a trigger.
    *Action:   Check the triggers which were involved in the operation.
    It's in dutch, so I'll have a go at translating:
    Error report:
    ORA-04088: Exception while executing trigger 'SCOTT.TRG_TEST'.
    ORA-01403: No data found
    ORA-06512: in rule 6
    04088. 00000 - "error during execution of trigger '%s.%s'"
    *Cause:    A runtime error occurred during execution of a trigger.
    *Action:   Check the triggers which were involved in the operation.
    Does anyone have an idea of how I can accomplish what I'm trying to do here.. Or maybe something I'm doing wrong?
    Thanks in advance!
    Davy

    What is "ora_dict_obj_name" defined as?
    Another option might be to setup a DBMS_SCHEDULER job to run the following insert
    firstly though, create the following table ;
    create document_table as (select * from dba_objects where rownum < 1)and then setup a DBMS_SCHEDULER job to run the following:
    begin
      insert into document_table
      (select dbo.*
       from   dba_objects    dbo
             ,document_Table dtb
       where  dbo.Object_ID = dtb.Object_ID(+)
       and    dtb.Object_ID is null);
       commit;
       exception
        when others then
          rollback;
          -- log a message somewhere with the error, i.e. SQLERRM
    end;
    /Note, I specified all columns, but you'll probably specify explicitly which column you require, in which case the CREATE table would change as well.
    Then you won't have a need for any trigger, and can better manage when you want your documentation to be updated.
    Another option might be to use COMMENT, which can be used on tables, views, materialized views, but won't cover all objects
    to the extent you might want.
    SQL> desc emp2
    Name                                                                                                  
    EMPNO                                                                                                 
    JOB                                                                                                   
    START_DATE                                                                                            
    SAL                                                                                                   
    DEPT                                                                                                  
    END_DATE                                                                                              
    SQL> comment on column emp2.sal is 'Existing Salary of employee as paid at most recent month end';

  • Need help with create trigger based on more then 1 table and join.

    Hello,
    Here i have 3 tables
    1. Employee
    PERSON_ID
    1
    1
    N
    NUMBER
    None
    ORG_ID
    2
    N
    NUMBER
    Frequency
    LOC_ID
    3
    N
    NUMBER
    Frequency
    JOB_ID
    4
    Y
    NUMBER
    Height Balanced
    FLSA_STATUS_ID
    5
    Y
    NUMBER
    Frequency
    FULL_NAME
    6
    N
    VARCHAR2 (250 Byte)
    Height Balanced
    FIRST_NAME
    7
    N
    VARCHAR2 (20 Byte)
    Height Balanced
    MIDDLE_NAME
    8
    Y
    VARCHAR2 (60 Byte)
    Height Balanced
    LAST_NAME
    9
    N
    VARCHAR2 (40 Byte)
    Height Balanced
    PREFERRED_NAME
    10
    Y
    VARCHAR2 (80 Byte)
    None
    EMAIL
    11
    Y
    VARCHAR2 (250 Byte)
    None
    MAILSTOP
    12
    Y
    VARCHAR2 (100 Byte)
    None
    HIRE_DATE
    13
    N
    DATE
    None
    2. ems_candidate
    EMS_CANDIDATE_ID
    1
    1
    N
    NUMBER
    None
    EMS_JOB_ID
    2
    Y
    NUMBER
    Frequency
    NAME
    3
    N
    VARCHAR2 (255 Byte)
    Frequency
    EMAIL
    4
    Y
    VARCHAR2 (255 Byte)
    None
    TELEPHONE
    5
    Y
    VARCHAR2 (25 Byte)
    None
    EMS_SOURCE_ID
    6
    Y
    NUMBER
    Frequency
    RECEIVED_DATE
    7
    Y
    DATE
    Frequency
    COMMENTS
    8
    Y
    VARCHAR2 (4000 Byte)
    None
    3. employee_resources
    EMP_RES_ID
    1
    1
    N
    NUMBER
    None
    PERSON_ID
    2
    Y
    NUMBER
    Height Balanced
    CANDIDATE_ID
    3
    Y
    NUMBER
    Frequency
    EMP_START_DATE
    4
    Y
    DATE
    None
    CUSTOM_RESOURCE_FLAG
    5
    Y
    NUMBER (1)
    None
    RESOURCE_GROUP_ID
    6
    N
    NUMBER
    Frequency
    RESOURCE_STATUS_ID
    7
    N
    NUMBER
    Frequency
    GROUP_LOC_ID
    8
    N
    NUMBER
    Height Balanced
    ASSIGNED_JIRA
    9
    Y
    VARCHAR2 (250 Byte)
    None
    REVOKED_JIRA
    10
    Y
    VARCHAR2 (250 Byte)
    None
    CREATED_DATE
    11
    Y
    DATE
    SYSDATE
    None
    UPDATED_DATE
    12
    Y
    DATE
    None
    Now i want to create trigger when new record get inserted in employee table wanted to update person_id in employee_resources table.
    So i want to match ems_candidate.name with employee.full_name , ems_candidate.ems_job_id with employee.ems_job_id. And if it matched then update person_id in employee_resources table else through an exception and insert record in temp table.
    If anybody has an idea can u please help me.
    Thanks,
    Gayatri.

    I created below trigger
    CREATE TRIGGER emp_resources_upd_person_id
    AFTER INSERT ON ems.employee
    FOR EACH ROW
    BEGIN
        UPDATE ems.employee_resources
           SET person_id = :new.person_id
         WHERE candidate_id = (SELECT ems_candidate_id  
                                 FROM ems.ems_candidate cand, ems.employee emp
                                WHERE TRIM(UPPER(emp.first_name)) = TRIM(UPPER(SUBSTR (cand.name, 1, INSTR (cand.name, ' ') - 1)))
                                  AND TRIM(UPPER(emp.last_name)) = TRIM(UPPER(SUBSTR (cand.name,INSTR (cand.name, ' ') + 1,DECODE (INSTR (SUBSTR (cand.name, INSTR (cand.name, ' ') + 1), ' '),0,LENGTH (cand.name),(INSTR (SUBSTR (cand.name, INSTR (cand.name, ' ') + 1), ' ') - 1)))))
                                  AND emp.person_id = :new.person_id);
    EXCEPTION
      WHEN OTHERS THEN
        INSERT INTO ems.update_person_id_exception(person_id,first_name,last_name,full_name) VALUES(:new.person_id,:new.first_name,:new.last_name,:new.full_name);
    END;
    Now when i am trying to insert row in ems.employee  table it gives me an error
    ORA-04091
    table string.string is mutating, trigger/function may not see it
    Cause: A trigger (or a user defined plsql function that is referenced in this statement) attempted to look at (or modify) a table that was in the middle of being modified by the statement which fired it.
    Action: Rewrite the trigger (or function) so it does not read that table.
    Can anybody please help me to come out from these error.
    Thanks,
    Gayatri.

  • How to get the co-ordinates of a dynamically created input field

    Hello Frn's
    i have created a dynamic text view . but this text view is not appearing at proper position . I want palce it infront of a dynamically created input field . how can i do this ?
    as i am thinking ...i should first of all  get info about the co-ordinates of   dynamaclly creatd input field . and with respect to these co-ordinates ...set the position of  text View .
    Please suggest  your thoughts .
    Thanks and Regards
    Priyank Dixit

    Hi,
    There is no provision in WD for getting screen coordinates and then placing the UI element.
    You to add the UI element to layout editor and based on the layout type it will add the UI element to respective position.
    I would advice not to create dynamic UI elements( instead you can create them statically and then play with visibility status through context binding ). This will be more effective way and less error prone. This is also recommended practice.
    still,For dynamic creation you can refer to following wiki:
    http://wiki.sdn.sap.com/wiki/display/WDABAP/CreatingUIElementsDynamicallyinAbapWebdynpro+Application
    regards
    Manas Dua

  • How dynamically create connection pool and Datasource

    Hi
    How I can dynamically create a connection pool and Data source in Oracle 10g Application server. In our J2EE application the user will be login with db user name, password and database name. I want to create connection pool and data source on the fly while login the user with database name. I our application we have access approximate 80 Databases. so my approach is given bellow
    1) Planning to create 80 connection pools and 80 Data sources so when user logs in while selecting the db name i will call the appropriate data source and create the DB connection. Is there any limitation to create number of data sources in oracle app server?
    2) Create DB connection with out using connection pool and data source. But i am not prefer this approach coz we need to handle some transaction in our application.
    Kindly throw some light on managing connection pool programmatically or in application run time.
    I would really appreciate if any one can provide any links or any inormation on this issue.
    Thanks in advance.

    Kindly let me know is there any drawbacks to create 80 Data Sources to connect 80 database in Oracle 10G App server and each data sources should have one connection pool. so i need to create 80 connection pool. Please let me know is this right approach or any work around to create Data source on fly for each request for corresponding database.

  • Please trace what is wrong in TRIGGER script , doesnt create trigger.

    Hi Oracle Gurus,
    Please help me, in finding what is wrong in trigger statement. It doesn not create trigger, instead it displays line numbers..like 1 2 3 4 ....after pressing the enter key,
    I am attaching the full script, where it alters table, then creates new table, the creates sequence..lastly it fails in creating the trigger.
    ==================================================================================
    SQL> ALTER TABLE MOBILE.MOBILE_USER ADD (LAST_LOGIN TIMESTAMP);
    Table altered.
    SQL> CREATE TABLE "MOBILE"."AUDIT_LOG"
    2 3 "AUDIT_LOG_ID" NUMBER(16,0) NOT NULL ENABLE,
    4 "DATE_CREATED" TIMESTAMP (6) NOT NULL ENABLE,
    5 "AUDIT_TYPE" VARCHAR2(20 BYTE) NOT NULL ENABLE,
    6 "AUDIT_DATA" CLOB,
    7 CONSTRAINT "AUDIT_LOG_PK" PRIMARY KEY ("AUDIT_LOG_ID") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "SERVICES_DATA" ENABLE
    8 )
    9 PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING STORAGE
    INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT
    10 11 12 )
    TABLESPACE "SERVICES_DATA" LOB
    13 14 (
    15 "AUDIT_DATA"
    16 )
    17 STORE AS
    18 (
    19 TABLESPACE "SERVICES_DATA" ENABLE STORAGE IN ROW CHUNK 8192 PCTVERSION 10 NOCACHE LOGGING STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
    20 ) ;
    Table created.
    SQL> CREATE SEQUENCE "MOBILE"."AUDIT_LOG_SEQ" INCREMENT BY 1 START WITH 1000 CACHE 20 NOCYCLE ;
    Sequence created.
    SQL> create or replace
    TRIGGER "MOBILE"."AUDIT_LOG_TRGR" before
    INSERT ON "AUDIT_LOG" FOR EACH row BEGIN IF inserting THEN IF :NEW."AUDIT_LOG_ID" IS NULL THEN
    SELECT AUDIT_LOG_SEQ.nextval
    INTO :NEW."AUDIT_LOG_ID"
    FROM dual;
    END IF;
    END IF;
    END;

    Ok great..but it gives the same error, we have already checked that AUDIT_LOG does exist.
    Is it checking something else..or it shoud be INSERT INTO instead of INSERT ON.
    Please help.
    create or replace
    TRIGGER "MOBILE"."AUDIT_LOG_TRGR" before
    INSERT ON "AUDIT_LOG" FOR EACH row BEGIN IF inserting THEN IF :NEW."AUDIT_LOG_ID" IS NULL THEN
    SELECT AUDIT_LOG_SEQ.nextval
    INTO :NEW."AUDIT_LOG_ID"
    FROM dual;
    END IF;
    END IF;
    END; /
    INSERT ON "AUDIT_LOG" FOR EACH row BEGIN IF inserting THEN IF :NEW."AUDIT_LOG_ID" IS NULL THEN
    ERROR at line 3:
    ORA-00942: table or view does not exist

  • Create trigger on view belong to different schema of same db

    Hi Guru's,
    I have two different schema in the same DB.
    Example : schema1 and schema2
    I have one view on schema1 and i have grant select to schema2 and create synonym for that view.
    Now i need to create trigger on synonym which created from view in schema1 and insert the data into different table from trigger when insert happen on view.
    first of all , is it possible?
    if its possible then do i need to give create any trigger on view to schema2.
    Or is there any other we can get this done..
    Many thanks.

    Hi,
    user590978 wrote:
    Hi Guru's,
    I have two different schema in the same DB.
    Example : schema1 and schema2
    I have one view on schema1 and i have grant select to schema2 and create synonym for that view.
    Now i need to create trigger on synonym I'm not sure I understand you.
    Triggers operate on tables and views (but I'll just say "table" from now on). It doesn't matter if the statement that caused the trigger to fire used the actual table name or a synonym.
    which created from view in schema1 and insert the data into different table from trigger when insert happen on view.
    first of all , is it possible?I'm not sure I understand you here, either.
    It is possible to have a trigger on a view in schema1, which INSERTs data into a table. That table can be in any schema, just so long as the trigger owner has privilges on INSERT into it.
    if its possible then do i need to give create any trigger on view to schema2.It's very dangerous, and usually a terrible idea, to grant the CREATE ANY privileges to users.
    Schema2 needs the CREATE ANY TRIGGER system privilege only to create a trigger in another schema, such as schema1. There's probably no reason to do that. Let schmea1 create the objects in its own schema.
    Post a test script that shows what you want to do. Include CREATE TABLE, CREATE VIEW, CREATE TRIGGER, CONNECT and INSERT statements, and the results you want (the contents of tables where the trigger INSERTed data). If you don't know how to code something, post the closest thing you can, and explain what you really want to do in that place.

  • Getting error while creating trigger!!

    Hi Guys,
    I am getting the following error while creating trigger in Oracle10g Database in TOAD environment.
    Error: PLS-00306: wrong number or types of arguments in call to '='
    Table details:
    One of the column having BLOB Data type in the table.
    In the trigger, I have compared :old and :new values.
    CREATE OR REPLACE TRIGGER INPL.trigger_new
    AFTER INSERT OR UPDATE OR DELETE
    ON TABLE_NEW REFERENCING NEW AS NEW OLD AS OLD
    FOR EACH ROW
    DECLARE
    action_flag VARCHAR2(1);
    new_image BLOB;
    BEGIN
    IF UPDATING
    THEN
    action_flag := 'U';
    ELSIF DELETING
    THEN
    action_flag := 'D';
    ELSIF INSERTING
    THEN
    action_flag := 'I';
    END IF;
    IF (:NEW.image = :OLD.image)
    THEN
    new_image := '';
    ELSE
    new_image := :NEW.image;
    END IF;
    INSERT INTO TABLE_NEW(action_flag, date_changed,nimage,oimage) values(new_image,:old.image);
    end;
    Any one knows about this issue, please let me know with the proper solution.
    Thanks for your immediate response!
    Regards,
    Lakshman

    CREATE OR REPLACE TRIGGER INPL.trigger_new
    AFTER INSERT OR UPDATE OR DELETE
    ON TABLE_NEW REFERENCING NEW AS NEW OLD AS OLD
    FOR EACH ROW
    DECLARE
    action_flag VARCHAR2(1);
    new_image BLOB;
    BEGIN
    IF UPDATING
    THEN
    action_flag := 'U';
    ELSIF DELETING
    THEN
    action_flag := 'D';
    ELSIF INSERTING
    THEN
    action_flag := 'I';
    END IF;
    IF (:NEW.image = :OLD.image)
    THEN
    new_image := '';
    ELSE
    new_image := :NEW.image;
    END IF;
    INSERT INTO TABLE_AUD(action_flag, date_changed,nimage,oimage) values(new_image,:old.image);
    end;
    I am getting the error in line at If condition
    Error: PLS-00306: Wrong number or tpyes of arguments in call '='
    Please let me know if any one knows exact solution!
    Thanks in advance!
    Regards,
    Lakshman

Maybe you are looking for

  • Unable to install NVIDIA drivers on Windows 8 (Boot Camp)

    I'm running Windows 8 on a secondary partition on my MacBook Pro (17-inch, 2009). I have, in the past, been able to successfully install Windows 8 on a second partition on this mac and get everything working, including all of my device drivers. I had

  • Is the Zen Touch Mac Compatib

    My Cousin has an iMac and i'm visiting him and I was wondering if I could transfer tunes from his computer to my Zen Touch. Also, is the zen touch like the ipod where it will only support syncing with one computer. Where it makes you delete everythin

  • Error in Class not found

    When i try to connect SQl 2000 database using JDBC, it gives an error indicating "java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver" I alredy set the CLASSPATH correctly & my JDBC driver also installed into my computer. P

  • Viewer&browser window problem in Aperture 2.1 i see half...!

    Hello everyone! I have just bought aperture 2.1 and as at the beginning everything was ok, after i dont know waht, i had problem with the browser and also the viewer screen! It previews the photos not in center of the viewer but at the right! Also in

  • Can I run applications from an external hard drive

    Hi I am a sort a new Mac user and I would like to run Lightroom from an external drive. Is this possible on a Mac? Thanks!