Use of "DBA_OBJECTS" in 'CREATE AFTER' Trigger

Hello

We want to store additional information about our items, we have in the database. Do we tought of the idea of creating a "documentation" table containing an object_id that references to the object_id of the dba_views view.

Now we want to create a new record automatically in our table documenting when a new object is created, as a first step it should contain only the object_id
To do this, we use a "AFTER CREATING" trigger, but when this trigger is enabled and if the code finds the new object_id in dba_objects, he returned no records and generates an error. Probably because when the trigger is run, the display is not yet updated?

create or replace
TRG_TEST RELAXATION
AFTER CREATE ON SCOTT. SCHEMA
DECLARE
tmp VARCHAR2 (50);
BEGIN
dbms_output.put_line (ora_dict_obj_name);

Select object_id
in tmp
from dba_objects
where object_name = ora_dict_obj_name;

dbms_output.put_line (tmp);
END;

Error report:
ORA-04088: doing bij uitvoering van trigger ' SCOTT. TRG_TEST'.
ORA-01403: Geen gegevens anyway.
ORA-06512: in regel 6
04088 00000 - "error during execution of trigger '% s.%s '.
* Cause: An error occurred during the execution of a trigger.
* Action: Check the triggers that participated in the operation.

It's in Dutch, so I'll have a go at translating:

Error report:
ORA-04088: Exception when 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: An error occurred during the execution of a trigger.
* Action: Check the triggers that participated in the operation.

Does anyone have an idea how I can accomplish what I am trying to do here... Or maybe something I am doing wrong?

Thanks in advance!
Davy

Hello

Instead of select it in your trigger, you may submit a job, what does it for you. This work would not go until your table is created.

Concerning
Peter

Tags: Database

