Logo Search packages:      
Sourcecode: freetds version File versions

int tds_submit_unprepare ( TDSSOCKET *  tds,
TDSDYNAMIC *  dyn 
)

Send a unprepare request for a prepared query

Parameters:
tds db connection
dyn dynamic query
Returns:
TDS_SUCCEED or TDS_FAIL

Definition at line 635 of file query.c.

References tds_client_msg(), tds_flush_packet(), and tds_submit_unprepare().

Referenced by tds_submit_unprepare().

{
int id_len;

      if (!dyn)
            return TDS_FAIL;

      tdsdump_log(TDS_DBG_FUNC, "%L inside tds_submit_unprepare() %s\n", dyn->id);

      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;
      }

      /* TODO check this code, copied from tds_submit_prepare */
      tds_free_all_results(tds);
      tds->rows_affected = 0;
      tds->state = TDS_QUERYING;

      tds->cur_dyn = dyn;

      if (IS_TDS7_PLUS(tds)) {
            /* RPC on sp_execute */
            tds->out_flag = 3;      /* RPC */
            /* procedure name */
            tds_put_smallint(tds, 12);
            tds_put_n(tds, "s\0p\0_\0u\0n\0p\0r\0e\0p\0a\0r\0e", 24);
            tds_put_smallint(tds, 0);     /* flags */

            /* id of prepared statement */
            tds_put_byte(tds, 0);
            tds_put_byte(tds, 0);
            tds_put_byte(tds, SYBINT4);
            tds_put_int(tds, dyn->num_id);

            return tds_flush_packet(tds);
      }

      tds->out_flag = 0x0F;
      /* dynamic id */
      id_len = strlen(dyn->id);

      tds_put_byte(tds, TDS5_DYNAMIC_TOKEN);
      tds_put_smallint(tds, id_len + 5);
      tds_put_byte(tds, 0x04);
      tds_put_byte(tds, 0x00);
      tds_put_byte(tds, id_len);
      tds_put_n(tds, dyn->id, id_len);
      tds_put_smallint(tds, 0);

      /* send it */
      return tds_flush_packet(tds);
}


Generated by  Doxygen 1.6.0   Back to index