-
Notifications
You must be signed in to change notification settings - Fork 61
Expand file tree
/
Copy pathcatalog.jl
More file actions
55 lines (47 loc) · 2.21 KB
/
catalog.jl
File metadata and controls
55 lines (47 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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