Validate text format when render page
Assuming the inserts are taking place on field tables (e.g. field_data_body, field_data_field_MACHINE_NAME), you shouldn't insert NULL into the *_format columns. Rather, you should be inserting the machine name of your desired filter format (e.g. filtered_html for Filtered HTML or full_html for Full HTML). See the filter_format table for all available machine names for your installation.