problem with trigger to block certain characters

Hello
This is the structure of the table
create table alarmtp(alamtp char)
The condition is that the table should allow only 2 characters (V or H), if we try to insert other than these 2 characters it should trigger an error...
So I wrote the following trigger
create or replace trigger block_tp
 after insert or update 
 of alamtp on alarmtp
 referencing new as new old as old
 for each row
 WHEN (NEW.ALAMTP ='V' OR NEW.ALAMTP='H') 
begin
 if((:old.alamtp <>'V' AND :old.alamtp <>'H') OR (:new.alamtp<>'V' AND :new.alamtp<>'H')) then
  raise_application_error(-20100,'not allowed');
 end if;
end; 
/ 
But the following insert statement runs instead of trigger the error...
insert into alarmtp values('A')
The above line is inserted... But do not

Could you please give the trick to change the trigger

Thank you
SQL>  create table alarmtp (alamtp char)
/
Table created.

SQL>  create or replace trigger block_tp
   after insert or update of alamtp
   on alarmtp
   for each row
   when (new.alamtp not in('V', 'H'))
begin
   raise_application_error (-20100, 'not allowed');
end block_tp;
/
Trigger created.

SQL>  insert into alarmtp values ('A')
/
insert into alarmtp values ('A')
Error at line 19
ORA-20100: not allowed
ORA-06512: at "MICHAEL.BLOCK_TP", line 2
ORA-04088: error during execution of trigger 'MICHAEL.BLOCK_TP'

SQL>  insert into alarmtp values ('H')
/
1 row created.

SQL>  insert into alarmtp values ('V')
/
1 row created.

SQL>  insert into alarmtp values ('X')
/
insert into alarmtp values ('X')
Error at line 28
ORA-20100: not allowed
ORA-06512: at "MICHAEL.BLOCK_TP", line 2
ORA-04088: error during execution of trigger 'MICHAEL.BLOCK_TP'

BTW. You are most probably catch a Tartar when you use a char data type: I recommend to varchar2.

Tags: Database