Similar Questions

  • Create a trigger that send mail with attachment after insertion of a line in Oracle APEX

    I want to create an insert after trigger on a table that is to send a mail with an attachment. Here is my code.

    CREATE OR REPLACE TRIGGER tr_feedback

    AFTER INSERT on REVIEWS

    FOR EACH LINE

    DECLARE

    l_id NUMBER;

    BEGIN

    l_id: = APEX_MAIL. SEND)

                    p_to        => ' [email protected] ',

    P_FROM = >: NEW. E-mail

    p_subj = >: NEW. Object

    p_body = > "Please see the attachment."

    p_body_html = > ' review of < b > please < /b > the attachment ")

    APEX_MAIL. ADD_ATTACHMENT (p_mail_id = > l_id,)

    p_attachment = >: NEW. FILE,

    p_filename = >: NEW. FILE NAME,

    p_mime_type = >: NEW. MIME);

    END;

    But when I insert data, I get the following error:

    ORA-20022: Null value provided for the parameter p_filename.

    ORA-06512: at "APEX_040200.WWV_FLOW_MAIL", line 1070

    ORA-06512: at "APEX_040200.WWV_FLOW_MAIL_API", line 141

    ORA-06512: at "TR_FEEDBACK", line 11

    ORA-04088: error during execution of trigger 'TR_FEEDBACK '.

    Now, how can I fix that? Thanks in advance.

    Agree with the above.  Triggers (ab) should not be used in this way.  Nontransactional process should not be based on a transactional trigger.  These processes are part of the business logic and should be at the level of the company of codification (Summit, you can add a process to be executed once the completed insertion)

  • Converting a string to a Date using an insert after trigger.

    Hi people:

    I have a table that has a column (called DATE_FED) that must be registered in the format string.

    Once all data insertion after trigger is triggered that copies of some columns in another table.

    The problem is that the insert after trigger will not work because the table is copied in stores DATE_FED data in a Date format.

    I'm trying to understand how to use the TO_DATE function to convert the NEW. Data DATE_FED to a Date format and the trigger does not work.

    Here is the trigger, as it is currently worded:

    Create or replace TRIGGER "FARM". "' BALES_FED_PAST_TRIG ' AFTER INSERT"FARM ". ' ' BALES_FED_PASTURE ' 'OLD' NEWS like 'NEW' FOR EACH LINE REFERENCING OLD declare

    BEGIN

    insert into BALES_STORAGE (BALES_LOST_SUBTRACTED, HARVESTING, CUTTING, STACKYARD, DATE_MOVED, FED_ID, BALE_YEAR) values (: new.) BALES_FED,: new. CULTURE: new. CUTTING: new. STACKYARD,: new. DATE_FED,: new. FED_ID,: new. BALE_YEAR);

    END;

    This trigger worked until I had to change the column type of DATE_FED from the Date to a string.

    I tried things like:

    TO_DATE (DATE_FED): = GCNEW. DATE_FED;    in a statement, but I don't get it.

    Summary:

    I need an insert after trigger to convert NEW. DATE_FED (a string) again. DATE_FED (a Date).

    Tables:

    BALES_FED_PASTURE is the table, the trigger to run.

    BALES_STORAGE is the table the trigger is to copy certain columns.

    I thank very you much for any help.

    Matthew

    FriendlyTooo wrote:

    I have a table that has a column (called DATE_FED) that must be registered in the format string.

    If you book the date in a format string. Bad design. In any case, what is this format? Register you as hh24:mi:ss dd/mm/yyyy or DD-me-YYYY, or... You what it is, you must use this format in your trigger:

    insert into BALES_STORAGE (BALES_LOST_SUBTRACTED, HARVESTING, CUTTING, STACKYARD, DATE_MOVED, FED_ID, BALE_YEAR) values (: new.) BALES_FED,: new. CULTURE: new. CUTTING: new. STACKYARD, TO_DATE(:new.) DATE_FED, "whatever-format-is"),: new. FED_ID,: new. BALE_YEAR);

    SY.

  • If I create a form using the free trial software, will I be able to use and access the form, after the trial period is over?

    If I create a form using the free trial software, will I be able to use and access the form, after the trial period is over?

    Yes, you can access the project that you created after the trial is over, but you need to back it up.

    Concerning

    Stéphane

  • Create the trigger after insert

    Hello

    I would like to ask how to create a trigger after insert on a table. Basically, what I wanted to do are when an insert to table1 it will insert the records to table2. But the problem is that folders that will be inserted in the new tables are entries/fields, who lived in NEW York City (on table of ld)

    after insertion, I wanted to add another field in table2 as status


    create table table1)

    Name varchar2 (55),
    City varchar2 (55)

    );

    create (table2)

    Name varchar2 (55)
    status int (1)
    )

    Hope you could help me.

    Thank you

    Best regards

    antok1015 wrote:
    Hello

    I would like to ask how to create a trigger after insert on a table. Basically, what I wanted to do are when an insert to table1 it will insert the records to table2.

    It's easy...

    SQL> create table table1(
      2    Name varchar2(55),
      3    City varchar2(55)
      4  );
    
    Table created.
    
    SQL>
    SQL> create table table2 (
      2    Name varchar2(55),
      3    status number(1)
      4  );
    
    Table created.
    
    SQL>
    SQL> create or replace trigger trg_tbl1 after insert on table1
      2  for each row
      3  begin
      4    insert into table2 values (:new.name, 1);
      5  end;
      6  /
    
    Trigger created.
    
    SQL> insert into table1 values ('Fred','Bob');
    
    1 row created.
    
    SQL> select * from table2;
    
    NAME                                                        STATUS
    ------------------------------------------------------- ----------
    Fred                                                             1
    
    SQL>
    

    But the problem is that folders that will be inserted in the new tables are entries/fields, who lived in NEW York City (on table of ld)

    after insertion, I wanted to add another field in table2 as status

    This is not sensible. Please explain what you mean.

  • Need to create a trigger that generates multiple rows in another table

    {size: 12} Hello

    I use Oracle9i (9.2.0.4.0)

    My problem is:
    I need to create a trigger that create different in the other table lines when someone will introduce a new line in the first table.

    For this, I use the table 4:

    1. first one where you want the trigger.
    2. a second just to take information.
    3. a third to make a trip meter.
    4. the fourth is the table where I want to create new lines. {size}

    Here is a summary of these 4 tables:

    {color: blue} Table 1
    STOJOU
    Number ¿Nulo? Tipo
    STOFCY_0 NOT NULL VARCHAR2 (9)
    ITMREF_0 NOT NULL VARCHAR2 (60)
    LOT_0 NOT NULL VARCHAR2 (45)
    VCRTYP_0 NOT NULL NUMBER (3)
    VCRNUM_0 NOT NULL VARCHAR2 (45)
    VCRLIN_0 NOT NULL NUMBER (10)
    QTYSTU_0 NOT NULL NUMBER
    NUMVCR_0 NOT NULL VARCHAR2 (45) {color}

    {color: blue} Table 2
    ITMMASTER
    Number ¿Nulo? Tipo
    ITMREF_0 NOT NULL VARCHAR2 (60)
    ZCOEFI_0 NOT NULL NUMBER {color}

    {color: blue} Table 3
    ZCTUART;
    Number ¿Nulo? Tipo
    CTUART_0 NOT NULL NUMBER (10)
    CTUDATE_0 NON NULL DATE {color}

    {color: blue} Table 4
    ZUART
    Number ¿Nulo? Tipo
    ZUARTDM_0 NOT NULL VARCHAR2 (102)
    STOFCY_0 NOT NULL VARCHAR2 (9)
    STOCOU_0 NOT NULL NUMBER
    ITMREF_0 NOT NULL VARCHAR2 (60)
    LOT_0 NOT NULL VARCHAR2 (45)
    CREDAT_0 NOT NULL DATE
    QTYSTU_0 NOT NULL NUMBER
    STA_0 NOT NULL VARCHAR2 (3)
    VCRLIN_0 NOT NULL NUMBER (10)
    VCRNUM_0 NOT NULL VARCHAR2 (45)
    VCRTYP_0 NOT NULL NUMBER (3) {color}

    I do this trigger:
    CREATE OR REPLACE TRIGGER CREA_REGISTROS_TRAZA
    AFTER INSERT ON STOJOU
    FOR EACH ROW
    DECLARE
       n INTEGER;
       ct NUMBER;
       fecha_actual VARCHAR2;
       fecha_old VARCHAR2;
       codigo_dm VARCHAR2;
    BEGIN
       fecha_actual := TO_CHAR(SYSDATE, 'DD/MM/YYYY');
       -- SELECT TO_CHAR(sysdate, 'DD/MM/YYYY') INTO fecha_actual FROM DUAL;
       SELECT TRUNC((STOJOU.QTYSTU_0/ITMMASTER.ZCOEFI_0),0) INTO n FROM STOJOU INNER JOIN ITMMASTER ON STOJOU.ITMREF = ITMMASTER.ITMREF;
          FOR i IN 1 .. n
       LOOP
          SELECT CTUART_0,TO_CHAR(CTUDAT_0, 'DD/MM/YYYY') INTO ct,fecha_old FROM ZCTUART;
          IF fecha_old <> fecha_actual THEN
            ct := 0;
          END IF;
          ct := ct + 1;
          INSERT INTO ZCTUART
            (CTUART_0,CTUDAT_0)
          VALUES
            (ct,SYSDATE);
          codigo_dm := SUBSTR('000000000000000000000',1,20 - LENGHT(NEW.ITMREF_0)) || NEW.ITMREF_0 || SUBSTR('0000000000',1,10 - LENGHT(NEW.LOT)) || NEW.LOT || SUBSTR('0000',1,4 - LENGHT(ct)) || ct;
          INSERT INTO ZUART
            (ZUARTDM_0,ITMREF_0,CREDAT_0,STA_0,QTYSTU_0,LOT_0,STOFCY_0,VCRLIN_0,VCRNUM_0,VCRTYP_0)
          VALUES
            (codigo_dm,NEW.ITMREF_0,SYSDATE,0,NEW.QTYSTU_0,NEW.LOT_0,NEW.STOFCY_0,NEW.VCRLIN_0,NEW.VCRNUM_0,NEW.VCRTYP_0);
       END LOOP;
    END CREA_REGISTROS_TRAZA;
    /
    {size: 12} And the error message I get States is just:
    "The trigger was created with compilation errors."
    Thanks for the help {size}

    You must prefix your NEW "columns" with a colon, as in: NEW.

  • What is this error when creating a trigger

    Hello

    I have create a trigger and get the following error. What is - c

    1 CREATE OR REPLACE TRIGGER TRG_AUDIT_LOGON AFTER
    2 LOG ON TO THE DATABASE
    3 Declare
    4 v_sid v$session.sid%type;
    type of v_serial 5 v$ session.serial # %;
    v_username 6 v$session.username%type;
    v_osuserid 7 v$session.osuser%type;
    8 v_machinename v$session.machine%type.
    v_PROGRAM 9 v$session.program%type;
    v_TERMINAL 10 v$session.terminal%type;
    11 v_hostname v$instance.host_name%type;
    v_instance_name 12 v$instance.instance_name%type;
    13 v_application_id v$database.dbid%type;
    date of v_logon_time 14;
    15 v_Audit_tab_check varchar2 (30);
    16 v_system_users_tab_check varchar2 (30);
    17 v_sql_Audit_upload varchar2 (1000): = "INSERT INTO dbaoper. T_AUDIT (HOST_NAME, APPLICATION_ID, INSTANCE_NAME, SID, SERIAL #, username, OSUSERID, MACHINENAME, PROGRAM, TERMINAL, LOGON_TIME) VALUES (: v_hostname,: v_application_id,: v_instance_name,: v_sid,: v_serial,: v_username,: v_osuserid,: v_machinename,: v_program,: v_TERMINAL,: v_logon_time) ';
    18 type c_audit_cur_typ is ref cursor;
    19 C_Audit c_audit_cur_typ;
    20 V_system_users_tab: = "T_SYSTEM_USERS";
    21 No_Audit_records Exception;
    Begin 22
    23 select table_name in v_Audit_tab_check from dba_tables where owner = 'DBAOPER' and table_name = "T_AUDIT";
    24 select table_name in v_system_users_tab_check from dba_tables where owner = 'DBAOPER' and table_name = "T_SYSTEM_USERS";
    25 c_Audit open for ' SELECT sid, serial # username, osuser, machine, terminal program v $ session WHERE audsid = userenv ("' sessionid" ') and program not as "'oracle@%J0%"' and no user name (select * from dbaoper.' |) V_system_users_tab |') and type! = "' BACKGROUND"' ';
    26 c_Audit of fetch in v_sid, v_serial, v_username, v_osuserid, v_machinename, v_program, v_TERMINAL;
    27 if c_Audit % Notfound then
    28 lift No_Audit_records;
    Else 29
    30 select host_name, instance_name in v_hostname, v_instance_name from v$ instance;
    31 select dbid from v_application_id from v$ database;
    32 select sysdate in double v_logon_time;
    33 execute immediate v_sql_Audit_upload using v_hostname, v_application_id, v_instance_name, v_sid, v_serial, v_username, v_osuserid, v_machinename, v_program, v_TERMINAL, v_logon_time;
    34 end if;
    35 close C_Audit;
    exception of 36
    37 when no_data_found then
    38 dbms_system.ksdwrt (2, 'ORA-20001 Audit T_AUDIT or T_SYSTEM_USERS not found Audit information tables are not entered'
    (39);
    40 what then No_Audit_records
    41 dbms_output.put_line ('Audit number to insert records");
    42 * end;
    SQL > /.

    WARNING: Trigger created with compilation errors.

    SQL > sho err
    Errors for TRG_AUDIT_LOGON TRIGGER:

    LINE/COL ERROR
    -------- -----------------------------------------------------------------
    18/20 PLS-00103: encountered the symbol "=" when expecting one of the
    Next:
    constant exception < an ID >
    < a between double quote delimited identifiers > double Ref table Fedya
    char time timestamp interval date binary national character
    NCHAR
    The '< an identifier >' replaced with '=' to
    continue.


    Thank you
    Pramod

    replace * "' * with *" *. For example userenv ("' sessionid" ') to userenv ("sessionid")

  • Copy the files created after a certain date

    How can I copy files that were created after a certain date?

    Thank you

    Hello

    Start - computer or Windows Explorer, you can navigate to a specific folder, then right-click on
    name (or) control position - MORE - Date created column - OK - the box, and then click the Date
    Created column that will align the content of the folder by date ascending or descending as you wish
    (click again to change the order). Then you can click on the 1st file in a sequence and hold SHIFT key and
    Click on the last file in the sequence you want - this will highlight the sequence - then right-click -.
    where in the region of high-lighted and the COPY - navigate to where you want to copy and then right-click
    on paste. To copy a group of files not in a sequence, hold down the CTRL key and click on the ones you want
    COPY that will highlight the files - right-click anywhere in the region high-lit - and then COPY
    Navigate to where you want to copy and click straight on and PASTE.

    --------------------------------

    You can search for files created after a certain date.

    Tips for finding files
    http://Windows.Microsoft.com/en-us/Windows-Vista/tips-for-finding-files

    How to use advanced search in Vista Options
    http://www.Vistax64.com/tutorials/75451-advanced-search.html

    ----------------------------------------------------------

    Win Key F opens advanced search

    Searching in Windows Vista, part 1
    http://Windows.Microsoft.com/en-us/Windows-Vista/searching-in-Windows-Vista-part-1-secrets-of-the-search-box

    Part 2
    http://Windows.Microsoft.com/en-us/Windows-Vista/searching-in-Windows-Vista-part-2-Start-menu-and-control-panel-search-tips

    Part 3
    http://Windows.Microsoft.com/en-us/Windows-Vista/searching-in-Windows-Vista-part-3-using-advanced-search-for-those-hard-to-find-files

    I hope this helps.

    Rob Brown - MS MVP: Bike - Mark Twain said it right.

  • the things that I create within the trial period can be used for commercial purposes, otherwise if I buy CC who will give me the right to use the things I create for commercial purposes

    the things that I create within the trial period can be used for commercial purposes, otherwise if I buy CC who will give me the right to use the things I create for commercial purposes

    While there is really no way to stop you using the trial for commercial purposes (and to be honest, it's probably the best way to know if it works for you, in any case) you need to keep in mind that, after the 30 day trial period you will not is no longer able to work the same day or any other project unless you register it.

  • I use Dreamweaver cc 2014 and after styling css to my fluid page layout grid I lose him resize, delete, duplicate and move up / down ability.

    I use Dreamweaver cc 2014 and after styling css to my fluid page layout grid I lose him resize, delete, duplicate a high displacement / low capacity.

    For this reason I can't build new pages by copying a page to create a new one.

    I have a third style sheet that I use for the styles of navigation and h1 - h6 ect. Tags. and I'm also using a dropdown menu CSS, if one of them can be the problem?

    The menu css that I use has the following script: I spend at the bottom of the html page. Before the closing tag, body

    < script >

    $(function () {})

    $("#nav").tinyNav ();

    });

    < /script >

    I also use the following for an image - I have put it to the top of the fluid

    grid style sheet.

    * {

    box-sizing: border-box; / * Opera/IE 8 + * /.

    -moz-box-sizing: border-box; / * Firefox, another Gecko * /.

    -webkit-box-sizing: border-box; / * Safari/Chrome, another WebKit * /.

    }

    Can you please help.

    My experience is that you should not touch the style sheets that have been created by the system of FGL. Also, there is no need to copy and paste whenever it could disrupt the spoilsports. If you need to apply your own styles and then put them in a second stylesheet, that way if something goes wrong, you can always revert to the original.

  • Error no valid identifier when you try to create a trigger

    Hi all

    I get this weird error when you try to create a trigger. Basically, it updates a table of different relationship on INSERT or UPDATE.

    The error I get is:
    * PL/SQL: ORA-00904: "cid": invalid identifier *.
    SET SERVEROUTPUT ON
    CREATE or REPLACE TRIGGER UPDATE_REL_TABLE 
         AFTER INSERT OR UPDATE ON XF_PROJECT_CODE
    FOR EACH ROW 
    DECLARE
         customer_count NUMBER;
         n_cid NUMBER;
    BEGIN 
         -- CHECK if company exist
         SELECT COUNT(*) INTO customer_count FROM XF_CLIENTS WHERE UPPER(client_name) = UPPER(:NEW.company);
         
         CASE 
         WHEN customer_count > 0 THEN
              -- GET CUSTOMER ID
              select t.cid INTO n_cid FROM XF_CLIENTS t WHERE t.CLIENT_NAME = :NEW.company;   // ERROR HERE!!
              
              -- UPDATE relationship table
              INSERT INTO XF_CLIENT_CODE_R (PROJECT_CODE_ID, cid) VALUES (:NEW.project_code_id, n_cid);
         
         ELSE
              -- customer does not exist
              n_cid := XF_CLIENTS_SEQ.NEXTVAL;
              
              -- Create client
              INSERT INTO XF_CLIENTS(cid, client_name) VALUES(n_cid, :NEW.company);
                   
              -- update relationship table
              INSERT INTO XF_CLIENT_CODE_R(project_code_id, XF_cid) VALUES (:NEW.project_code_id, n_cid);
              
         END CASE;
    END; 
    /
    SHOW ERRORS;
    The column exists and matches the data type (number). Any help appreciated. bit at loss where I'm wrong.

    Good fishing! Who'd do all right.

  • How and where to use Java script to create a new button in the page of detail of the object

    Hi all

    I want to create "New/Add button" in the page of detail of the object. If I'm not mistaken I need to use the java script for this, but could you please let me know how and where to use Java script to create a new button in the page of detail of the CRMOD object.

    Thanks in advance.

    Kind regards
    Manish

    Any related object on the details of the page should have an 'Add' or 'New' or the two default buttons - it of a vanilla feature and will do the required action.

    If you want to change this behavior and do something delicate you will potentially have to to go for javascript. You must add the javascript code in a web custom tab on this object.

    Admin--> Application Customization--> Contact--> Applet Web Contact

    Now add your javascript in the code box, after selecting the type = HTML for this web applet, expose this web applet on the Contact details page layout and your javascript will be called every time this page is loaded.

    Check this document online to see how javascript can be integrated into the CRM on demand http://helponmyproject.com/TTOCOD/

    See you soon!
    Royston

  • Create a trigger (pk of sequence) &amp; JPA

    When I tried to create the trigger (pk of sequence), I noticed that the generated code is automatically:

    CREATE OR REPLACE TRIGGER "ORA11111". "ID_GEN ' before insert on 'S_PROJ' for each row begin if insertion then if: NEW." ' ' ID ' is null then select PROJ_SEQ.nextval in: NEW. ' ' ID ' from dual; end if; end if; end;
    ALTER TRIGGER 'ORA11111 '. "' ID_GEN ' ENABLE

    I have the JPA mapped to this table data object class, the primary key 'ID' field is declared 'int', so 'create' APP is not successful because the default type int is 0 (will never be NULL, primary key so trigger the auto-increment). How to do this?

    Thank you
    Mike

    Yes, it works for new records.

    Oracle DB has sequences. It could be used by the @SequenceGenerator. If it is properly set up the warranty that the PK constraint does not occur.

    -olaf

  • Help me in creating a trigger Insert and Update Options

    Hello

    Please help me in creating a trigger.

    My requirement is that, after insert or update on a Table, I want to launch an event.

    I have started this way, but does not know how to fully implement it.

    I have a dept table


    CREATE TRIGGER DepartmentTrigger
    INSERT AFTER on Dept
    BEGIN
    INSERT INTO mytable VALUES("123","Kiran");
    END DepartmentTrigger;


    Please tell me how I can put the update option also.

    Thanks in advance.

    Please tell me how I can put the update option also.

    Add "or update". ;-)

    Here are a few suggestions, but you definitely need to refer to the manual page that suggested the previous poster.

    CREATE OR REPLACE the TRIGGER DepartmentTrigger
    AFTER INSERT or Update ON Dept
    BEGIN
    INSERT INTO mytable VALUES(:new.) Dept 'DEPT ADDED OR CHANGED');
    END DepartmentTrigger;

    The "or replace" means that you can replace the shutter button as you develop without having to type in a drop statement each time. Just change and reissue your script over and over again until you get it right.

    The addition of "update or" or "Or remove" fact the trigger too much fire for these events. Note, you peut want separate triggers in different scripts and with different names for each event. You must decide whether your design is really the same thing either an insert or an update.

    : new. Dept, this is how you should refer to the vale has changed the Dept column (: old.) Dept is the previous value). I changed the double quotes in the string in the clause VALUES of apostrophes.

    Andy

  • problem when creating a trigger: SQL statement ignored

    Hello people,

    I am trying to create a trigger, but it is not created. Instead, I get the error message that a SQL statement at line 22 was ignored. It's the line indicating IF num2 = 1 THEN. I'd be happy if someone could point me in the right direction or solve my problem.

    CREATE OR REPLACE TRIGGER TriggerLogement BEFORE INSERT OR update ON tenants
    FOR EACH LINE
    DECLARE
    NUM INTEGER;
    num2 INTEGER;
    NUM3 INTEGER;
    paysLocataire VARCHAR2 (255);
    categorieLocataire VARCHAR2 (1);
    BEGIN
    SELECT COUNT (ns) IN the number OF tenants WHERE nomBat =: new.nomBat;

    IF num > 0 THEN
    SELECT paid IN the country OF sports WHERE ns =: new.ns;
    SELECT COUNT (country) IN number OF athletes sp, tenants lo WHERE sp.ns = lo.ns AND paysLocataire AND lo.nomBat = pays =: new.nomBat;
    IF num = 0 THEN
    raise_application_error (-20000, "building already in use for another nationality");
    ON THE OTHER
    SELECT COUNT (ns) IN num2 OF tenants WHERE nLogement =: new. NLogement AND nomBat =: new.nomBat;
    IF num2 = 2 THEN
    raise_application_error (-20000, 'full accommodation');
    ON THE OTHER
    IF num2 = 1 THEN
    CateogrieLocataire INTO SELECT category OF athletes WHERE ns = new.ns;
    SELECT COUNT (ns) IN num3 FROM tenant lo, sportsmen sp WHERE lo.ns = sp.ns
    AND lo.nLogement =: new. NLogement AND lo.nomBat =: new.nomBat AND sp.categorie = categorieLocataire;
    IF num3 = 0 THEN
    raise_application_error ("-20000, ' already in use for the other sex");
    END IF;
    END IF;
    END IF;
    END IF;
    END IF;
    END;

    If you need more information or if you have any questions about my posts please leave your questions or comments. I hope this isn't how completely wrong to enforce some constraints that I can't do with CONSTRAINT and CHECK in the schema definition.

    Thanks for your help and your attention.

    Sebastian

    Hello

    Whenever you have a problem that raises an error, display the full error message; do not paraphrase just part of it.

    In the triggers line numbers from the first statement DECLARE or BEGIN, so line 22 of your trigger is:

    SELECT categorie INTO cateogrieLocataire FROM Sportifs WHERE ns = new.ns;
    

    You are missing a colon before 'new': it should be:

    SELECT categorie INTO cateogrieLocataire FROM Sportifs WHERE ns = :new.ns;
    

    A FOR EACH ROW trigger on tenants cannot ask tenants. It's a shame: there are many useful things, you could do if that were allowed, but it's not.
    I'm not sure of what all queries. At least one of them:

    SELECT  COUNT (ns)
    INTO    num2
    FROM    Locataires
    WHERE   nLogement = :new.NLogement
    AND     nomBat    = :new.nomBat;
    
    IF num2 = 2 THEN
        raise_application_error(-20000,'accomodation full');
    

    can be replaced by a UNIQUE constraint. (Constraints are better than triggers, in any case.)

    If you can't do what you want with constraints, you can leave anyone directly INSERT or update the table: force them to use a procedure stored instead. You can have an INSTEAD OF trigger on a view, which is essentially the same, but allows you to use DML commands.

    If you need help, post some sample data and some examples of DML operations that must be allowed, given the data and some examples of DML operations that should not be allowed.

Maybe you are looking for