Business Rule in trigger not working

Hi,
I have business rule that no one below 18 years should be employed in this system.
I have created a trigger that alerts me so, but when ever I insert someone either over 10 or below, it fires and deos not insert any record, but if I deleted the trigger, everything works fine.
I should have put a check constraint (s_hire_date - s_dob) < 6570 on the table, but I just thought should be able to do it.
Why please?
stops insertion of under 18 years into employee table
CREATE OR REPLACE TRIGGER Tr_new_employee
BEFORE INSERT ON employee for each row
DECLARE s_hire_date DATE;
s_dob date;
begin
select :NEW.hire_date, :NEW.dob into s_hire_date, s_dob from employee
where empid =:new.empid;
IF (s_hire_date - s_dob) < 6570 then
raise_application_error(-20101,'Person too young');
end if;
end;
Many thanks in advance
cube60

Hello Warren and All,
Thanks for the code, the trigger did compile successfully, but prevents any kind of insertion whether over 18 or younger.
SQL> CREATE OR REPLACE TRIGGER Tr_new_employee
2 BEFORE INSERT ON employee for each row
3 DECLARE s_hire_date DATE;
4 s_dob date;
5 begin
6
7 select :NEW.hire_date, :NEW.dob into s_hire_date, s_dob from employee
8 where empid =:new.empid;
9
10 IF TRUNC(months_between(s_hire_date,s_dob)/12) < 18 then
11 raise_application_error(-20101,'Person too young');
12 end if;
13 end;
14 /
Trigger created.
SQL> COMMIT;
Commit complete.
SQL> --under 18 to time of hire_date
SQL> EXEC NEW_EMPLOYEE('CHARLES','DICKSON','M','29-JAN-1992','PT2','','','','',sysdate,NULL,09890111
,'HSBC','WANDSWORTH','CURRENT','PR3');
BEGIN NEW_EMPLOYEE('CHARLES','DICKSON','M','29-JAN-1992','PT2','','','','',sysdate,NULL,09890111,'HS
ERROR at line 1:
ORA-01403: no data found
ORA-01403: no data found
ORA-06512: at "SYSTEM.TR_NEW_EMPLOYEE", line 5
ORA-04088: error during execution of trigger 'SYSTEM.TR_NEW_EMPLOYEE'
ORA-06512: at "SYSTEM.NEW_EMPLOYEE", line 26
ORA-06512: at line 1
SQL> COMMIT;
Commit complete.
SQL> --over 18
SQL> EXEC NEW_EMPLOYEE('WARREN','TALENTINO','M','29-JAN-1975','HOURLY','','','','','18-FEB-2001',NUL
L,36901212,'BARCLAYS','SYDENHAM','CURRENT','TEMP7');
BEGIN NEW_EMPLOYEE('WARREN','TALENTINO','M','29-JAN-1975','HOURLY','','','','','18-FEB-2001',NULL,36
ERROR at line 1:
ORA-01403: no data found
ORA-01403: no data found
ORA-06512: at "SYSTEM.TR_NEW_EMPLOYEE", line 5
ORA-04088: error during execution of trigger 'SYSTEM.TR_NEW_EMPLOYEE'
ORA-06512: at "SYSTEM.NEW_EMPLOYEE", line 26
ORA-06512: at line 1
I know your logic is fine, something might be wrong with the trigger even though it created succesfully. It is not doing what it is intended to do.
Many thanks
cube60

Similar Messages

  • While i am creating my business rule i am not able to connect the planning

    while i am creating my business rule i am not able to connect the planning application and database?I dont know what is the reason?

    Make sure you log into the planning application before logging into EAS.
    Cheers
    John
    http://john-goodwin.blogspot.com/

  • Business rule XML facts not visible soa  11.1.1.6.0

    Hello experts,
    Here comes the description of steps:
    When dragging a business rule with input and output facts defined(xsd:complexType), in bpel 2 process, in the edit rule dialog box:
    click on either of the assign input & output tabs to add a copy rule,
    in the decision fact map dialog box:
    the type is business rules facts in the drop down menu.
    Here the business rules variables are not shown.
    Having read the following older posts:
    Empty Business Rule Facts while assigning input/output facts
    SOA Jdev app - Bpel Business Rule - Assign Input Facts issue
    still, I do not see any solution or workaround offered.
    Any helping hand?
    TIA!
    Edited by: NickAiva on Oct 13, 2012 10:41 AM
    Edited by: NickAiva on Oct 15, 2012 3:16 PM

    Hi SK,
    I think, you have permissions issue. May be you are not able to write to C:\JDeveloper\mywork\MarkViewSerialApprovalApplication\MarkViewSerialApproval\oracle\rules
    Regards
    Borys

  • Succesfactors - Business Rule to trigger workflow (not triggering)

    Hi,
    I have used Business Rules and linked them to Base Objects to default values before and this worked just fine.
    Now I am trying to trigger a workflow from the moment a save is performed in the specific portlet.
    The rule is kicked off (I tested with defaulting a value and that worked correctly) but I don't get the notification that a workflow is started.
    This is how I configured my rule:
    The SF documentation talks a lot about using the pre-defined functions, but there is no real example for triggering workflows.
    I'm probably missing something... any suggestions?
    Already thanks in advance for your suggestions!
    Cheers,
    Gerrit

    Hi Sharma,
              There may be many reasons if the mail is not delivered from SAP .
    1. First Check with the transaction SCOT ( and SOST )
       This will tell you whether SMTP Configured is working fine or not.
       If there are pending ( Waiting ) items in SCOT , then it is not WF isssue ...it's related SMTP .
    2. You can very well test the SAP system for mails by sending a sample mail to your email id from SBWP
    3. If SCOT is working then you call drill down your analysis to application specific things i.e WOrkflow
    Hope this helps ur analysis
    Regards,
    Vijay

  • Multiple row update; CEV business rule parameters are not refreshed

    During a multiple row update, a business rule is fired for each row.
    This change event business rule must update the value of another column in the same table (and same row).
    Unfortunately, the parameters of the BR are keeping the values of the first row that has been checked. Since my parameter p_id always keeps the same value, I always update the same row.
    Does somebody have a hint on how to solve this problem ?
    I'm using Headstart R6i and Forms6i with Oracle9i DB.
    Thanks in advance for your help,
    Denis.

    I think that's how it works. I tried that with a variable where type is Members.
    It is not showing me a prompt when i select multiple rows. However works only for first row. (even if the menu is initiated from second row).
    Multiple rows selected, variable type is members. works only for first row in selection. (in 11.1.2.2) You can try log an SR and see what Oracle has to say.
    Regards
    Celvin
    http://www.orahyplabs.com

  • Business Rule Repository has not been configured?

    Hi,
    In EAS trying to open Business Rules, I get "Repository has not been configured or you are not authorized to use Business Rules" (I get this with the admin creds)
    In details, "Error loading objects from Data Source", "SQLSyntaxExceptionError: ORA-00942 table or view does not exist"
    This is relatively new Production install running v. 11.1.2.1
    I ran into this after my LCM migration of a Planning app failed, unable to create business rules.
    IT folks tell me "the database looks fine" when I asked them about the ORA-00942 table.
    Can anyone help point me to a configuration step that might have been missed?
    Everything works in development environment, so if there's something to compare between the two, I'd appreciate any help.
    Thanks,

    Its necessary to do the following
    SE80 -> BSP Application -> Tunguska -> Pages with Flow Logic -> start_sts.htm   or  start_sts2.htm-> Right click & display in same window -> Properties tab -> Transfer Options -> HTTPS should be UNCHECKED.

  • Business rules config does not save to UJP_ELIM and UJP_ELIMH

    Hi folks,
    I completed the configuration of currency translation and the calculation of ultimate ownership in a consolidation application that I am building in BPC 7.5.  I then started to work on the business rules for Consolidation.  These are my findings:
    The first field is called Adjustment ID  on the screen (but it is actually Elim ID in the Elim table and ElimH tables). 
    When I populate this field and save, I get an error message saying "Input rule data does not match the rule name ELIMH.
    When I populate all the fields on the Auto adj defn screen and try to save or try to validate, I get the same error.
    Nothing gets saved to the tables and Both the Elim and Elimh tables have no values in them.
    In 7.0 NW, when I created a new adjustment id and saved, it automatically went and saved it to the database and this was the same in 5.1 as well.
    What am I missing?
    Would very much appreciate any light that you can shed on this.
    Thank you
    Tara Sitaram

    Hi Tara,
    Can you check that your BPC ABAP, BPC .net Server and BPC client are the same service pack?
    Thanks,
    John

  • Account Assignment Trigger not Working

    I'm working on Siebel Assignment Manager.. first I try to Assign Service Request to an Employee and in two Assignment mode (Batch and Dynamic) and it's work fine.
    but when I try to assign Account to a Position, and I follow the same steps I followed before, the monitor work and the owner change depending on the Score and the Rule not working ...on the other hand the trigger (Dynamic) not working at all, and there is no change
    I have searched to know where is the problem …and didn’t find solution
    please help me ASAP
    Thanks & Regards,
    Enas

    Hi Glenn,
    Thanks for u r replay.
    We are using our own ZVIEWS. We have copied the Bupasearch view and we done some modifications according to our requirement.(added DOB field)
    We got DOB in our Zview. But Customer search functionality is not working.
    Plz help me to solve the issue.
    Thanks,
    Sreedhar

  • Format Trigger not working in 10g Report.

    I have a report with two eclipses
    (*) Debit (*) Credit . Please note that the two asterics denotes eclipses.
    I have a format triggers on these eclipses based on the database item Debit_credit.
    IF :debit_credit = 'CREDIT' THEN
    RETURN FALSE;
    ELSE
    RETURN TRUE;
    End if;
    and vis-visa. However the format trigger is not working. Regardless of the value of
    debit_credit. I even created a frame around these eclipses and put my format trigger all to no avail. Please help.

    Create a boilerplate text in your repeating frame (get rid of the field :debit_credit from your layout, but leave it in your query). I created the boilerplate field B_1. My format trigger looks like:
    function B_1FormatTrigger return boolean is
    begin
      if upper(:debit_credit) = 'CREDIT' then
           srw.set_field(0, to_char('(*) CREDIT'));
       else srw.set_field(0, to_char('(*) DEBIT'));
      end if;
      return (TRUE);
    end;I hope I understood your question OK...I am not sure what an eclipses is?

  • "Old" update rule from ODS not working

    Hi Gurus,
    I need to set up the "old" fashioned update rule to load data from an ODS1 to another ODS2.
    The thing is that I need to set up an update rule because I need to implement a Return Table Routine that is not supported (as far as I know) by the new Transformation/DTP.
    When I select option (through the right mouse click over ODS1)  "Other Options" - "Create Update Rule" it takes me out of the RSA1 and leaves me in the main menu making it impossible to create a new update rule.
    The strange thing is that I have this working from and ODS to an InfoCube.....
    Suggestions, a workaround??
    Andrea.

    Hi Jerry,
    Just to confirm that this is not working. The tys_TG_1 structure only shows me the target infoprovider structure. Check that in the how to, to be able to derive employee first you need to assign eache source_filed to the result_field leaving employee blank.
    I need to have in the same place, the source_field structure (source infoprovider field structure) and the result_field structure (target infoprovider structure). That is what the "old" return table gives me as in the same place I can have the communication_structure (source infoprovider field structure) with the return_table structure (target infoprovider structure). 
    Just to understand, in the source infoprovider I have 12 Key Figures (1 for each period) and I have to split each incoming record to 12 records. If I work only with the result_field structure tys_TG_1 and the result_package tyt_TG_1 I'm not able the see those 12 KF.
    So... return table functionality is not fully supported by BW 7 as far as I know.
    Any other ideas why I'm not able to create the old Update Rules from an ODS?
    Regards,
    Andrea.

  • After Logon on Database Trigger Not Working From Client Terminal

    Hi Every One
    I Have a Problem, I'am Using Oracle 10g R2, I'd Written After Logon on Database Trigger, I'd Written The Trigger Under The Under The User With DBA Privileges, and it is work Fine, but it is work only when i Logon On The Database from The Server Terminal with any user, and If Logon From any Other Terminal It Is Not Work,
    Can any One Know The Reason, Please Help me
    Yasser Mokhtar

    Please post the trigger code.

  • Changes to business rules in EAS not reflecting in planning

    Hi Friends,
    One of my client is facing the issue issue.Could anyone help on the issue.
    When a new business rule is created or changed in EAS, the changes are not reflected in Planning. A stop and restart of the service is required to see the new business rule or a change to a calculation.
    This is a consistent error we are having in development.
    Thanks in advance.
    Regards.

    Hi,
    First I would check to see if any patches relate to the issue you are having.
    I would then log the issue with Oracle to see if they can help any further and it could be a bug.
    It sounds like the cache may not be getting updated so planning doesn't see any changes, restarting clears the cache and objects are read directly from the database tables so you can the changes, that is just a guess though.
    Cheers
    John
    http://john-goodwin.blogspot.com/

  • Oracle Form Services Installation (Test.fmx) Trigger Not working

    Hi
    I install oracle BI and forms Services on oracle application infrastructure after installation i run the following command "http://ora.server.com:7778/forms/frmservlet?config=testfrm" it will show the form "form services install sucessfully" but when i do a certain cusmization on it i.e. put a one text box on that text put put a key_next tigger in which i show a alert message only. After Customization i run a same URL it will again show that form with the changes but the trigger (Key_next) will not fire
    I don't understatnd why tigger is not working or fire.

    So we understand things correctly,
    You are running a form and a trigger won't fire. What kind of trigger? A when-button-pressed, or a key-next-item, or something else? I don't believe key_next is a valid trigger.
    If you are using a key trigger, you need to make sure that the keys are mapped as you expect. You can see how the keys are mapped in the menu under Help => Keys when you run the form. Make sure the button is mapped like you expect. Additionally, you can modify the mapping by updating the resource file, but that's kind of outside the scope of this...
    This type of questions really is suited for the Forms forum under Developer Tools => Forms at: Forms
    If you need more help, post there. The focus of that section if Forms.

  • Trigger not working as expected

    create or replace trigger EMP_B4
      before insert on SCOTT.EMP 
      for each row
      when (NEW.SAL IS NULL)
    declare
      -- local variables here
      i NUMBER;
    begin
      :NEW.SAL := 22222;
    end EMP_B4;Hi,
    The trigger is not working; when an entry inserted with SAL null, I should see the salary set to default 22222. But sometimes, it dont work and SAL remains as NULL.
    Anyone encountered similar case before?
    Message was edited by:
    [email protected]

    Hi,
    Here is what i have done. I have used your trigger as;
    SQL> create or replace trigger EMP_B4
    2 before insert on SCOTT.EMP
    3 for each row
    4 when (NEW.SAL IS NULL)
    5 declare
    6 -- local variables here
    7 i NUMBER;
    8 begin
    9 :NEW.SAL := 22222;
    10* end EMP_B4;
    11 /
    Trigger created.
    SQL> insert into emp (empno,deptno) values (111,10);
    1 row created.
    SQL> select * from emp;
    EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
    7369 SMITH CLERK 7902 17-DEC-80 800 20
    7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
    7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
    7566 JONES MANAGER 7839 02-APR-81 2975 20
    7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
    7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
    7782 CLARK MANAGER 7839 09-JUN-81 2450 10
    7788 SCOTT ANALYST 7566 19-APR-87 3000 20
    7839 KING PRESIDENT 17-NOV-81 5000 10
    7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30
    7876 ADAMS CLERK 7788 23-MAY-87 1100 20
    EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
    7900 JAMES CLERK 7698 03-DEC-81 950 30
    7902 FORD ANALYST 7566 03-DEC-81 3000 20
    7934 MILLER CLERK 7782 23-JAN-82 1300 10
    111 22222 10
    211 yogesh analyst 7369 12-DEC-05 22222 10 20
    SQL> insert into emp values (211,'yogesh','analyst',7369,'12-dec-2005','',10,20);
    1 row created.
    SQL> select * from emp;
    EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
    7369 SMITH CLERK 7902 17-DEC-80 800 20
    7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
    7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
    7566 JONES MANAGER 7839 02-APR-81 2975 20
    7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
    7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
    7782 CLARK MANAGER 7839 09-JUN-81 2450 10
    7788 SCOTT ANALYST 7566 19-APR-87 3000 20
    7839 KING PRESIDENT 17-NOV-81 5000 10
    7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30
    7876 ADAMS CLERK 7788 23-MAY-87 1100 20
    EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
    7900 JAMES CLERK 7698 03-DEC-81 950 30
    7902 FORD ANALYST 7566 03-DEC-81 3000 20
    7934 MILLER CLERK 7782 23-JAN-82 1300 10
    111 22222 10
    211 yogesh analyst 7369 12-DEC-05 22222 10 20
    See, again it's working fine. Can you give a case where your trigger has not workrd properly.

  • Condition in Approval Procedure Rule in ChaRM not working properly

    Hi experts,
    We are on 7.1 SP8.
    We have Z-partners defined and included those in the Approval Procedure too. In order to fill the approval procedure steps with the default partner, we defined a rule policy.
    For example step ZMCR000001 needs to be filled with BPE by default.
    This works fine.
    But when we want to overwrite the default value with another value, the default is always put back over the manual entered value.
    Also manually added process steps get that same value.
    It looks as if the last step of the condition is not working properly (i.e. the check to see if the approver is already filled).
    Can somebody tell me how we can get manually entered values in there?

    Hi ,
    You can play with User status, add to condition in which user status you dont wont this to be triggered.
    Example add "And User status equal ZMCR Created":
    On staus created you get automatic approval determination with default partner ID's
    Now on Validation the rule will not be triggered and your manually added values saved as is.
    Rg Dan.

Maybe you are looking for

  • Append excel sheet data to sharepoint list

    HI, I have an excel sheet and i have publshed this list on sharepoint 2010. Now i want to append some more records to the same list on sharepoint. So is it possible in sharepoint? Please help to solve the issue. Thanks & Regards Rajni

  • Capture cost of procured materials in a third party sales order scenario

    Dear Experts, I'm developing a third party sales order solution to my company following the recommended third party scenario by SAP. Everything is working fine from creation of sales order, automatic creation of purchase requisition, create purchase

  • Is it possible to upload an album from my iPod to iTunes?

    Is it possible to upload an album from my iPod to iTunes?

  • Some system settings not retained after restart

    In Snow Leopard, after a restart, the sound volume setting defaults to 50% and some Finder window views settings change (icon view becomes list view) or a cleaned up window reverts to jammed up icons. Additionally, iTunes always asks to allow incomin

  • Fx5900xt not working

    I had this problem from the start, just haven't gotten around to fix it yet... Could someone help me? In windows i can do whatever i want, and it doesn't hang. As soon as i start any type of game it crashes, either to the desktop or completely. It ca