title: Unable to do update table from Apex 5 button Error mentions Cannot Insert NULL
body: <p>Hi People of the Palace</p>
  
  <p>I am not having luck here and tried a lot of things and seems as if I am not able to get the value from the field which needs to update.</p>
  
  <p>There are 2 fields within Apex 5 which I want to update if something if the value is changed from default. :QUANTITY which is a text field inside of a Tabular form and :DISC which is also a text field in the same row.
  There can be single or multiple rows to that needs to be updated and this is usually where you set the option "updated rows and columns only"</p>
  
  <p>The table SALES_TEMP does has columns <code>ID</code>, <code>NAME</code>, <code>QUANTITY_TO_SELL</code>, <code>DISCOUNT</code>.</p>
  
  <p>The PL/SQL code that is assigned in the process to do this update is as follows.</p>
  
  <pre><code>BEGIN
  update SALES_TEMP 
  set QUANTITY_TO_SELL=:QUANTITY, DISCOUNT=:DISC;
  end;
  </code></pre>
  
  <p>When I try and update the fields, it will return with </p>
  
  <blockquote>
    <p>Cannot insert NULL into QUANTITY_TO_SELL</p>
  </blockquote>
  
  <p>and similar with the DISCOUNT field.</p>
  
  <p>Now I know there is nothing wrong with the query because if I do this:</p>
  
  <pre><code>BEGIN
  update SALES_TEMP 
  set QUANTITY_TO_SELL='2', DISCOUNT='5';
  end;
  </code></pre>
  
  <p>It does in fact update the table, but it will then do this update to all rows in the table because I have no where clause.</p>
  
  <p>I have had a look through the different options and cannot seem to find why it does not select the data from the fields. My main issue is, I have an exact same query running doing an insert which works.</p>
  
  <p>Also from Apex's Sql Command line option if I run.</p>
  
  <pre><code>update SALES_TEMP 
  set QUANTITY_TO_SELL=:QUANTITY, DISCOUNT=:DISC;
  </code></pre>
  
  <p>I get a popup requesting values for <code>:QUANTITY</code> and <code>:DISC</code> and it then updates the columns so something tells me that this is not getting the values from these text fields.</p>
  
  <p>The SQL command to add to populate the fields are</p>
  
  <pre><code>select ID, NAME, QUANTITY_TO_SELL as QUANTITY, DISCOUNT as DISC from SALES_TEMP;
  </code></pre>
  
  <p>Obviously each gets assigned as <code>:ID</code>, <code>:NAME</code> <code>:QUANTITY</code> and <code>:DISC</code> in apex.</p>