]> gitweb.factorcode.org Git - factor.git/blob - extra/odbc/odbc-docs.factor
calendar.format: make duration>human-readable more human readable
[factor.git] / extra / odbc / odbc-docs.factor
1 ! Copyright (C) 2007 Chris Double.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: help.syntax help.markup threads ;
4
5 IN: odbc
6
7 HELP: odbc-init
8 { $values { "env" "an ODBC environment handle" } }
9 { $description
10     "Initializes the ODBC driver manager and returns the "
11     "environment handle required by " { $link odbc-connect } "."
12 }
13 { $see-also odbc-init odbc-connect odbc-disconnect odbc-prepare odbc-free-statement odbc-execute odbc-next-row odbc-number-of-columns odbc-describe-column odbc-get-field odbc-get-row-fields odbc-get-all-rows odbc-query } ;
14
15 HELP: odbc-connect
16 { $values
17     { "env" "an ODBC environment handle" }
18     { "dsn" "a string" }
19     { "dbc" "an ODBC database connection handle" }
20 }
21 { $description
22     "Connects to the database identified by the ODBC data source name (DSN). "
23     "The environment handle is usually obtained by a call to " { $link odbc-init } ". The result is the ODBC connection handle which can be used in other ODBC calls. When finished with the connection handle " { $link odbc-disconnect } " must be called on it."
24 }
25 { $examples { $code "dbc get \"DSN=mydsn\" odbc-connect" } }
26 { $see-also odbc-init odbc-connect odbc-disconnect odbc-prepare odbc-free-statement odbc-execute odbc-next-row odbc-number-of-columns odbc-describe-column odbc-get-field odbc-get-row-fields odbc-get-all-rows odbc-query } ;
27
28 HELP: odbc-disconnect
29 { $values { "dbc" "an ODBC database connection handle" } }
30 { $description
31     "Disconnects from the given database."
32 }
33 { $see-also odbc-init odbc-connect odbc-disconnect odbc-prepare odbc-free-statement odbc-execute odbc-next-row odbc-number-of-columns odbc-describe-column odbc-get-field odbc-get-row-fields odbc-get-all-rows odbc-query } ;
34
35 HELP: odbc-prepare
36 { $values
37     { "dbc" "an ODBC database connection handle" }
38     { "string" "a string containing SQL" }
39     { "statement" "an ODBC statement handle" }
40 }
41 { $description
42     "Prepares (precompiles) the given SQL string, ready for execution with " { $link odbc-execute } ". When finished with the statement " { $link odbc-free-statement } " must be called on it."
43 }
44 { $see-also odbc-init odbc-connect odbc-disconnect odbc-prepare odbc-free-statement odbc-execute odbc-next-row odbc-number-of-columns odbc-describe-column odbc-get-field odbc-get-row-fields odbc-get-all-rows odbc-query } ;
45
46 HELP: odbc-free-statement
47 { $values { "statement" "an ODBC statement handle" } }
48 { $description
49     "Closes the statement handle and frees up all resources associated with it."
50 }
51 { $see-also odbc-init odbc-connect odbc-disconnect odbc-prepare odbc-free-statement odbc-execute odbc-next-row odbc-number-of-columns odbc-describe-column odbc-get-field odbc-get-row-fields odbc-get-all-rows odbc-query } ;
52
53 HELP: odbc-execute
54 { $values { "statement" "an ODBC statement handle" } }
55 { $description
56     "Executes the statement. Once this is done " { $link odbc-next-row } " can be called to retrieve rows."
57 }
58 { $see-also odbc-init odbc-connect odbc-disconnect odbc-prepare odbc-free-statement odbc-execute odbc-next-row odbc-number-of-columns odbc-describe-column odbc-get-field odbc-get-row-fields odbc-get-all-rows odbc-query } ;
59
60 HELP: odbc-next-row
61 { $values
62     { "statement" "an ODBC statement handle" }
63     { "bool" "a boolean indicating success or failure" }
64 }
65 { $description
66     "Retrieves the next available row from the database. If no next row is available then " { $link f } " is returned. Once the row is retrieved " { $link odbc-number-of-columns } ", " { $link odbc-describe-column } ", " { $link odbc-get-field } " and " { $link odbc-get-row-fields } " can be used to query the data retrieved."
67 }
68 { $see-also odbc-init odbc-connect odbc-disconnect odbc-prepare odbc-free-statement odbc-execute odbc-next-row odbc-number-of-columns odbc-describe-column odbc-get-field odbc-get-row-fields odbc-get-all-rows odbc-query } ;
69
70 HELP: odbc-number-of-columns
71 { $values { "statement" "an ODBC statement handle" } { "number" "a number" } }
72 { $description
73     "Returns the number of columns of data retrieved."
74 }
75 { $see-also odbc-init odbc-connect odbc-disconnect odbc-prepare odbc-free-statement odbc-execute odbc-next-row odbc-number-of-columns odbc-describe-column odbc-get-field odbc-get-row-fields odbc-get-all-rows odbc-query } ;
76
77 HELP: odbc-describe-column
78 { $values
79     { "statement" "an ODBC statement handle" }
80     { "columnNumber" "a column number starting from one" }
81     { "column" "a column object" }
82 }
83 { $description
84     "Retrieves column information for the given column number from the statement. The column number must be one or greater. The " { $link <column> } " object returned provides data type, name, etc."
85 }
86 { $see-also odbc-init odbc-connect odbc-disconnect odbc-prepare odbc-free-statement odbc-execute odbc-next-row odbc-number-of-columns odbc-describe-column odbc-get-field odbc-get-row-fields odbc-get-all-rows odbc-query } ;
87
88 HELP: odbc-get-field
89 { $values
90     { "statement" "an ODBC statement handle" }
91     { "column!" "a column number starting from one or a <column> object" }
92     { "field" "a <field> object" }
93 }
94 { $description
95     "Returns a field object which contains the data for the field in the given column in the current row. The column can be identified by a number or a <column> object. The datatype of the contents of the field depends on the type of the column itself. Note that this word can only be safely called once on each column in a given row with most ODBC drivers. Subsequent calls on the same row for the same column can fail."
96 }
97 { $see-also odbc-init odbc-connect odbc-disconnect odbc-prepare odbc-free-statement odbc-execute odbc-next-row odbc-number-of-columns odbc-describe-column odbc-get-field odbc-get-row-fields odbc-get-all-rows odbc-query } ;
98
99 HELP: odbc-get-row-fields
100 { $values { "statement" "an ODBC statement handle" } { "seq" "a sequence" } }
101 { $description
102     "Returns a sequence of all field data for the current row. Note that this is not the <field> objects, but the data for that field. This word can only be called once on a given row. Subsequent calls on the same row may fail on some ODBC drivers."
103 }
104 { $see-also odbc-init odbc-connect odbc-disconnect odbc-prepare odbc-free-statement odbc-execute odbc-next-row odbc-number-of-columns odbc-describe-column odbc-get-field odbc-get-row-fields odbc-get-all-rows odbc-query } ;
105
106 HELP: odbc-get-all-rows
107 { $values { "statement" "an ODBC statement handle" } { "seq" "a sequence" } }
108 { $description
109     "Returns a sequence of all rows available from the statement. Effectively it is the contents of the entire query so may take some time and memory. Each element of the sequence is itself a sequence containing the data for that row. A " { $link yield } " is performed an various intervals so as to not lock up the Factor instance while it is running."
110 }
111 { $see-also odbc-init odbc-connect odbc-disconnect odbc-prepare odbc-free-statement odbc-execute odbc-next-row odbc-number-of-columns odbc-describe-column odbc-get-field odbc-get-row-fields odbc-get-all-rows odbc-query } ;
112
113 HELP: odbc-query
114 { $values
115     { "string" "a string containing SQL" }
116     { "dsn" "a DSN string" }
117     { "result" "a sequence" }
118 }
119 { $description
120     "This word initializes odbc, connects to the database with the given DSN, executes the query string and returns the result as a sequence. It cleans up all resources it uses. It is an inefficient way of running multiple queries but is useful for the occasional query, testing at the REPL, or as an example of how to do it."
121 }
122 { $see-also odbc-init odbc-connect odbc-disconnect odbc-prepare odbc-free-statement odbc-execute odbc-next-row odbc-number-of-columns odbc-describe-column odbc-get-field odbc-get-row-fields odbc-get-all-rows odbc-query } ;