Trigger with a transfer error

I had a problem in class that to define a trigger that would update a sales table when an order has been placed (this information is stored in another table). Thanks for any help.

The Question in the gist:

A trigger is needed so that every time an order is confirmed (when ORDERPLACED is set to 1 in the table bb_basket) the bb_sale_sum table is updated accorddingly.

This is my code so far:

CREATE OR REPLACE TRIGGER bb_salesum_trg
After the UPDATE of orderplaced WE bb_basket
for each line
When (old.orderplaced <>1 and new.orderplaced = 1).
declare
Number of lv_tot_num (7.2);
Number of lv_qty_num (7.2);
number of lv_id_num (3,0);
Start
Select b, b.quantity, bi.idproduct
in lv_tot_num, lv_qty_num, lv_id_num
of bb_basket b, bb_basketitem bi
where bi.idbasket = b.idbasket;
Update bb_sales_sum
Set tot_qty = tot_qty + lv_qty_num
where idproduct = lv_id_num;
Update bb_sales_sum
Set tot_sales = tot_sales + lv_tot_num
where idproduct = lv_id_num;
END;
/

Update bb_basket
Set orderplaced = 1
where idbasket = 3;


And then my mistake:

Error from the 281 in command line:
Update bb_basket
Set orderplaced = 1
where idbasket = 3
Error report:
SQL error: ORA-04091: table SYSTEM. BB_BASKET is changing, function of triggering/can not see
ORA-06512: at "SYSTEM. BB_SALESUM_TRG', line 6
ORA-04088: error during execution of trigger ' SYSTEM. BB_SALESUM_TRG'
04091 00000 - "table %s.%s is changing, function of triggering/can not see.
* Cause: A trigger (or plsql user-defined function that is referenced in)
This statement) attempted to watch (or modify) a table that has been
in the Middle being modified by the statement that shot.
* Action: Rewrite the trigger (or function) so it does not read this table.


* I guess I get this error because I try to use TOT_QTY & TOT_SALE of my most while I'm updateing as column.* *.


Here are three tables I think I need for this problem:

