Check if a field value is already in the database
You should use hook_node_validate
This allows you to return error on the specific field that fails.
e.g.

if($query-&gt;rowCount() &gt; 0) {
  form_set_error('machine_name', t('There already exists another node with same machine name - machine name has to be unique.'));
  // where machine_name is the field in this example
}

You wanna check database if value exists.
Can you elaborate exactly what you wanna check? Is it to ensure a specific field only contains unique values?