Skip to content

Commit 4c1b131

Browse files
committed
Update Patterns Decoupling SQL.md
1 parent 98a0873 commit 4c1b131

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Patterns Decoupling SQL.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ SQLite does not support stored procedures, and the application is responsible fo
1414

1515
A better strategy is to combine SQL snippets into a source code library represented by textual modules containing SQL code only. The application should load this library at startup and parse it (SQL comments in the source library can hold the necessary metadata along with inline documentation). Alternatively, the application may store SQL snippets in a database table, such as *queries(name, sql, doc, ...)*. A dedicated application routine would query this table, returning an SQL snippet based on its name. This routine is the only potential exception for inlining basic SQL, responsible for accessing the *queries* table.
1616

17-
With either storage approach, such an SQL library puts all SQL code in compact SQL-only form, facilitating the development process. It is essential, however, that both the calling application and SQL rely on parameterized queries rather than dynamic SQL generation by the application. Parameterized queries, like stored procedures, can present black boxes to the application with a similar SQL interface, which involves the query label, query parameters, and returned columns. As long as the SQL interfaces are stable, the application code can use a conventional query label/name to identify the appropriate snippet (in either file or database library) and send it verbatim to the database. Such an SQL library may be reused, for example, on different platforms or, where relevant, with multiple API bindings.
17+
With either storage approach, such an SQL library puts all SQL code in compact SQL-only form, facilitating the development process. It is essential, however, that both the calling application and SQL rely on parameterized queries rather than dynamic SQL generation by the application. Parameterized queries, like stored procedures, can present black boxes to the application with a similar SQL interface, which involves the query label, query parameters, and returned columns. As long as these SQL interfaces are stable, the application code can use a conventional query label/name to identify the appropriate snippet (in either file or database library) and send it verbatim to the database. Such an SQL library may be reused, for example, on different platforms or, where relevant, with multiple API bindings.

0 commit comments

Comments
 (0)