Note that there are some explanatory texts on larger screens.

plurals
  1. POOracle SQL PLS-00049: bad bind variable
    primarykey
    data
    text
    <p>I'm getting this error which seems to be an issue with column spelling. However I am 99% percent sure I have spelled everything correct, but I can't see any reason to be getting the error I do...</p> <p>Here's the source:</p> <pre><code>CREATE OR REPLACE TRIGGER update_qoh_trigger AFTER INSERT ON sales FOR EACH ROW DECLARE v_qoh products.qoh%TYPE; v_new_qoh products.qoh%TYPE; BEGIN SELECT qoh INTO v_qoh FROM products WHERE id = :new.product_id; v_new_qoh := v_qoh - new.quantity; // ERROR HERE UPDATE products SET qoh = :v_new_qoh WHERE id = :new.product_id; END; / sho err </code></pre> <p>And that gives a:</p> <pre><code>12/12 PLS-00049: bad bind variable 'V_NEW_QOH' </code></pre> <p>I have tried replacing line 12 with the following combinations:</p> <ul> <li><code>v_new_qoh := :v_qoh - :new.quantity;</code></li> <li><code>:v_new_qoh := :v_qoh - :new.quantity;</code></li> <li><code>:v_new_qoh = :v_qoh - :new.quantity;</code></li> <li><code>:v_new_qoh := v_qoh - :new.quantity;</code></li> <li><code>:v_new_qoh := :v_qoh - new.quantity;</code></li> <li><code>v_new_qoh := v_qoh - :new.quantity;</code></li> </ul> <p>But it still gives me the error.</p> <p>The products table looks like this:</p> <pre><code>CREATE TABLE products ( id NUMBER, name VARCHAR2, price NUMBER, qoh NUMBER(2) ); CREATE TABLE sales ( id NUMBER(10) AUTO_INCREMENT, customer_id NUBMER(3), product_id NUMBER(3), quantity NUMBER(2), price NUMBER(5,2), sale_date DATE, despatch_id NUMBER(10) ); </code></pre> <p>Thanks in advance for your help.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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