Similar Questions

  • Satellite C660: problem with keyboard - double or missing characters

    Hello

    Last week, I bought my first laptop - a C660.
    A few days after I bought it, I noticed that he was typing double characters or completely miss the characters.
    Now, maybe it's that I'm adjusting to the keyboard, but I was wondering if there was any problem with the keyboards?

    Jin

    Perhaps, there is a defect in material of the keyboard. Are you running Os with the factory settings? Otherwise, contact the after-sales service. they will fix for free.

  • Problem with keyboard on the M60 (characters to jump)

    I bought an M60 for my wife and she complained that he jumps constantly characters. I found the same problem. For example, type in the URLS in internet explore or composing emails, he will be missed by 10% of the time characters. I saw a couple of posting on this topic in the forums.

    Good old Dixons refused to refund purchases as someone called me today to say that she cannot see any problem with the keyboard.

    Does anyone know a solution to this problem?

    Hello Chris

    Unfortunately, the problem can be fixed with some kind of firmware. I spoke with Toshiba and this is known issue and they also said that Toshiba do some tests with the new keyboards and when this will be resolved customers can expect a help about it.

    If I understand right, there is a problem with the contacts of the button. As you know that it is the new keyboard with numeric keypad and not the standard. Sorry, but for now, need you a little patience. If you want you can also try to contact the after-sales Service of Toshiba partner in your country. Maybe they have the same information. Talk with them. A consultation is free.

    Good luck!

  • problem with audio export blocked at 8000 hz since AE CC 12.2.0.52

    Hello

    Today, it's a mess, I don't know if it's my iMac is dying or what, but several problems.

    I try to export a model, he has worked and today, the frequency of the audio in the render parameter is blocked at 8000Hz, when I try to use another frequency and confirm, the frequency is back to 8000Hz! I try with other audio files, but it's the same problem...

    solution?

    Here are the details of the update fixes after effects CC (12.2.1), which is now available:

    http://Adobe.LY/AE_CC_1221

    This update fixes the bug of audio sampling, as well as several other issues.

    Note the part at the end of this page on a crucial update for the creative cloud desktop application, which addresses serious problems with the SOUL, first Pro and After Effects.

  • Problem with the text block (text cut)

    Hello

    I have a problem with indesign (last CC version, I have upgradate today in the morning).

    I create a document with several pages and each page

    is a text box it and the text box are connected (the text content is broadcast through them).

    The text box are defined by a paragraph style, where I set the font style, color...

    I defined that the box can be 2 colunms and oviously, I also set betwin space columns.

    So the apears tex cut in the bottom text box and the rest of the blanks strages.

    I enclose a scrrenshot.

    Please, help me, I'm stacked in this disorder.

    Thnk

    EmilianoSchermata 2016-07-21 alle 16.48.59.png

    I find the solution.

    Yhe problem was in the style Panel,

    in the tab which, in Italian, is called 'options di separazione.

    I am enclosing a copy.

    Thank you all

  • Problem with trigger AFTER INSERT

    Hi all

    I am updating a column in the table by adding 2 characters 'a_' after INSERTION using the trigger.

    Now when I insert data in the table a trigger is fired for INSERTION.
    According to the syntax, I think that we cannot pass parameters in a trigger.
    I have a test10 table that looks like this.
    t1    varchar2(10)
    t2    varchar2(10)
    t3    varchar2(10)
    t4    number
    t5    number
    
    t1 is kinda primary_key and t2 is unique though the table isn't structured like that but the data in it follows that.
    The code in the trigger looks like this 
    
    CREATE OR REPLACE TRIGGER test10_t1 
      AFTER INSERT 
      ON test10 
      FOR EACH ROW
    BEGIN
      IF INSERTING THEN
        UPDATE test10 SET t1 = 'a_'||:old_value WHERE t1 = ?;  -- I need to mention the parameter here but not sure if we can pass param in a trigger 
      END IF;
    END;
    If I omit the WHERE clause, all records are updated. Is there another way to solve the problem?

    THX
    Rod.

    There is no need to use a clause of update.

    Have you tested the relaxation that I suggested in my last post?

  • Problem with adding previously blocked contact.

    I tried to add an old friend of my friends on Skype after believing have been they are blocked for a while. I emptied my blocked list and sought their username after asking them what it was, but the Skype directory could not find them. After about an hour of googling and try to add them in different ways, I made a new Skype account and looked for their names, and he came instantly. Does anyone have any idea what this problem is? I am not sure if they have blocked me without knowing it, but they have added me as a contact, and I've never had a notification that someone has tried to add me.

    I am sure I am running the latest version of Skype. My OS is Windows 7 64 bit Home Premium edition.

    I don't get the error messages.

    First of all, make sure that you actually have the last currently 7.1 version installed Skype.

    http://www.Skype.com/en/download-Skype/

    There was a bug in version 7.0 , making it impossible to add a previously deleted contact.

  • PowerState situation - problem with the code block - returns false, but seems real to list extended properties

    If this provision of the code (part of a script a lot bigger) seems to not work properly.  It returns false when it should return true.  Basically I want my script to verify that virtual machines are turned on by the admin of the script running.  There will be a break in case of failure and then press a button to try again.  Here is the block of code (which I have shared out in his own script to test).

    #Import the CSV
    $vmlist = Import-CSV d:\scripts\migration.csv
    
    #validate VMs are powered up on the new vCenter
    foreach ($item in $vmlist) {
      $vmname=$item.vmname
      $powerstate = (Get-VM $vmname).extensiondata.Guest.PowerState -eq "poweredOn"
      IF ($powerstate -eq $false) {
      write-host ""
      write-host "$vmname has failed to start, please confirm the VM is up.  Script will pause." -foreground Yellow
      write-host "Bring $vmname backonline then" -foreground Yellow
      Write-Host "Press any key to retry..." -foreground Yellow
      Write-Host ""
      $null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')
      }
         ELSE {
      write-host ""
      write-host "$vmname is powered up, script will continue" -foreground green
      write-host ""
      }
    }
    

    To list extended properties, it returns the correct information:

    PowerCLI D:\scripts > Get - VM ATEST-VM002 | format-list *.

    PowerState: receiving

    When I run in the script with the extensiondata. Guest.Powerstat, it returns false.

    PowerCLI D:\scripts > .extensiondata (Get - VM ATEST-VM002). Guest.PowerState - eq "receptor".

    Fake

    What should we not

    . ExtensionData (get - VM $vmname). Runtime.PowerState - eq "receptor".

    But why look in the ExtensionData that same property is exposed as (Get - VM $vmname). PowerState

  • Problem with trigger on the table

    Hello

    I have the table TEMP AS (NUMBER of SNO
    STATE VARCHAR2 (50).
    DATE OF UPDATE_DATE)

    I want to create the trigger on this table as each time that it is updated in the STATE of temporary table UPDATE_DATE updated columns.
    I am creating the trigger using the PRAGMA autonomous transaction, but it does not work with that and withouht PRAGMA.
    With PRAGMA I get the error message ' ORA-00060: Deadlock detected while you wait resource. "

    Is it possible to create triggers on this table to update columns in the same table.

    Published by: user6040008 on December 11, 2012 01:08

    Hello
    This is not a valid forum for questions like that. Thank you for using {forum: id = 75} forum. However, you can use following code:

    
    create or replace trigger xx
    before update of state
    on cabasys.temp
    for each row
    begin
    :new.update_date := sysdate;
    end; 
    

    Published by: kikolus on 2012-12-11 10:40

  • Problem with a damaged block

    Hello everyone
    I have a block on my database corrupted. It's the affected object:

    SYSMAN. MGMT_DB_INIT_PARAMS_ECM_PK which is a tables organized in Index, of what I can´t use the DBMS_REPAIR package. Whit RMAN I've run the following script:

    BLOCKRECOVER datafile 2 block 41464 restoration until sequence N.

    and didn t work at all.

    How can I solve this problem?

    Thank you.

    Refer to the MOS score

    How to corrupt format block is no not part of any Segment [ID 336133.1]

    Werner

  • What is the problem with my ACL using wildcard characters.

    I'm trying to deny little hosts in Cisco ASA however, I got the error why I should use the "subnet mask" for ACL in this firewall. ?

    192.168.1.44
    192.168.1.45
    192.168.1.46
    192.168.1.47

    extended access list 1 inside_access_in_1 line deny icmp 192.168.1.44 0.0.0.3 host 8.8.8.8

    ERROR: IP address, mask of <192.168.1.44,0.0.0.3>is not pair

    Help, please.

    Thank you.

    Since you're on a SAA, you cannot use a mask with joker - try to use the subnet mask itself (255.255.255.252). You have the correct generic, but Cisco ASA (or, to my knowledge, some the most of them) do not support masks with joker in the instructions of the ACL. Otherwise, it looks good to me. Let us know how it goes!

  • Problem with the text block, put in place when it is used on the page number marker

    Hello!

    I would use the text block on the marker page number on the master page in Indesign. The text block should change width when increases the page number. It does not work. What happens is that when the number of page moves a two-digit figure, the numbers tightened itself (compressed on top of each other) and the block of text changes size unless I drag on it (which means I have to manually unlock the master page first).

    I'm doing something wrong, or is this a bug?

    Thank you!

    Altogether! So, you can use a rule of Pará to simply do it!

  • problem with trigger

    CREATE OR REPLACE TRIGGER entrada_statement
    AFTER INSERT ON entrada
    DECLARE
    t_entrada entrada_temp % rowtype;
    err_msg varchar (200);
    BEGIN
    for t_entrada IN (SELECT * from entrada_temp) loop
    BEGIN
    If (NOT EXISTS (SELECT * FROM pelicula WHERE codigo_pelicula = t_entrada.codigo_pelicula)) THEN
    BEGIN
    insert into film (codigo_pelicula, title, language, formato, Género, codigo_productora) VALUES (t_entrada.codigo_pelicula, t_entrada.titulo, t_entrada.idioma, t_entrada.formato, t_entrada.genero, t_entrada.codigo_productora);
    END IF;
    end loop;

    DELETE from entrada_temp;

    end;


    I have this error
    10/14 PLS-00103: encountered the symbol "IF" when expecting one of the following values:; < an ID > < an ify quotes double bounded-ident >
    Not possible to use an if it s phrase in a sentence in a trigger?

    Thank you.

    You don't need the second BEGINS.

    Try this:

    create or replace trigger entrada_statement
    after insert on entrada
    declare
      pl_dummy number;
    begin
      for t_entrada in (select * from entrada_temp) -- t_entrada is declared implicitly when using a FOR Loop
      loop
        select count(*) into pl_dummy
        from   peliculas
        where  exists (select null
                       from   peliculas
                       where t_entrada.codigo_pelicula=codigo_pelicula
                      );
        if pl_dummy = 0
        then
          insert into pelicula(codigo_pelicula,titulo,idioma,formato,genero,codigo_productora)
          values(t_entrada.codigo_pelicula, t_entrada.titulo, t_entrada.idioma,t_entrada.formato,t_entrada.genero,t_entrada.codigo_productora);
        end if;
      end loop;
      delete from entrada_temp;
    end;
    
  • problem with trigger to update column

    I am creating a trigger when I INSERTS a record into the CHART table, it will also insert the record in the MASTER_TAB table as well. I can't make the statement to UPDATE the trigger.

    To do so, the relaxation, I have currently below.

    But what I am also eager to make, only to do an UPDATE if the 'REMARKS' column changes.

    So, something like:

    If the update and: NEW.COMMENTS! =: OLD.COMMENTS THEN
    do not include a record
    create or replace TRIGGER "TABLE_BIU"
    BEFORE
    INSERT OR UPDATE ON "CHART"
    FOR EACH ROW
    BEGIN
    INSERT INTO MASTER_TAB
    (
    CASE_NUMBER,
    COMMENTS
    )
    VALUES
    (
    :NEW.CASE_NUMBER,
    :NEW.COMMENTS
    );
    END;
    Thank you
    Deanna
    create or replace TRIGGER TABLE_BIU
    BEFORE
    INSERT OR UPDATE ON CHART
    FOR EACH ROW
    BEGIN
    IF INSERTING OR NOT NVL(:OLD.COMMENTS,:NEW.COMMENTS || 'X') = NVL(:NEW.COMMENTS,:OLD.COMMENTS || 'X')
    THEN
    INSERT INTO MASTER_TAB
    (
    CASE_NUMBER,
    COMMENTS
    )
    VALUES
    (
    :NEW.CASE_NUMBER,
    :NEW.COMMENTS
    );
    END IF;
    END;
    

    SY.

  • Problems with some foreign characters

    Hi, I have problems with 217-255 (basically accented characters and umlauts) ASCII characters. For example, I download the word "Pyre" (books in German), but it shows up as "ba¼cher".

    It seems that the chain adds an extra character or something. The a¼ is a code ascii 195 and 188 respectively, while the u is 252. If anyone else has experienced this? How do you get around it?

    Thank you.

    How do you get the chain on the blackberry?

    Take a look at the javadoc for the String class. It is a constructor that takes encoding: new string (byte [], String enc);

    The enc parameter can be the following:

    • "ISO-8859-1" (default)
    • 'UTF-8 '.
    • "UTF-16BE".
    • "US-ASCII".

    Cheers, Barak

Maybe you are looking for

  • Removal of the drop-down search/browser

    Hello I don't want grey drop-down (see table) when I type in the search field or browser. I already disabled 'To provide search suggestions' in the search settings and delete the other engines. In addition, I now get suggestions to ADD other engines.

  • 900 hpelite cushion collection

    I tried to do a hard reset and it keeps looping.i checked all the functions of parties and every thing goes out well.

  • What I do with 106 records Recovered iPhoto?

    August 2013 April 2015, I have amassed 106 "iphoto recovered files.  I see them in the Finder, but don't know if I can see on the pictures. They all seem to be empty.   Is it possible to look at these files through pictures to make sure they are empt

  • Update of Variables between two loops

    Hi all I use LabView to work and did not have formal training in it, so I'm learning I'll. The problem I'm having is LabView won't let you pass variables from one loop to the other let say update the entry, my understanding is probably wrong. In the

  • USB 3.0 does not

    I recently bought a 500-314 desktop computer and I always try to get everthing works properly.  I've downgraded to window 7 64-bit Home.  My usb ports are driving me crazy.  My mouse and keyboard (rear) work, but nothing else that I plug fails to be