Logo Search packages:      
Sourcecode: freetds version File versions

int tds_submit_query ( TDSSOCKET *  tds,
const char *  query 

tds_submit_query() sends a language string to the database server for processing. TDS 4.2 is a plain text message with a packet type of 0x01, TDS 7.0 is a unicode string with packet type 0x01, and TDS 5.0 uses a TDS_LANGUAGE_TOKEN to encapsulate the query and a packet type of 0x0f.

query language query to submit

Definition at line 69 of file query.c.

References tds_client_msg(), tds_flush_packet(), tds_put_string(), and tds_submit_query().

Referenced by tds_connect(), and tds_submit_query().

      int query_len;

      if (!query)
            return TDS_FAIL;

      /* Jeff's hack to handle long query timeouts */
      tds->queryStarttime = time(NULL);

      if (tds->state == TDS_PENDING) {
            tds_client_msg(tds->tds_ctx, tds, 20019, 7, 0, 1,
                         "Attempt to initiate a new SQL Server operation with results pending.");
            return TDS_FAIL;


      tds->rows_affected = 0;
      tds->state = TDS_QUERYING;

      query_len = strlen(query);
      if (IS_TDS50(tds)) {
            tds->out_flag = 0x0F;
            tds_put_byte(tds, TDS_LANGUAGE_TOKEN);
            tds_put_int(tds, query_len + 1);
            tds_put_byte(tds, 0);
            tds_put_n(tds, query, query_len);
      } else {
            tds->out_flag = 0x01;
            tds_put_string(tds, query, query_len);
      return tds_flush_packet(tds);

Generated by  Doxygen 1.6.0   Back to index