After insert trigger mutation of error, what is the way to overcome it.

I have two tables namely profiles_answers and user_profileanswers. Based on the requirement that is: when a user inserts the answer in the table of user_profileanswers I need to calculate the weight-age of this issue with the many options available in the profiles_answers table and update this table user_profileanswers age-weight. So, for that, I wrote the following after trigger insert. But when I try to insert it throws me error mutation. As I update the table, used to insert action in the trigger. Please let me how can know I solve this problem.

create or replace

AI_weightageCaluculation TRIGGER AFTER

FOR EACH row INSERT on user_profileanswers

BEGIN

DECLARE

v_a VARCHAR2 (50);

YaeUb VARCHAR2 (50);

V_c VARCHAR2 (50);

v_d VARCHAR2 (50);

ve VARCHAR2 (50);

a_weightage NUMBER;

b_weightage NUMBER;

c_weightage NUMBER;

d_weightage NUMBER;

e_weightage NUMBER;

BEGIN

SELECT option_a, option_b, option_c, option_d, option_e IN

v_a, YaeUb, v_c, v_d, profiles_answers FROM ve

WHERE profile_questions_id =: new.profilequestion_id;

IF (v_a IS NOT NULL AND YaeUb IS NOT NULL AND v_c IS NOT NULL AND v_d IS NOT NULL AND EV IS NOT NULL) THEN

BEGIN

a_weightage: = 85;

b_weightage: = 60;

c_weightage: = 45;

d_weightage: = 30;

e_weightage: = 15;

END;

ELSIF (v_a IS NOT NULL AND YaeUb IS NOT NULL AND v_c IS NOT NULL AND v_d IS NOT NULL AND ve IS NULL) THEN

BEGIN

a_weightage: = 85;

b_weightage: = 60;

c_weightage: = 30;

d_weightage: = 15;

END;

ELSIF (v_a IS NOT NULL AND YaeUb IS NOT NULL AND v_c IS NOT NULL AND v_d IS NULL AND ve IS NULL) THEN

BEGIN

a_weightage: = 85;

b_weightage: = 45;

c_weightage: = 15;

END;

ON THE OTHER

BEGIN

a_weightage: = 85;

b_weightage: = 15;

END;

END IF;

IF: new.answer = 'A' THEN

BEGIN

UPDATE user_profileanswers

SET weightage = a_weightage

WHERE user_id =: new.user_id

AND profileanswer_id =: new.profileanswer_id

AND profilequestion_id =: new.profilequestion_id;

END;

ELSIF: new.answer = 'B' THEN

BEGIN

UPDATE user_profileanswers

SET weightage = b_weightage

WHERE user_id =: new.user_id

AND profileanswer_id =: new.profileanswer_id

AND profilequestion_id =: new.profilequestion_id;

END;

ELSIF: new.answer = 'C' THEN

BEGIN

UPDATE user_profileanswers

SET weightage = c_weightage

WHERE user_id =: new.user_id

AND profileanswer_id =: new.profileanswer_id

AND profilequestion_id =: new.profilequestion_id;

END;

ELSIF: new.answer = ' THEN

BEGIN

UPDATE user_profileanswers

SET weightage = d_weightage

WHERE user_id =: new.user_id

AND profileanswer_id =: new.profileanswer_id

AND profilequestion_id =: new.profilequestion_id;

END;

ON THE OTHER

BEGIN

UPDATE user_profileanswers

SET weightage = e_weightage

WHERE user_id =: new.user_id

AND profileanswer_id =: new.profileanswer_id

AND profilequestion_id =: new.profilequestion_id;

END;

END IF;

END;

END;

Thanks in advance.

Hmm... Why do after insertion?

CREATE OR REPLACE TRIGGER BI_weightageCaluculation

FRONT INSERT ON user_profileanswers FOR EACH ROW

BEGIN

SELECT BOX: NEW. RESPONSE

WHEN 'A' a_weight THEN

WHEN 'B' THEN b_weight

WHEN 'C' THEN c_weight

When ' THEN d_weight

Of OTHER e_weight

END

in: new.weightage

(SELECT 85 a_weight

Case option_result

WHEN 31 THEN 60

WHEN 15 THEN 60

WHEN 7 THEN 45

another 15

end b_weight

Case option_result

WHEN 31 THEN 45

WHEN 15, THEN 30

When 7 then 15

END c_weight

Case option_result

WHEN 31 THEN 30

When 15 then 15

END d_weight

Case option_result

WHEN 31 THEN 15

END e_weight

FROM (SELECT DECODE (option_a, NULL, 0, 1) +)

Decode (option_b, NULL, 0, 2) +.

Decode (option_c, NULL, 0, 4) +.

Decode (option_d, NULL, 0, 8) +.

Decode(option_e,,0,16) option_result

OF profiles_answers

WHERE profile_questions_id =: new.profilequestion_id));

