Skip to content
Advertisement

Failing to produce or update a table row using a trigger in SQL

I am trying to create a trigger in Oracle SQL 12c.

The concept is that i have two tables, a storage table (Storage) that holds items and a delivery table (Supplier_Orders) that notes how many items(Units) are being delivered to the storage. The trigger is supposed to detect whether an item that is being delivered to the storage (new_product_id) already exists in the storage(product_id), and if not it automatically adds it and also asks the user to input some mandatory values(barcode and sell_price). If it does exist, it updates the table by adding the items being delivered (Units) to the total of items(remaining_units).

The errors produced are the following:

Error(5,5): PL/SQL: Statement ignored

Error(5,31): PLS-00405: subquery not allowed in this context

Error(10,5): PL/SQL: Statement ignored

Error(10,34): PLS-00405: subquery not allowed in this context

Advertisement

Answer

The Subquery is not allowed at PL/SQL, after IF condition in your code. It’s allowed only in SQL.

You can use a variable to check the “product_id” in the “storage” table and determine the IF condition on it.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement