title: How to use select into a local variable in SYBASE ASE
body: <p>i am using Sybase ASE 15.0.3. and i want to use this type of logic, but it gives me error.</p>
  
  <pre><code>begin
  declare 
  @b int, @c int
  
  select      @b = Count(My_ID) 
  FROM        some_table
  WHERE       (some_condition);
  
  
  select      @c = Count(My_Sales) 
  FROM        some_table
  WHERE       (some_condition);
  
  
  insert into my_table (new_id, new_sales) value (@b, @c);
  
  end;
  </code></pre>
  
  <p>and then use these variables to insert value into a table.</p>
  
  <p>ERROR: "Attemp to insert null value into "new_id", table "my_table" column doesn't allow nulls. Update fails"</p>