END;

/

HTH

Tags: Database

Similar Questions

  • I need to import a simple Excel file in InDesign, but it must be free of error, what are the system requirements of InDesign and Excel?

    I need to import a simple Excel file in InDesign, but it must be free of error, what are the system requirements of InDesign and Excel?

    but it must be free of errors

    Do you mean without errors in the text or formatting? When you place an Excel doc, the Place dialog box allows you to display Import Options. You can choose to place as a non formatted table and apply to any InDesign Table Style.

  • What is the way to apply the sequence ATG?

    What is the way to apply the sequence ATG?
    for example, if I want to order numbers to increment in order 1,2,3,4,... What is the way to do it?

    Best way to generate an ID field is by the use of an IDGenerator. It is not guaranteed to generate numbers which are contiguous.

    To get numbered contiguously order numbers, I guess you could add another field to the order and have a database trigger that will select the next value in a sequence in the database itself. In the application could get complicated if there are multiple instances ATG running the same application.

  • What is the way to find out which app is downloading data from the internet?

    Every time I connect to internet, I see that nearly 100 MB of data is is downloaded, without my consent. I did almost all the applications that I know to ask my permission before you download.

    Yet, some applications are downloading data without my consent.
    I would like to know what are the applications that do.

    What is the way to find out which app is downloading data from the internet?

    There is background applications that automatically transfer and receive data when the computer is connected to the internet. Try if there is active apps running.

    1. click Alt + Ctrl + Del to go to start Task Manager / Applications and end unnecessary tasks.

    2. go in Control Panel / programs / uninstall a program and uninstall unwanted programs.

    I hope this helps.

  • After insert trigger. How you assign value to variable?

    Was wondering if I could get a little help please... I have no experience in PL\SQL... The underside of the trigger fires when inserting another table and this trigger adds lines to another table... When you try to assign "bdate" one value from another table, I can't compile trigger... The ORA-04084 getting when you try to compile... Can someone tell me what the problem is in the code please?

    Thank you
    Curtis

    CREATE OR REPLACE TRIGGER "HKSM. "' CHILLPK_IAR ' AFTER
    INSERT ON 'CHILLPACK' FOR EACH LINE
    DECLARE
    bdate SAPUPLOAD.mfgdate%TYPE;
    BEGIN
    IF: New.sku NOT IN ("REPRISE", "EMT") THEN
    IF TO_CHAR (: new .adddate, 'HH24:MI:SS'), ' 04:00:00 ' THEN
    -adddate = production, last updated date
    : New.adddate: =: New.adddate-1;
    END IF;

    -bdate = mfgdate (date of slaughter of the inventory)
    Mfgdate SELECT INTO bdate INVENTORY
    WHERE RTRIM (containerkey) = RTRIM(:New.containerkey)
    AND RTRIM (sku) = RTRIM(:New.sku);

    INSERT INTO SAPUPLOAD)
    SKU,
    quantity,
    WGT,
    mfgdate,
    PFLAG,
    rtype,
    containerId,
    batchdate)
    VALUES)
    : New.sku,.
    : New.traysproduced,.
    : New.weightproduced,.
    : New.adddate,.
    NULL,
    'CREATE ',.
    : New.containerkey,.
    bdate);
    END IF;
    END;

    user3954362 wrote:
    Thanks for your reply... So why doesn't this work?

    Create or replace TRIGGER "HKSM. "' CHILLPK_IAR ' AFTER
    INSERT ON 'CHILLPACK' FOR EACH LINE
    DECLARE
    bdate sapupload.mfgdate%TYPE;
    BEGIN
    If: New.sku not in ("REPRISE", "EMT") then
    If to_char (: new .adddate, 'HH24:MI:SS')< '05:30:00'="">
    bdate: =: New.adddate - 1;
    On the other
    bdate: =: New.adddate;
    End If;
    Insert into SAPUPLOAD
    (sku qty, wgt, mfgdate, pflag, rtype, containerid, batchdate)
    Values
    (: New.sku,:New.traysproduced,:New.weightproduced,:New.adddate, null, 'CREATE',:New.containerkey, bdate);
    End If;
    End;

    Because you are not trying to change a new value that you were with this line in your original post:

    :New.adddate := :New.adddate -1;
    
  • after insert trigger problem

    I am trying to write a trigger that will update a neck date after each insertion.

    CREATE OR REPLACE TRIGGER PS1. XX_CDATE
    AFTER INSERT ON ps1.COMMNPLANBUDGET
    Old SEO AS OLD AS new NEW
    FOR EACH LINE
    declare the PRAGMA AUTONOMOUS_TRANSACTION;
    BEGIN
    Update ps1.COMMNPLANBUDGET set CREATION_DATE = sysdate where PROJECTID =: new. PROJECTID;
    commit;
    END XX_CDATE;

    For the same thing, I wrote the code above, it created successfully but when I am inserting a record pass date is not updated. Please let me know where I did wrong. Thanks in advance

    It's everything you want

    create or replace trigger ps1.xx_cdate before insert on ps1.commnplanbudget referencing old as old new as new for each row
    begin
         :new.creation_date := sysdate;
    end xx_cdate;
    

    Use a trigger to insert BEFORE and just change the: NEW value

  • Device: usb fax modem; fatal error, what is the cause of the problem?

    using my usb modem-fax, the result is fatal error, the response of the device that I can't send your fax due to an unexpected error, pls help.

    I already installed and installed the device, remove and installed gain but the problem still there, pls help.tnx

    Duplicate the content of the Post-

    USB FAX MODEM FAIL TO PERFORM

    'THE FAX CANNOT BE SENT BECAUSE OF AN UNEXPECTED ERROR' IT IS THE MODEM ANSWER AFTER DIALING THE NUMBER, BUT BEFORE IT WAS OK, PLS TELL WHAT IS THE CAUSE OF THE PROBLEM AND TO SOLVE IT, TNX

    Hello


    1. What is the error code when printing / fax fails?

    2. What is the brand and model of Fax Modem?

    3. use an internal card for your fax and modem functions or an external modem?

    4. what was the recent change in hardware or software performed on the computer before the question?

    Please follow the links below to solve the problem.

    Method 1

    Check the compatibility of the device in the Windows 7 Compatibility Center.

    Note: Check the categories of SOFTWARE and HARDWARE.
    Method 2

    Follow the links to help resolve the fax modem

    Reference, the LEARN Section.

    Method 3

    Uninstall the program interface for Fax and reinstall it from the manufacturer's website.

    Run the uninstall program tool set up to help install questions.
     
    Also follow the instrunctions from the link below.
     
    I hope this helps.
  • 0x000000C2 after connection XP SP2 BSOD error - cannot find the drivers for model

    Hello
    Windows XP from. Once the connection with password, it immediately crashes with the following error:
    0x000000C2 (0 x 00000043, 0xD76A2000, 0, 0)

    Try using ERD - but it does not find the system of windows XP - made notrecognizes hard drive - need special driver for the amorçage using F6.
    But what is the driver, and how can I find it?

    * find any hd driver.*
    * can't find my specific model of laptop *.

    my laptop model is NOT listed in the database to support toshiba, OR recording of my laptop:
    Satellite Pro A200 - EZ2205X system unit
    model No. PSAF4U - 00L 004

    also falling series. the results as invalid. ???
    Help, please!

    Post edited by: zhelp

    Your laptop is definitely written but you probably searched on the wrong page. Your model is WE model then please look for drivers on http://www.csd.toshiba.com/cgi-bin/tais/su/su_sc_modSel.jsp

    You want to the new installation of Windows XP Home edition? What you need is driver SATA and it must be loaded before installation WXO begins. This driver must be load with F6.
    I put t know which chipset your laptop model, but please see THIS page for how to find it.

  • LDIF syntax error: what is the reason of this failure when you try to import the new user

    What is the reason of this failure when you try to import the new user, followed the book syntax

    C:\Users\Administrator\Documents>ldifde-i f Newusers.ldf
    Connecting to "practice01.testa01.com".
    Registration as current user using SSPI
    Import directory of the file "Newusers.ldf".
    Loading entries.
    There is a syntax error in the input file
    Failure on line 3.  The last token starts with 'C '.
    0 entries modified with success.
    An error has occurred in the program

    Hello

    The question you have posted is related to LDIFDE with Active Directory in a domain environment, and would be better suited to the TechNet community. Please visit the link below to find a community that will provide the best support.

    http://TechNet.Microsoft.com/en-us/default.aspx

  • Error 800488eb Code for Windows Live Messenger 2011. What is the way to get around this?

    I had this error for centuries and have searched all over the internet for months, but impossible to find something that works. What is the solution?

    Hello

    The question you have posted is related to Windows Live Messenger and would be better suited in the Windows Live Solution Center.

    Please visit the link below to find a community that will support what ask you

    http://windowslivehelp.com/product.aspx?ProductID=2

  • What is the way to faster/better load 160K every night?

    Oracle 9.2
    We have records of 160 K (maybe get new records in the future) that must be refreshed in the production database every night (complete emptying). I suggested that we need to truncate the data, and then do the bulk loading every night. What is the best/fast way? or a better way? How fast to bulk load 160K?

    Appreciate any suggestions.
    Thank you
    S.

    Hello

    Insert bulk is the right option. You have a test or development environment where you Messure it?

    Concerning
    Ignacio

    [My blog | http://oracledisect.blogspot.com]

  • What are the ways to vCenter 5.1 5.0?

    I have vCenter 5.0 with joint hosts, most of them is ESX 4.0, two of them is a 5.0 ESXi. I would like to upgrade vCenter to 5.1.

    What is the best and least disruptive to do? I am considering an upgrade in place against the construction of a new 5.1 vcenter and then migrate all hosts in

    This vCenter. What is the best and least disruptive to do? Both are considered as valid ways to achieve the same goal?

    Thank you

    Another option that you have, and the way I just made, must continue to operate your vCenter 5.0. Start the installation for the SSO to the ISO 5.1 and get that working first. It is not interact with 5.0, so you should not spoil anything. Once you have that working, you can install the WebClient service too and also get that works - it interacts with SSO, then you can experiment and make sure it's all happy. Once all this is done, take your time, and then do the rest of the upgrade to vCenter 5.1.

    I guess ours was a fairly simple installation - we run all services on the same Windows Server vcenter, and we were already in SQL 2008, so it was not too serious - it was with 13 ESXi5.0 9 ESXi4.1 hosts and about 180 guests.

    The WebClient/SSO Service took me a few hours to do in February, and the last part of the upgrade to vCenter took a few hours of time to do last week. Of course, you can add another + 2 hours for installation of syslog, dumper, autodeploy, vShield and other pieces that you have.

    My biggest fear was of all the horror stories I had heard about the SSO installation, that is why I am and out of the way first.

    Of course, I'm always build and test my image ISO ESXi5.1 of installation etc.

    G

  • What is the way to place a background Image in a Div?

    I searched Google and Adobe forums for a while now, and although there are very valid solutions for similar problems I discovered that none of them fixed the problem that I am facing. I blame myself and get lost in this encoding sloppy mine, so part of my plan was to start my stylesheet from scratch.

    My question, what is the right way to add a background image in a div? I currently have the div albums following the css style "header", here's what I typed in this section:

    < style type = "text/css" >

    @import url("..) ("/ twoColLiqLtHdr.css");

    . Header {}

    Width: 1000px;

    height: 300px;

    background-image: url(Assets/HeaderTemplate.png);

    background-repeat: no-repeat;

    background-position: center;

    }

    The problem here is that the background image is not still appear. I would appreciate help, could someone inform me on how to do this so that I can implement images in div in the future without turning my coding in a bottom right mess?

    Thank you in advance.

    Try changing it to:

    background-image: url('Assets/HeaderTemplate.png');

    Also make sure you have the case appropriate for file names: for example

    Assets = active

    HeaderTemplate = headertemplate

    etc etc.

    Sometimes these things create problems.

    Good luck.

  • How to downgrade to iOS6? IPad 2 no longer works at decent speed after improvement of iOS 9. What is the new marketing strategy?

    After "redevelopment" of iOS6 to iOS9, I couldn't use my ipad 2 at a decent speed. Even when most of the applications have been closed. I had the same problem with another product apple a few years ago. The new OS also made the unit to slow to use. The so-called update destryoed functionality. I want the option to revert to iOS 6. Please, I beg you!

    There is no possibility of return.

  • After installation of XP SP3 error, "cannot locate the Microsoft FoxPro support library".

    I've recently updated to service pack 3. When I try to open a program I use, it says "Cannot locate the Microsoft FoxPro support library". The program is run when I had service pack 2. Am I missing something with service pack 3?

    Hello

    Post your query in Visual FoxPro forums to improve the assistance:

    http://social.msdn.Microsoft.com/forums/en-us/visualfoxprogeneral/threads

    You can check the link where another customer a similar question below:

    http://social.msdn.Microsoft.com/forums/en-us/visualfoxprogeneral/thread/57918732-e804-456a-B506-6eaf0dc75bd5/

Maybe you are looking for