on 2023 Mar 21 5:52 AM
With SQL Server, I developed a trigger that would be triggered anytime data was added to a certain table, in this instance FORECAST TEST DATA. The trigger was to subsequently insert certain data from the inserted row into a table named the PRODUCT TEST DATE table, as seen in this example. The other columns in the database were then to be populated with values already present in the table, utilizing products with the same PROD NUM value. Query:
CREATE OR ALTER TRIGGER FORECAST_TRIGGER ON FORECAST_TEST_DATA FOR INSERT AS INSERT INTO PRODUCT_TEST_DATA (PRODUCT_TEST_DATA.PROD_NUM, PRODUCT_TEST_DATA.MONTH, PRODUCT_TEST_DATA.STORE_TYPE, PRODUCT_TEST_DATA.PRODUCT_KEY, PRODUCT_TEST_DATA.CATEGORY, PRODUCT_TEST_DATA.BRAND_NAME,PRODUCT_TEST_DATA.COLOUR) SELECT inserted.PROD_NUM, inserted.MONTH, inserted.STORE_TYPE, inserted.PRODUCT_KEY, PRODUCT_TEST_DATA.CATEGORY, PRODUCT_TEST_DATA.BRAND_NAME,PRODUCT_TEST_DATA.COLOUR FROM inserted, PRODUCT_TEST_DATA WHERE inserted.PROD_NUM = PRODUCT_TEST_DATA.PROD_NUM GO
This issue has hampered my development on the project, and I'm not sure how to proceed. The needed functionality is already included in the trigger; it only has to be rebuilt in Oracle SQL.
Request clarification before answering.
Oracle uses :old and :new to determine the "old" values in a table vs "new" values being inserted into a table. You also need to determine if you you want the trigger to fire BEFORE inserting new values, or AFTER the insert. Check online Oracle documentation re: BEFORE and AFTER triggers. Your example should be easy enough to port over to Oracle.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
52 | |
6 | |
5 | |
5 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.