db_get_quote_indices (private)
db_get_quote_indices sql
Defined in packages/acs-tcl/tcl/01-database-procs.tcl
Given a piece of SQL, return the indices of single quotes. This is useful when we do bind var substitution because we should not attempt bind var substitution inside quotes. Examples:
sql return value {'a'} {0 2} {'a''} {} {'a'a'a'} {0 2 4 6} {a'b'c'd'} {1 3 5 7}
- Parameters:
- sql (required)
- See Also:
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- db_get_quote_indices
Source code: set quote_indices [list] # Returns a list on the format # Example - for sql={'a'a'a'} returns # {0 2} {0 0} {2 2} {3 6} {4 4} {6 6} set all_indices [regexp -inline -indices -all -- {(?:^|[^'])(')(?:[^']|'')+(')(?=$|[^'])} $sql] for {set i 0} { $i < [llength $all_indices] } { incr i 3 } { lappend quote_indices [lindex $all_indices $i+1 0] [lindex $all_indices $i+2 0] } return $quote_indicesXQL Not present: Generic, PostgreSQL, Oracle