pub fn encode_sql_batch_with_transaction(
sql: &str,
transaction_descriptor: u64,
) -> BytesExpand description
Encode a SQL batch request with a transaction descriptor.
Per MS-TDS spec, when executing within an explicit transaction:
- The
transaction_descriptorMUST 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 executetransaction_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);