CREATE TABLE bb_Basket)
idBasket number (5),
Quantity number (2),
idShopper number 4,
OrderPlaced number (1).
Total part number (7.2).
The number total (7.2).
Number (5.2) of the expedition.
Number (5.2) tax.
date of dtCreated by DEFAULT SYSDATE,
Promo number (2),
ShipFirstName varchar2 (10),
ShipLastName varchar2 (20).
ShipAddress varchar2 (40),
ShipCity varchar2 (20).
ShipState varchar2 (2),
ShipZipCode varchar2 (15).
ShipPhone varchar2 (10),
ShipFax varchar2 (10),
ShipEmail varchar2 (25).
BillFirstName varchar2 (10),
BillLastName varchar2 (20).
BillAddress varchar2 (40),
BillCity varchar2 (20).
BillState varchar2 (2),
BillZipCode varchar2 (15).
BillPhone varchar2 (10),
BillFax varchar2 (10),
BillEmail varchar2 (25).
date of dtOrdered by DEFAULT SYSDATE,
ShipProvince varchar2 (20).
ShipCountry varchar2 (20).
BillProvince varchar2 (20).
BillCountry varchar2 (20).
CardType char(1),
CardNumber varchar2 (20).
ExpMonth tank (2),
ExpYear char (4),
CardName varchar2 (25).
char (1) default 'n' shipbill,
Default char (1) ShipFlag 'n',
Bskt_id_pk KEY (idBasket) PRIMARY, the CONSTRAINT
CONSTRAINT bskt_idshopper_fk FOREIGN KEY (idShopper)
REFERENCES bb_Shopper (idShopper));
Create sequences bb_idBasket_seq
start with 25;
insert into bb_basket (idbasket, quantity, idshopper, orderplaced, partial, total, shipping, tax, dtcreated, promo)
values (3, 3, 21, 1, 26.60, 32.40, 5.00,.80, 23 January 07 ', 0);
insert into bb_basket (idbasket, quantity, idshopper, orderplaced, partial, total, shipping, tax, dtcreated, promo)
values (4, 1, 21, 1, 28.50, 34.36, 5.00,.86, 12 February 07 ', 0);
insert into bb_basket (idbasket, quantity, idshopper, orderplaced, partial, total, shipping, tax, dtcreated, promo)
values (5, 4, 22, 1, 41,60, 48,47, 5.00, 1.87, 19 February 07 ', 0);
insert into bb_basket (idbasket, quantity, idshopper, orderplaced, partial, total, shipping, tax, dtcreated, promo)
values (6, 3, 22, 1, 149.99, 161,74, 5.00, 6.75, 1 March 07 ', 0);
insert into bb_basket (idbasket, quantity, idshopper, orderplaced, partial, total, shipping, tax, dtcreated, promo)
values (7, 2, 23, 1, 21.60, 27.25, 5.00,.65, 26 January 07 ', 0);
insert into bb_basket (idbasket, quantity, idshopper, orderplaced, partial, total, shipping, tax, dtcreated, promo)
values (8, 2, 23, 1, 21.60, 27.25, 5.00,.65, 16 February 07 ', 0);
insert into bb_basket (idbasket, quantity, idshopper, orderplaced, partial, total, shipping, tax, dtcreated, promo)
values (9, 2, 23, 1, 21.60, 27.25, 5.00,.65, 2 March 07 ', 0);
insert into bb_basket (idbasket, quantity, idshopper, orderplaced, partial, total, shipping, tax, dtcreated, promo)
values (10, 3, 24, 1, 38.90, 45,65, 5.00, 1.75, 7 February 07 ', 0);
insert into bb_basket (idbasket, quantity, idshopper, orderplaced, partial, total, shipping, tax, dtcreated, promo)
values (11, 1, 24, 1, 10: 00 am, 3:45 pm, 5.00,.45, 27 February 07 ', 0);
insert into bb_basket (idbasket, quantity, idshopper, orderplaced, partial, total, shipping, tax, dtcreated, promo)
values (12, 7, 25, 1, 72,40, 83,66, 8.00, 3.26, 19 February 07 ', 0);
insert into bb_basket (idbasket, quantity, idshopper, orderplaced, partial, total, shipping, tax, dtcreated, promo)
values (13, 2, 26, 0, 20 h 00, 0, 0, 0, 9 February 07 ', 0);
insert into bb_basket (idbasket, quantity, idshopper, orderplaced, partial, total, shipping, tax, dtcreated, promo)
values (14, 0, 26, 0, 0, 0, 0, 0, 10 February 07 ', 0);
Update bb_basket
Set dtordered = dtcreated;
Update bb_basket
Set dtordered = NOTHING
where orderplaced = 0;

CREATE TABLE bb_basketItem)
idBasketItem number (2),
idProduct number (2),
Price number (6.2),
Quantity number (2),
idBasket number (5),
option 1 number (2),
option2 number (2),
CONSTRAINT bsktitem_id_pk PRIMARY KEY (idBasketItem).
CONSTRAINT bsktitem_bsktid_fk FOREIGN KEY (idBasket)
REFERENCES bb_Basket (idBasket),
CONSTRAINT bsktitem_idprod_fk FOREIGN KEY (idproduct)
REFERENCES bb_Product (idproduct));
Create sequences bb_idBasketitem_seq
start with 50;
insert into bb_basketItem
values (15, 6, 5.00, 1, 3, 1, 4);
insert into bb_basketItem
values (16, 8, 10.80, 2, 3, 2, 4);
insert into bb_basketItem
values (17, 4, 28.50, 1, 4, NULL, NULL);
insert into bb_basketItem
values (18, 7, 10.80, 1, 5, 2, 3);
insert into bb_basketItem
values (19, 8, 10.80, 1, 5, 2, 3);
insert into bb_basketItem
values (20, 9, 10 h 00, 1, 5, 2, 3);
insert into bb_basketItem
values (10, 21, 10 h 00, 1, 5, 2, 3);
insert into bb_basketItem
values (22, 10, 10: 00, 2, 6, 2, 4);
insert into bb_basketItem
values (23, 2, 129.99, 1, 6, NULL, NULL);
insert into bb_basketItem
values (24, 7, 10.80, 1, 7, 2, 3);
insert into bb_basketItem
values (25, 8, 10.80, 1, 7, 2, 3);
insert into bb_basketItem
values (26, 7, 10.80, 1, 8, 2, 3);
insert into bb_basketItem
values (27, 8, 10.80, 1, 8, 2, 3);
insert into bb_basketItem
values (28, 7, 10.80, 1, 9, 2, 3);
insert into bb_basketItem
values (29, 8, 10.80, 1, 9, 2, 3);
insert into bb_basketItem
values (30, 6, 5.00, 1, 10, 1, 3);
insert into bb_basketItem
values (31, 8, 5.40, 1, 10, 1, 3);
insert into bb_basketItem
values (32, 4, 28.50, 1, 10, NULL, NULL);
insert into bb_basketItem
values (33, 9, 10 h 00, 1, 11, 2, 3);
insert into bb_basketItem
values (34, 8, 10.80, 2, 12, 2, 3);
insert into bb_basketItem
values (35, 9, 10 h 00, 2, 12, 2, 3);
insert into bb_basketItem
values (36, 6, 10 h 00, 2, 12, 2, 3);
insert into bb_basketItem
values (37, 7, 10.80, 1, 12, 2, 3);
insert into bb_basketItem
values (38, 9, 10 h 00, 2, 13, 2, 3);
CREATE TABLE bb_sales_sum
(idProduct NUMBER (2),)
tot_sales NUMBER (7.2).
tot_qty, NUMBER (5.2));
INSERT INTO bb_sales_sum (idProduct, tot_sales, tot_qty)
VALUES (6, 100, 10);
INSERT INTO bb_sales_sum (idProduct, tot_sales, tot_qty)
VALUES (8, 100, 10);

>
Well, I didn't belive that's what I do.
>
Well that's exactly what you do

select b.total, b.quantity, bi.idproduct
into lv_tot_num, lv_qty_num, lv_id_num
from bb_basket b, bb_basketitem bi
where bi.idbasket = b.idbasket;

you query the table bb_basket ('from bb_basket') inside the trigger that updates the bb_baske table. This will give the error table mutation as just pointed out.

Tags: Database

Similar Questions

  • What is wrong with this sequence, it does not work when, after 3 inserts, I add a new record with the trigger it gives an error.

    Mr President.

    What is wrong with this sequence, it does not work when, after 3 inserts, I add a new record with the trigger it gives an error.

    --SL_CUSTOMERS table data
    
    
    INSERT INTO SL_CUSTOMERS VALUES(1,'Kamrul Hasan',NULL,NULL,'Moghbazar', 'Dhaka','0456789123',NULL,NULL,NULL,'Y',NULL);
    INSERT INTO SL_CUSTOMERS VALUES(2,'Rabiul Alam',NULL,NULL,'Motijheel', 'Dhaka','0567891234',NULL,NULL,NULL,'Y',NULL);
    INSERT INTO SL_CUSTOMERS VALUES(3,'Shahed Hasan',NULL,NULL,'2-G/1,2-2,Mirpur', 'Dhaka','0678912345',NULL,NULL,NULL,'Y',NULL);
    
    
    
    

    CREATE SEQUENCE  "ALIZA"."SL_CUSTOMERS_SEQ"  MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 1 NOCACHE NOORDER  NOCYCLE ;
    
    
    CREATE OR REPLACE TRIGGER SL_CUSTOMERS_TRG 
    BEFORE INSERT ON "ALIZA"."SL_CUSTOMERS"   
    FOR EACH ROW   
    BEGIN   
    IF :NEW.CUSTOMER_ID IS NULL OR :NEW.CUSTOMER_ID < 0 THEN  
      SELECT SL_CUSTOMERS_SEQ.nextval   
        INTO :NEW.CUSTOMER_ID  
        FROM DUAL;   
      END IF;   
    END;   
    /
    
    
    
    

    When I try to insert several records with the seq.nextval it gives error

    violation of primary key.

    INSERT INTO "ALIZA"."SL_CUSTOMERS" (CUSTOMER_NAME) VALUES ('sdfsd')
    ORA-00001: unique constraint (ALIZA.SL_CUSTOMERS_PK) violated
    ORA-06512: at line 1
    
    
    
    
    One error saving changes to table "ALIZA"."SL_CUSTOMERS":
    Row 4: ORA-00001: unique constraint (ALIZA.SL_CUSTOMERS_PK) violated
    ORA-06512: at line 1
    
    
    
    
    
    
    
    

    Concerning

    Mr President.

    I find the solution by creating a function before the triiger

    as below

    CREATE SEQUENCE  "ALIZA"."SL_CUSTOMERS_SEQ"  MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 1 NOCACHE NOORDER  NOCYCLE ;
    
    CREATE OR REPLACE FUNCTION get_SL_CUSTOMERS_vId RETURN VARCHAR2 AS
    BEGIN
       RETURN SL_CUSTOMERS_SEQ.NEXTVAL;
    
    END;
    /
    
    CREATE OR REPLACE TRIGGER SL_CUSTOMERS_TRG
    BEFORE INSERT ON "ALIZA"."SL_CUSTOMERS"
    FOR EACH ROW
    DECLARE
    dummy VARCHAR2(200);
    BEGIN
      dummy := get_SL_CUSTOMERS_vId();
      :NEW.CUSTOMER_ID := dummy;
    END;
    /  
    

    It works very well

    Thank you all for the suggestions.

    Concerning

  • Who installed Procomm Plus - error message: file transfer error general error 119

    Anyone tried to install ProComm Plus more. Just could not get it to load fails on an iswinapi.dll of the GET the error message:
    Error - 119 target general file transfer error-check

    Hello

    It seems that the Symantec has designed this ProComm Plus application
    Why n t ask the company to Symantec for advice and support.
    The support guys generally have more experience with clean products

  • I tried to install TimeQPlus v 4.0.32 A Windows Server 2008 R2, and it gives me "feature transfer error".

    When I tried to install TimeQPlus v 4.0.32 presence & software in Windows Server 2008 R2, the error message next time will appear and will not let me install the software. I have the privilege on the server.

    Feature transfer error

    Function:         NewFeature
                                 Component: Client Application
                              File:                D:\Data2.cab
                               Error: incorrect function

    Can someone help me with this problem? Thank you

    Hello

    Your question (Windows 7/Vista/XP) is more complex than what is generally answered in the Microsoft Answers forums. It is better suited for the IT Pro TechNet public. Please ask your question in the Forum on TechNet Support. You can follow the link to your question:
    http://social.technet.Microsoft.com/forums/en-us/categories/

  • Feature Transfer Error 1612

    Trying to install a new driver for a USB adapter wireless from a CD, the installation program stops with a message "feature transfer error:-1612 the installation source for this product is not available." Verify that the source exists and that access you. The reason that it is said that the source is not available, it's that his tent to read in the 'A' driving instead of the Conference on disarmament. I downloaded a new copy of the installer from the manufacturer of the adapter and it ran from the 'C' drive, but with the same result. I disconnected the drive 'A' and rebooted and restarted the CD of installation but once again had the same error.  I ran the installation CD on another PC without any problem. Both running XP Pro SP3. How can I fix? There's another similar thread in this forum, but it does not mention that the program is trying to access the drive 'A' and most of this thread is not relevant to my problem.

    I finally got the installer to work. It was a relocation of an already corrupt driver. I made a backup of the complete registry and then used regedit to find and remove all the references I found to the previous file. I rebooted and ran the installer, and it worked.

  • Error install civ 4, "feature transfer error".

    I am running windows 7 and trying to install civ4. When you download the 2nd disc it says "feature transfer error" (cyclic redundancy check data error check) if any body know wat this means or can help out me that would be great.

    Hello

    Please continue with the following steps to support...

    http://www.Microsoft.com/downloads/en/details.aspx?FamilyId=2da43d38-DB71-4C1B-bc6a-9b6652cd92a3&displaylang=en

    http://answers.Microsoft.com/en-us/Windows/Forum/Windows_7-gaming/getting-Civilization-IV-to-work-with-Windows-7/f7420698-91aa-47C0-a862-8f0c0cef30a3

    http://www.Microsoft.com/games/en-us/games/pages/civilizationivcomplete.aspx

    http://www.CivFanatics.com/civ4/

    Thank you

    Aaron

  • Cannot download BAR file for PlayBook. "Transfer error".

    I tried to download my file .bar for playbook for 3 days now, but I keep getting errors. My .bar file is 50 MB in size, I don't know if the size is causing this problem. I tried several browsers: IE, Firefox, Chrome and Safari.

    What happens when the upload 100% or I get an error message saying "Transfer error has occurred" or the progress bar jump down to 1% and stays there until the site times out and I have to log in again.

    I tried both my click "Add filebundle".bar file buttons 'Import Batch files. "

    I tried to download my app as a .bar file and also compress the .bar in a zip file. . Bar or .zip worked using "Import Batch files" or "add a filebundle.

    I know that my .bar file is not damaged and that it is signed correctly because I am able to deploy in the PlayBook and it works perfectly.

    If I use Firefox, I always get the "transfer error occurred" error and when I use IE bar always jumps to 1% of the increase and the Web site times out.

    Has anyone of another been able to download a file of 50 MB ot more high? I see the game to PlayBook that are big more than 300 MB, so I guess that 50 MB is OK.

    Is anyone else able to download a file to all .bar the anysize?

    Thanks in advance

    Ok. I put in a ticket and received a response from Blackberry that there is currently a problem with the download of large files.

    If the person supported offered Blackberry download my file for me and my game is finally approved and live on the PlayBook. Thanks to all for your responses.

    Blackberry support said they are working on fixing it so if someone runs into a problem of downloading a large file (don't know the size limits, my record was 50 MB) don't forget to put in a support ticket, so you don't waste a lot of time

  • CanoScan 4200F gives error - "Twain data transfer error".

    I have a new Windows 7 PC and unable to use CanoScan 4200F, he returns with "Twain data transfer error".  Worked fine with Windows XP.  What should I do

    to make it work?

    Check the manufacturers technical support for latest drivers site, they have Windows 7 drivers that you can download and install. Download little correct level for your computer - 32 or 64 bit - and then install them.

    CanoScan 4200F drivers:
    http://www.USA.Canon.com/Cusa/support/consumer/scanners/canoscan_series/canoscan_4200f?selectedName=DriversAndSoftware

    To see if you have Windows 7 32-bit or 64-bit:

    1. Open system by clicking the Start button, right-click computer, and then clicking Properties.
    2. Under system, you can view the type of system, it will say 32 or 64 bits.
  • trigger with: new and: old to compare the values

    Jin
    I want to use the trigger with: new: old to compare the old values with new ones.
    I have an employee of the table

    Name Null? Type
    ENO NOT NULL NUMBER 4
    ENAME VARCHAR2 (20)
    SALARY NUMBER (10.2)

    now I want to set up a trigger so that it checks everything by inserting the values as part of if
    the insertion of salary value is greater than the last salary (line) table. If it fails, then it will be
    raises an application error.
    I can't write this code as is return errors.
    Thank you

    Published by: user13371438 on Sep 6, 2010 03:00

    Please share the code you have written to achieve so far.

  • Help!  Get pop-ups with CODE of ERROR: sec_error_X1X510_A

    I have an iMAC end of 2012, 3.4 GHz Intel Core i7, 16 GB 1600 MHz DDR3. NVIDIA GeForce GTX 680MX 2048 MB, El Capitan iOS

    When you use Safari, Google home page, I type a domain and it goes to what I believe is a pop-up fake Apple Support with CODE of ERROR: sec_error_X1X510_A.

    Need help solving this. THX

    You have probably installed some adware. Please post a report of EtreCheckof your system. We then look for obvious problems. Please click on the link, download the application and run the report. Once you have the report, please copy and paste into your response to this post.

    If you would like more information on what is EtreCheck, just click on the link and you will find a description of the application.

  • Using Firefox 4 and Windows 7. Whenever I have to start Firefox from a shortcut to a Web site, what happens with the following error "there was a problem sending the command to the program". The requested site is loaded after that. without any problem.

    Using Firefox 4 and Windows 7. Whenever I have to start Firefox from a shortcut to a Web site, what happens with the following error "there was a problem sending the command to the program". The requested site is loaded after that. without any problem.

    If a shortcut is used while Firefox is already open the error will not occur.

    For me, the problem was the FoxClock extension. Once I disabled it, the problem was gone.

    Hope this helps.

    Olivier

  • HP Officejet 4632: hp officejet with an OXC4EB827F error code 4632

    I have a hp officejet 4632 with an OXC4EB827F error code and does not work, also the power button blinks continuously.  Tried the reset how to print HP and doctor Scan and it did not help, there is no response from the printer.  Any help would be apprciated as two years out of warranty.

    Hello!

    Welcome to HP's Forums a great way to get help.

    Thanks for your post. I see that you have a problem with your printer "HP Officejet 4632" that gives you an error message "OXC4EB827F".

    It looks like a hardware problem with the printer.

    Please try this link on the HP forum is the author of X-23 an HP Forum Expert certified. There is a link for the same series of the printer, but not the exact model of printer.

    Link:

    http://HP.care/2bP97Dx

    If this fails, contact HP Technical Support for your printer using this link service:

    http://HP.care/2bGzo6g

    I hope this helps! Let me know how it goes.

    Take care and have a nice day.

  • Satellite 5200 701 begins with SHLWAPI.dll error code

    My Satellite 5200 701 comes with SHLWAPI.dll error code, thn stops.

    Any help would be grateful!

    You can start your laptop in safe mode?

  • I can't convert Excel - it continues to flow upward with an unexpected error!

    I am trying to convert an invoice in Excel, but it continues to flow upward with an unexpected error. Help, please!

    Clear salvation,

    It is a forum of numbers. You can have better luck on an Excel forum.

    Quinn

  • HP Setup crashes with a runtime error for interface C309-m software

    I am running Windows 7 64 bit.  All operating system updates are installed.

    I need to update the software to interface with my printer HP Photosmart Premium C309-m.  The current software is out of date.  I can't start the scan from the printer, and only my account on the computer recognizes that I have a printer.  Several analysis diagnosis on the State of HP Scan Doctor tool that some software components seem to be missing.  The printer itself seems to work very well.

    When I try to update the software C309-m via HP Print/Scan doctor, software downloads, extracted, then runs and crashes with a runtime error.  The error box comes from the Microsoft Visual C++ run-time library and the crash of Setup runs is the appdata/local/temp/7zS3DA1 directory that I seem to have several similar directories that were not cleaned from previous installation attempts.

    Any suggestions on how to get a successful installation of the C309-m software would be appreciated.

    Hi Ken50,

    I would recommend selecting the Uninstall_L3.bat.

    Please let me know how it goes.

Maybe you are looking for