Skip to content

Special Commands

Syntra ODBC extends standard SQL with several special commands for controlling cache behavior, voiding QuickBooks transactions, and managing the sync engine.

Controls how fresh the data must be when reading from the cache. The value is in seconds.

-- Force a live query, bypassing the cache entirely
SET QB_MAX_STALENESS = 0;
SELECT * FROM customers;
-- Accept data up to 5 minutes old
SET QB_MAX_STALENESS = 300;
SELECT * FROM invoices;

When you issue a SELECT query, Syntra checks the age of the cached data for that table:

  • If the cached data is fresher than QB_MAX_STALENESS, the query reads from the local cache.
  • If the cached data is older than QB_MAX_STALENESS, Syntra fetches live data from QuickBooks before returning results.

The default staleness is determined by the table’s polling tier:

TierDefault Staleness
Hot60 seconds
Warm180 seconds
Cold900 seconds
Frozen3600 seconds

Setting QB_MAX_STALENESS = 0 guarantees a live fetch from QuickBooks for every query. This is useful for debugging or verifying recent writes, but will be slower than cached reads.

The setting applies to the current session (connection) only.

Voids a transaction in QuickBooks. Unlike DELETE, which removes the transaction entirely, voiding preserves the transaction record with a zero amount, matching QuickBooks Desktop’s built-in void behavior.

CALL qb_void('Invoice', '12345-1234567890');
CALL qb_void('SalesReceipt', '67890-1234567890');
CALL qb_void('Bill', '11111-1234567890');
CALL qb_void('CreditMemo', '22222-1234567890');
CALL qb_void('Check', '33333-1234567890');
ParameterDescription
TxnTypeThe QuickBooks transaction type (e.g., Invoice, Bill, SalesReceipt, Check, CreditMemo, JournalEntry)
TxnIDThe transaction’s unique ID in QuickBooks
SELECT txn_id, ref_number, customer_ref_full_name, txn_date
FROM invoices
WHERE ref_number = 'INV-1001';

Then use the returned txn_id in the void call.

Forces a complete rebuild of the local cache by re-fetching all data from QuickBooks Desktop.

CALL qb_rebuild_all();
  • After making significant changes directly in QuickBooks Desktop
  • After adding new custom fields in QuickBooks
  • If the cache appears to be out of sync with QuickBooks
  • After upgrading Syntra ODBC to a new version
  • This operation can take several minutes depending on the size of your QuickBooks company file.
  • The server remains available during the rebuild. Queries will continue to serve data from the existing cache until the rebuild completes.
  • Do not run this command frequently. The incremental sync mechanism keeps the cache current for normal operations.

Forces an immediate sync of a specific table:

CALL qb_sync_table('customers');
CALL qb_sync_table('invoices');

This is more targeted than qb_rebuild_all() and completes much faster when you only need to refresh one table.

Lists all available QuickBooks tables:

SHOW TABLES;

Lists all columns for a specific table:

SHOW COLUMNS FROM customers;
SHOW COLUMNS FROM invoices;