-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Wrap SQLTables and SQLColumns catalog functions * Add tests for catalog functions
- Loading branch information
Showing
5 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Catalog functions. | ||
|
||
""" | ||
tables(conn; catalogname=nothing, schemaname=nothing, tablename=nothing, tabletype=nothing) -> ODBC.Cursor | ||
Find tables by the given criteria. This function returns a `Cursor` object that | ||
produces one row per matching table. | ||
Search criteria include: | ||
* `catalogname`: search pattern for catalog names | ||
* `schemaname`: search pattern for schema names | ||
* `tablename`: search pattern for table names | ||
* `tabletypes`: comma-separated list of table types | ||
A search pattern may contain an underscore (`_`) to represent any single character | ||
and a percent sign (`%`) to represent any sequence of zero or more characters. | ||
Use an escape character (driver-specific, but usually `\\`) to include underscores, | ||
percent signs, and escape characters as literals. | ||
""" | ||
function tables(conn; catalogname=nothing, schemaname=nothing, tablename=nothing, tabletype=nothing) | ||
clear!(conn) | ||
stmt = API.Handle(API.SQL_HANDLE_STMT, API.getptr(conn.dbc)) | ||
conn.stmts[stmt] = 0 | ||
conn.cursorstmt = stmt | ||
API.enableasync(stmt) | ||
API.tables(stmt, catalogname, schemaname, tablename, tabletype) | ||
return Cursor(stmt) | ||
end | ||
|
||
""" | ||
columns(conn; catalogname=nothing, schemaname=nothing, tablename=nothing, columnname=nothing) -> ODBC.Cursor | ||
Find columns by the given criteria. This function returns a `Cursor` object that | ||
produces one row per matching column. | ||
Search criteria include: | ||
* `catalogname`: name of the catalog | ||
* `schemaname`: search pattern for schema names | ||
* `tablename`: search pattern for table names | ||
* `columnname`: search pattern for column names | ||
A search pattern may contain an underscore (`_`) to represent any single character | ||
and a percent sign (`%`) to represent any sequence of zero or more characters. | ||
Use an escape character (driver-specific, but usually `\\`) to include underscores, | ||
percent signs, and escape characters as literals. | ||
""" | ||
function columns(conn; catalogname=nothing, schemaname=nothing, tablename=nothing, columnname=nothing) | ||
clear!(conn) | ||
stmt = API.Handle(API.SQL_HANDLE_STMT, API.getptr(conn.dbc)) | ||
conn.stmts[stmt] = 0 | ||
conn.cursorstmt = stmt | ||
API.enableasync(stmt) | ||
API.columns(stmt, catalogname, schemaname, tablename, columnname) | ||
return Cursor(stmt) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters