Veeva VQL Formatter & Linter
Pretty-print, lint, and generate REST API cURL/fetch snippets for Veeva Vault Query Language (VQL) queries — 100% client-side.
VQL Linter
Your VQL syntax passes all static checks (balanced parentheses, quoted strings, clause order, and field rules).
Vault REST API Wrapper
curl -X POST "https://myvault.veevavault.com/api/v25.1/query" \
-H "Authorization: {session_id}" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json" \
--data-urlencode 'q=SELECT id, name__v, document_number__v, status__v, major_version_number__v, minor_version_number__v FROM documents FIND ('\''protocol'\'' SCOPE name__v, title__v) WHERE status__v = '\''steady_state__v'\'' AND type__v = '\''clinical__c'\'' ORDER BY document_number__v ASC MAXROWS 500 PAGESIZE 100'What Makes Veeva VQL Different from Standard SQL?
Veeva Vault Query Language (VQL) borrows its SELECT ... FROM ... WHERE structure from SQL, but its grammar is built specifically for Veeva Vault documents, objects, and relationships. Standard SQL formatters often misread Vault suffixes (__v for standard fields, __c for custom fields, and __r / __vr for relationships) as well as VQL-specific clauses like FIND, MAXROWS, PAGESIZE, and SKIP.
Common VQL Errors, Issues & Fixes
1. Using SELECT *
Issue: VQL rejects SELECT * with a query syntax error because Vault requires explicit field names.
Fix: List the exact API field names you need, such as SELECT id, name__v, status__v FROM documents.
2. PAGESIZE Placed Before MAXROWS
Issue: Writing PAGESIZE 100 MAXROWS 500 triggers a Vault parser error.
Fix: Always put MAXROWS first: MAXROWS 500 PAGESIZE 100.
3. Truncated LongText / RichText Fields
Issue: By default, VQL truncates LongText and RichText fields to 250 characters and strips HTML markup. Calling LONGTEXT(field__c) without an alias also fails.
Fix: Wrap the field and add an AS alias: LONGTEXT(description__c) AS full_description or RICHTEXT(notes__c) AS notes_html.
4. Wrong Relationship Suffix (__c vs __r)
Issue: Traversing parent fields using study__c.name__v fails because __c holds only the record ID.
Fix: Use __r (custom) or __vr (standard) when dotting into related records, e.g. study__vr.status__v.
5. SKIP Pagination Returning Duplicates
Issue: Using SKIP and PAGESIZE without sorting can shift record order across pages.
Fix: Include a deterministic ORDER BY clause (e.g. ORDER BY id ASC) or follow the next_page URL in the API response.
6. HTTP 414 URI Too Long on GET /query
Issue: Passing long VQL queries with large IN (...) lists in the URL query string hits URL length limits.
Fix: Use POST /api/v25.1/query with Content-Type: application/x-www-form-urlencoded and send q=... in the request body.
VQL Clauses Quick Reference
| Clause / Function | Purpose | Example |
|---|---|---|
| FIND ('...' SCOPE ...) | Full-text search optionally scoped to specific fields | FIND ('protocol' SCOPE name__v, title__v) |
| MAXROWS | Caps total returned records (must precede PAGESIZE) | MAXROWS 500 |
| PAGESIZE | Number of records per response page | PAGESIZE 100 |
| SKIP | Offset of records to skip before returning results | SKIP 50 |
| LONGTEXT / RICHTEXT | Returns full field text beyond the 250-char default | LONGTEXT(description__c) AS full_desc |
Official Veeva Documentation & References
Consult the official Veeva Systems portals for complete VQL grammar, API limits, and Vault object references:
- Veeva Vault Developer Portal — VQL Overview →Official VQL syntax, query targets, functions, joins, and pagination rules.
- Veeva Vault REST API Reference →Official documentation for /api/vXX.X/query, authentication, and rate limits.
- Veeva Vault Platform Help →Official admin guides including Criteria VQL, sharing rules, and reference constraints.
- Veeva Systems Official Website →Product overview for Veeva Vault Platform, Vault CRM, PromoMats, and R&D Cloud.
Related Veeva Guides & Tools
Frequently Asked Questions
- What is Veeva VQL (Vault Query Language)?
- VQL is Veeva Vault’s SQL-like query language used to retrieve documents, Vault objects, and system records via the Vault REST API (/api/vXX.X/query).
- Why do standard SQL formatters fail on Veeva VQL?
- VQL includes Veeva-specific clauses and naming conventions such as __v, __c, and __r suffixes, relationship dot-paths (product__vr.name__v), FIND (... SCOPE ...), MAXROWS, PAGESIZE, SKIP, and LONGTEXT()/RICHTEXT() functions that generic SQL formatters often misformat.
- Does Veeva VQL support SELECT *?
- No. VQL requires you to explicitly specify the field API names you want to retrieve (for example, SELECT id, name__v). This linter flags SELECT * as an error.
- Why does MAXROWS have to come before PAGESIZE in VQL?
- Veeva Vault’s query parser enforces a strict clause order for pagination: MAXROWS must appear before PAGESIZE (for example, MAXROWS 500 PAGESIZE 100). Reversing them causes a Vault API syntax error.
- Are my Veeva queries sent to a server?
- No. Formatting, linting, and cURL/fetch snippet generation run 100% locally in your browser. Nothing is transmitted over the network.