encode_sql_batch_with_transaction

Function encode_sql_batch_with_transaction 

Source
pub fn encode_sql_batch_with_transaction(
    sql: &str,
    transaction_descriptor: u64,
) -> Bytes
Expand description

Encode a SQL batch request with a transaction descriptor.

Per MS-TDS spec, when executing within an explicit transaction:

  • The transaction_descriptor MUST be the value returned by the server in the BeginTransaction EnvChange token.
  • For auto-commit mode (no explicit transaction), use 0.

§Arguments

  • sql - The SQL text to execute
  • transaction_descriptor - The transaction descriptor from BeginTransaction EnvChange, or 0 for auto-commit mode.

§Example

use tds_protocol::sql_batch::encode_sql_batch_with_transaction;

// Within a transaction with descriptor 0x1234567890ABCDEF
let sql = "INSERT INTO users VALUES (1, 'Alice')";
let tx_descriptor = 0x1234567890ABCDEF_u64;
let payload = encode_sql_batch_with_transaction(sql, tx_descriptor);