changed function get_record_sql to get_field_sql