src-db/database/model/triggers/AD_ALERTRECIPIENT_TRG.xml
author Juan Pablo Aroztegi <juanpablo.aroztegi@openbravo.com>
Mon, 28 Apr 2008 09:28:08 +0000
changeset 785 8dba91261590
parent 756 ae11e4610537
child 2078 cf88ca44cdd2
permissions -rw-r--r--
Fix last update of copyright years in database files
adrian@94
     1
<?xml version="1.0"?>
adrian@94
     2
  <database name="TRIGGER AD_ALERTRECIPIENT_TRG">
adrian@94
     3
    <trigger name="AD_ALERTRECIPIENT_TRG" table="AD_ALERTRECIPIENT" fires="after" insert="true" update="true" delete="true" foreach="row">
gorkaion@239
     4
      <body><![CDATA[
gorkaion@239
     5
adrian@170
     6
adrian@94
     7
adrian@94
     8
adrian@94
     9
    /*************************************************************************
adrian@94
    10
    * The contents of this file are subject to the Openbravo  Public  License
adrian@94
    11
    * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
adrian@94
    12
    * Version 1.1  with a permitted attribution clause; you may not  use this
adrian@94
    13
    * file except in compliance with the License. You  may  obtain  a copy of
adrian@94
    14
    * the License at http://www.openbravo.com/legal/license.html
adrian@94
    15
    * Software distributed under the License  is  distributed  on  an "AS IS"
adrian@94
    16
    * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
adrian@94
    17
    * License for the specific  language  governing  rights  and  limitations
adrian@94
    18
    * under the License.
adrian@94
    19
    * The Original Code is Openbravo ERP.
adrian@94
    20
    * The Initial Developer of the Original Code is Openbravo SL
adrian@94
    21
    * All portions are Copyright (C) 2001-2006 Openbravo SL
adrian@94
    22
    * All Rights Reserved.
adrian@94
    23
    * Contributor(s):  ______________________________________.
adrian@94
    24
    ************************************************************************/
antonio@735
    25
      n NUMBER;
adrian@94
    26
    BEGIN
adrian@94
    27
adrian@94
    28
   IF INSERTING or UPDATING THEN
adrian@94
    29
     select count(*)
adrian@94
    30
       into n
adrian@94
    31
       from ad_user_roles
adrian@94
    32
      where ad_user_id = :new.ad_user_id
adrian@94
    33
        and ad_role_id = :new.ad_role_id;
adrian@94
    34
     IF :new.AD_USER_ID is not null and n=0 then
adrian@94
    35
       RAISE_APPLICATION_ERROR(-20515, 'User not in role') ;
adrian@94
    36
     end if;
adrian@94
    37
   END IF;
antonio@735
    38
END AD_ALERTRECIPIENT_TRG
gorkaion@239
    39
]]></body>
adrian@94
    40
    </trigger>
adrian@94
    41
  </database>