Note that there are some explanatory texts on larger screens.

plurals
  1. POUpdating Column B Value with Clumn A Old Value
    text
    copied!<p>Created the following VendorAccount Table</p> <pre><code>VendorAccount (Ven_AccountId, Ven_RegNo, Ven_Invoice_RefNo, TotalAmount, Paid_ToVen , Balance ) </code></pre> <p>In the above table the value of TotalAmount is came from another Table(<code>Vendor_InvoiceDetails</code>).The TOTALBALANCE value is selected through POPUP LOV.</p> <p>The <code>Pad_TOVEN</code> amount is subtracted from <code>TOTALAMOUNT</code>(<code>TotalAMount-Pad_TOVEN</code>).When ever i select <code>TOTALAMOUNT</code> it gives me the old <code>TOTAL VALUE</code> as shown below in picture. <img src="https://i.stack.imgur.com/d2LG7.png" alt="enter image description here"></p> <p>I want the updated the value.When ever i select TotalAmount it should give me the new updated value on the basis of <code>Ven_Invoice_RefNo</code> i-e 2300 in <code>TotalAmount</code> Column in new entry. Below is the trigger but it has the fallowing error</p> <p>ERROR: <code>PLS-00103: Encountered the symbol "DECLARE" when expecting one of the following: begin function pragma procedure subtype type &lt;an identifier&gt; &lt;a double-quoted delimited-identifier&gt; current curs</code></p> <p>Trigger:</p> <pre><code>create or replace trigger "VENDORACCOUNT_T2" BEFORE insert or update or delete on "VENDORACCOUNT" for each row begin DECLARE new_balance INT; DECLARE new_total INT; DECLARE new_paid INT; SELECT balance INTO old_balance, total INTO old_total, PAID_TOVEN INTO new_paid FROM vendoraccount WHERE ven_regno = new.ven_regno AND VEN_INVOICE_REFNO = new.VEN_INVOICE_REFNO; UPDATE vendoraccount SET TOTALAMOUNT = old_total + old_balance - new_paid, balance = TOTALAMOUNT - new_paid WHERE VEN_REGNO= new.VEN_REGNO AND VEN_INVOICE_REFNO = new.VEN_INVOICE_REFNO; end; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload