db_insert error delta "doesn't have a default" When I execute this code:

db_insert('field_data_field_room_rates')
    -&gt;fields(array(
      'entity_type' =&gt; 'node',
      'bundle' =&gt; 'rooms',
'entity_id' =&gt; $roomno,
'revision_id' =&gt; 0,
'field_room_rates_target_id' =&gt; $mynode-&gt;nid
    ))
    -&gt;execute();


It returns back an error saying "General error: 1364 Field 'delta' doesn't have a default value".  Any quick way to work around this without doing a count to respect the order?  I don't want to give it an arbitrary number.

Thanks in advance!
Without knowing the circumstances, I think you might better off loading your node,  adding to the field array, then using the node save function. But if you want to stick with DB operations, you could retrieve the next highest cardinality with this query:

  $next_delta = db_select('field_data_field_room_rates','rates')
    -&gt;fields('rates', array('delta'))
    -&gt;condition('entity_id', $mynode-&gt;nid)
    -&gt;condition('revision_id', $mynode-&gt;vid)
    -&gt;orderBy('delta','DESC')
    -&gt;range(0,1)
    -&gt;execute()-&gt;fetchField() + 1;