ruby-odbc 0.9998
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +53 -0
- data/ChangeLog +283 -0
- data/GPL +340 -0
- data/MANIFEST +23 -0
- data/README +110 -0
- data/doc/odbc.html +1315 -0
- data/ext/extconf.rb +112 -0
- data/ext/init.c +197 -0
- data/ext/odbc.c +7905 -0
- data/ext/utf8/extconf.rb +146 -0
- data/ext/utf8/init.c +12 -0
- data/ext/utf8/odbc.c +15 -0
- data/lib/cqgen.rb +561 -0
- data/ruby-odbc.gemspec +16 -0
- data/test/00connect.rb +1 -0
- data/test/10create_table.rb +1 -0
- data/test/20insert.rb +6 -0
- data/test/30select.rb +69 -0
- data/test/40update.rb +4 -0
- data/test/50drop_table.rb +3 -0
- data/test/70close.rb +1 -0
- data/test/test.rb +32 -0
- data/test/utf8/test.rb +32 -0
- metadata +80 -0
data/MANIFEST
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
COPYING
|
2
|
+
ChangeLog
|
3
|
+
GPL
|
4
|
+
MANIFEST
|
5
|
+
README
|
6
|
+
ruby-odbc.gemspec
|
7
|
+
ext/extconf.rb
|
8
|
+
ext/odbc.c
|
9
|
+
ext/init.c
|
10
|
+
ext/utf8/extconf.rb
|
11
|
+
ext/utf8/odbc.c
|
12
|
+
ext/utf8/init.c
|
13
|
+
lib/cqgen.rb
|
14
|
+
doc/odbc.html
|
15
|
+
test/test.rb
|
16
|
+
test/00connect.rb
|
17
|
+
test/10create_table.rb
|
18
|
+
test/20insert.rb
|
19
|
+
test/30select.rb
|
20
|
+
test/40update.rb
|
21
|
+
test/50drop_table.rb
|
22
|
+
test/70close.rb
|
23
|
+
test/utf8/test.rb
|
data/README
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
# $Id: README,v 1.36 2010/01/15 09:54:15 chw Exp chw $
|
2
|
+
|
3
|
+
ruby-odbc-0.9998
|
4
|
+
|
5
|
+
This is an ODBC binding for Ruby. So far it has been tested with
|
6
|
+
|
7
|
+
- Ruby 1.[6-9], MySQL 3.22/MyODBC (local), unixODBC 2.1.0
|
8
|
+
on Linux 2.2-x86 and 2.6-x86_64
|
9
|
+
|
10
|
+
- Ruby 1.6.4, MySQL 3.22/MyODBC (local), libiodbc 2.50
|
11
|
+
on Linux 2.2-x86
|
12
|
+
|
13
|
+
- Ruby 1.[6-8], MySQL 3.22/MyODBC (remote), MS Jet Engine, MSVC++ 6.0
|
14
|
+
on Windows NT4SP6
|
15
|
+
|
16
|
+
- Ruby 1.6.[3-5], MySQL 3.22/MyODBC (remote), MS Jet Engine, cygwin,
|
17
|
+
on Windows NT4SP6 and 2000
|
18
|
+
|
19
|
+
- Ruby 1.8.*, SQLite/ODBC >= 0.67, libiodbc 3.52.4 on Fedora Core 3 x86
|
20
|
+
|
21
|
+
Michael Neumann <neumann@s-direktnet.de> and
|
22
|
+
Will Merrell <wmerrell@catalystcorp.com> reported successful compilation
|
23
|
+
with Cygwin on Win32.
|
24
|
+
|
25
|
+
Requirements:
|
26
|
+
|
27
|
+
- Ruby 1.6.[3-8] or Ruby >= 1.7
|
28
|
+
- unixODBC 2.x or libiodbc 3.52 on UN*X
|
29
|
+
|
30
|
+
Installation:
|
31
|
+
|
32
|
+
$ ruby -Cext extconf.rb [--enable-dlopen|--disable-dlopen]
|
33
|
+
$ make -C ext
|
34
|
+
# make -C ext install
|
35
|
+
|
36
|
+
--enable/disble-dlopen turns on/off special initialization
|
37
|
+
code to make ruby-odbc agnostic to unixODBC/iODBC driver
|
38
|
+
manager shared library names when GCC is used for compile.
|
39
|
+
In cases where unixODBC or iODBC is installed in non-standard
|
40
|
+
locations, use the option --with-odbc-dir=<non-standard-location>
|
41
|
+
when running extconf.rb
|
42
|
+
|
43
|
+
Installation of utf8 version:
|
44
|
+
|
45
|
+
$ ruby -Cext/utf8 extconf.rb [--enable-dlopen|--disable-dlopen]
|
46
|
+
$ make -C ext/utf8
|
47
|
+
# make -C ext/utf8 install
|
48
|
+
|
49
|
+
Installation MSVC:
|
50
|
+
|
51
|
+
C:..>ruby -Cext extconf.rb
|
52
|
+
C:..>cd ext
|
53
|
+
C:..>nmake
|
54
|
+
C:..>nmake install
|
55
|
+
C:..>ruby -Cutf8 extconf.rb
|
56
|
+
C:..>cd utf8
|
57
|
+
C:..>nmake
|
58
|
+
C:..>nmake install
|
59
|
+
|
60
|
+
Testing:
|
61
|
+
|
62
|
+
$ ruby -Ctest test.rb DSN [uid] [pwd]
|
63
|
+
or
|
64
|
+
$ ruby -KU -Ctest/utf8 test.rb DSN [uid] [pwd]
|
65
|
+
|
66
|
+
Usage:
|
67
|
+
|
68
|
+
Refer to doc/odbc.html
|
69
|
+
|
70
|
+
The difference between utf8 and non-utf8 versions are:
|
71
|
+
|
72
|
+
- non-utf8 version uses normal SQL.* ANSI functions
|
73
|
+
- utf8 version uses SQL.*W UNICODE functions and
|
74
|
+
requires/returns all strings in UTF8 format
|
75
|
+
|
76
|
+
Thus, depending on the -K option of ruby one could use
|
77
|
+
that code snippet:
|
78
|
+
|
79
|
+
...
|
80
|
+
if $KCODE == "UTF8" then
|
81
|
+
require 'odbc_utf8'
|
82
|
+
else
|
83
|
+
require 'odbc'
|
84
|
+
fi
|
85
|
+
|
86
|
+
It is also possible to load both non-utf8 and utf8 version
|
87
|
+
into ruby:
|
88
|
+
|
89
|
+
...
|
90
|
+
# non-utf8 version
|
91
|
+
require 'odbc'
|
92
|
+
# utf8 version
|
93
|
+
require 'odbc_utf8'
|
94
|
+
|
95
|
+
Whichever is loaded first, gets the module name 'ODBC'.
|
96
|
+
The second loaded module will be named 'ODBC_UTF8' (for
|
97
|
+
'odbc_utf8') or 'ODBC_NONE' (for 'odbc'). That should
|
98
|
+
allow to use both versions simultaneously in special
|
99
|
+
situations.
|
100
|
+
|
101
|
+
TODO:
|
102
|
+
|
103
|
+
- heavier testing
|
104
|
+
- improve documentation
|
105
|
+
|
106
|
+
Author:
|
107
|
+
|
108
|
+
Christian Werner
|
109
|
+
mailto:chw@ch-werner.de
|
110
|
+
http://www.ch-werner.de/rubyodbc
|
data/doc/odbc.html
ADDED
@@ -0,0 +1,1315 @@
|
|
1
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
|
2
|
+
"http://www.w3.org/TR/html4/strict.dtd">
|
3
|
+
<html lang="en">
|
4
|
+
<head>
|
5
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
6
|
+
<meta http-equiv="Content-Style-Type" content="text/css">
|
7
|
+
<meta name="Keywords" lang="en" content="ODBC Binding for Ruby">
|
8
|
+
<link rev="made" href="mailto:chw@ch-werner.de">
|
9
|
+
<style type="text/css">
|
10
|
+
<!--
|
11
|
+
body {
|
12
|
+
background-color: white;
|
13
|
+
color: black;
|
14
|
+
}
|
15
|
+
address { text-align: right }
|
16
|
+
div.lastmodifed { text-align: right }
|
17
|
+
div.language { text-align: right }
|
18
|
+
pre {
|
19
|
+
white-space: pre;
|
20
|
+
background-color: antiquewhite;
|
21
|
+
border: inset thin;
|
22
|
+
}
|
23
|
+
-->
|
24
|
+
</style>
|
25
|
+
<title>Ruby ODBC Reference</title>
|
26
|
+
</head>
|
27
|
+
<body>
|
28
|
+
<h1><a name="reference">Ruby ODBC Reference</a></h1>
|
29
|
+
<div class = "lastmodifed">
|
30
|
+
Last update: Fri, 15 January 2010
|
31
|
+
</div>
|
32
|
+
<hr>
|
33
|
+
<div>
|
34
|
+
<h2><a name="ODBC">ODBC</a></h2>
|
35
|
+
<p>
|
36
|
+
The module to encapsulate the Ruby ODBC binding.
|
37
|
+
</p>
|
38
|
+
<h3>module functions:</h3>
|
39
|
+
<dl>
|
40
|
+
<dt><a name="ODBC::datasources"><code>datasources</code></a>
|
41
|
+
<dd>Returns an array of <a href="#ODBC::DSN">ODBC::DSN</a>s, i.e. all
|
42
|
+
known data source names.
|
43
|
+
<dt><a name="ODBC::drivers"><code>drivers</code></a>
|
44
|
+
<dd>Returns an array of <a href="#ODBC::Driver">ODBC::Driver</a>s,
|
45
|
+
i.e. all known ODBC drivers.
|
46
|
+
<dt><a name="ODBC::error"><code>error</code></a>
|
47
|
+
<dd>Returns the last error messages (String array) or nil.
|
48
|
+
The layout of the warning/error messages
|
49
|
+
is described <a href="#ODBC::Error">here</a>.
|
50
|
+
Retrieving this message as well as subsequent succeeding ODBC
|
51
|
+
method invocations do not clear the message. Use the
|
52
|
+
<a href="#OBDC::clear_error"><code>clear_error</code></a> method
|
53
|
+
for that purpose.
|
54
|
+
<dt><a name="ODBC::info"><code>info</code></a>
|
55
|
+
<dd>Returns the last driver/driver manager warning messages
|
56
|
+
(String array) or nil.
|
57
|
+
The layout of the warning/error messages
|
58
|
+
is described <a href="#ODBC::Error">here</a>.
|
59
|
+
Retrieving this message as well as subsequent succeeding ODBC
|
60
|
+
method invocations do not clear the message. Use the
|
61
|
+
<a href="#OBDC::clear_error"><code>clear_error</code></a> method
|
62
|
+
for that purpose.
|
63
|
+
<dt><a name="ODBC::clear_error"><code>clear_error</code></a>
|
64
|
+
<dd>Resets the last driver/driver manager error and warning messages
|
65
|
+
to nil.
|
66
|
+
<dt><a name="ODBC::raise"><code>raise(<var>value</var>)</code></a>
|
67
|
+
<dd>Raises an <a href="#ODBC::Error">ODBC::Error</a> exception with
|
68
|
+
String error message <var>value</var>.
|
69
|
+
<dt><a name="ODBC::newenv"><code>newenv</code></a>
|
70
|
+
<dd>Returns a new <a href="#ODBC::Environment">ODBC::Environment</a>.
|
71
|
+
<dt><a name="ODBC::connection_pooling">
|
72
|
+
<code>connection_pooling[=<var>value</var>]</code></a>
|
73
|
+
<dd>Gets or sets the process-wide connection pooling attribute.
|
74
|
+
<dt><a name="ODBC::to_time1">
|
75
|
+
<code>to_time(<var>timestamp</var>)</code></a>
|
76
|
+
<dt><a name="ODBC::to_time2"><code>to_time(<var>date</var>,[<var>time</var>])</code></a>
|
77
|
+
<dt><a name="ODBC::to_time3"><code>to_time(<var>time</var>,[<var>date</var>])</code></a>
|
78
|
+
<dd>Creates a <code>Time</code> object from the specified arguments,
|
79
|
+
which must be <a href="#ODBC::Date">ODBC::Date</a>,
|
80
|
+
<a href="#ODBC::Time">ODBC::Time</a>, or
|
81
|
+
<a href="#ODBC::TimeStamp">ODBC::TimeStamp</a> objects.
|
82
|
+
<dt><a name="ODBC::to_date1">
|
83
|
+
<code>to_date(<var>timestamp</var>)</code></a>
|
84
|
+
<dt><a name="ODBC::to_date2"><code>to_date(<var>date</var>)</code></a>
|
85
|
+
<dd>Creates a <code>Date</code> object from the specified arguments,
|
86
|
+
which must be <a href="#ODBC::Date">ODBC::Date</a>, or
|
87
|
+
<a href="#ODBC::TimeStamp">ODBC::TimeStamp</a> objects.
|
88
|
+
<dt><a name="ODBC::connect"><code>connect(<var>dsn</var>,[<var>user</var>,<var>passwd</var>])
|
89
|
+
[{|<var>dbc</var>| <var>block</var>}]</code></a>
|
90
|
+
<dd>If no block is specified, a connection to the given data source
|
91
|
+
is established and a <a href="#ODBC::Database">ODBC::Database</a>
|
92
|
+
object is returned, identifying that connection. Otherwise,
|
93
|
+
the block is executed with the database object. When the block
|
94
|
+
is finished, the connection is automatically released.
|
95
|
+
Options are:
|
96
|
+
<dl>
|
97
|
+
<dd><var>dsn</var>: Data source name (String or
|
98
|
+
<a href="#ODBC::DSN">ODBC::DSN</a>)
|
99
|
+
<dd><var>user</var>: Login user name (String)
|
100
|
+
<dd><var>passwd</var>: Login password (String)
|
101
|
+
</dl>
|
102
|
+
</dl>
|
103
|
+
<h3>constants:</h3>
|
104
|
+
<p>
|
105
|
+
Some constants of the ODBC API are defined in order to set connection
|
106
|
+
options, to deal with SQL data types, and to obtain database meta data.
|
107
|
+
</p>
|
108
|
+
<dl>
|
109
|
+
<dt>Cursor behaviour:
|
110
|
+
<dd><var>SQL_CURSOR_FORWARD_ONLY</var>,
|
111
|
+
<var>SQL_CURSOR_KEYSET_DRIVEN</var>,
|
112
|
+
<var>SQL_CURSOR_DYNAMIC</var>,
|
113
|
+
<var>SQL_CURSOR_STATIC</var>
|
114
|
+
<dt>Concurrency (transactions):
|
115
|
+
<dd><var>SQL_CONCUR_READ_ONLY</var>,
|
116
|
+
<var>SQL_CONCUR_LOCK</var>,
|
117
|
+
<var>SQL_CONCUR_ROWVER</var>,
|
118
|
+
<var>SQL_CONCUR_VALUES</var>
|
119
|
+
<dt>Fetch direction:
|
120
|
+
<dd><var>SQL_FETCH_NEXT</var>,
|
121
|
+
<var>SQL_FETCH_FIRST</var>,
|
122
|
+
<var>SQL_FETCH_LAST</var>,
|
123
|
+
<var>SQL_FETCH_PRIOR</var>,
|
124
|
+
<var>SQL_FETCH_ABSOLUTE</var>,
|
125
|
+
<var>SQL_FETCH_RELATIVE</var>
|
126
|
+
<dt>Data types:
|
127
|
+
<dd><var>SQL_UNKNOWN_TYPE</var>,
|
128
|
+
<var>SQL_CHAR</var>,
|
129
|
+
<var>SQL_NUMERIC</var>,
|
130
|
+
<var>SQL_DECIMAL</var>,
|
131
|
+
<var>SQL_INTEGER</var>,
|
132
|
+
<var>SQL_SMALLINT</var>,
|
133
|
+
<var>SQL_FLOAT</var>,
|
134
|
+
<var>SQL_REAL</var>,
|
135
|
+
<var>SQL_DOUBLE</var>,
|
136
|
+
<var>SQL_VARCHAR</var>,
|
137
|
+
<var>SQL_DATETIME</var>,
|
138
|
+
<var>SQL_DATE</var>,
|
139
|
+
<var>SQL_TYPE_DATE</var>,
|
140
|
+
<var>SQL_TIME</var>,
|
141
|
+
<var>SQL_TYPE_TIME</var>,
|
142
|
+
<var>SQL_TIMESTAMP</var>,
|
143
|
+
<var>SQL_TYPE_TIMESTAMP</var>,
|
144
|
+
<var>SQL_LONGVARCHAR</var>,
|
145
|
+
<var>SQL_BINARY</var>,
|
146
|
+
<var>SQL_VARBINARY</var>,
|
147
|
+
<var>SQL_LONGVARBINARY</var>,
|
148
|
+
<var>SQL_BIGINT</var>,
|
149
|
+
<var>SQL_TINYINT</var>,
|
150
|
+
<var>SQL_BIT</var>,
|
151
|
+
<var>SQL_GUID</var>
|
152
|
+
<dt>Parameter related:
|
153
|
+
<dd><var>SQL_PARAM_TYPE_UNKNOWN</var>,
|
154
|
+
<var>SQL_PARAM_INPUT</var>,
|
155
|
+
<var>SQL_PARAM_OUTPUT</var>,
|
156
|
+
<var>SQL_PARAM_INPUT_OUTPUT</var>,
|
157
|
+
<var>SQL_DEFAULT_PARAM</var>
|
158
|
+
<var>SQL_RETURN_VALUE</var>
|
159
|
+
<dt>Procedure related:
|
160
|
+
<dd><var>SQL_RESULT_COL</var>,
|
161
|
+
<var>SQL_PT_UNKNOWN</var>,
|
162
|
+
<var>SQL_PT_PROCEDURE</var>,
|
163
|
+
<var>SQL_PT_FUNCTION</var>
|
164
|
+
<dt>Environment attributes:
|
165
|
+
<dd><var>SQL_CP_OFF</var>,
|
166
|
+
<var>SQL_CP_ONE_PER_DRIVER</var>,
|
167
|
+
<var>SQL_CP_ONE_PER_HENV</var>,
|
168
|
+
<var>SQL_CP_DEFAULT</var>,
|
169
|
+
<var>SQL_CP_STRICT_MATCH</var>,
|
170
|
+
<var>SQL_CP_RELAXED_MATCH</var>,
|
171
|
+
<var>SQL_CP_MATCH_DEFAULT</var>,
|
172
|
+
<var>SQL_OV_ODBC2</var>,
|
173
|
+
<var>SQL_OV_ODBC3</var>
|
174
|
+
<dt>Info types for
|
175
|
+
<a href=#get_info><code>ODBC::Database.get_info</code></a>
|
176
|
+
yielding integer results:
|
177
|
+
<dd><var>SQL_ACTIVE_ENVIRONMENTS</var>,
|
178
|
+
<var>SQL_ACTIVE_CONNECTIONS</var>,
|
179
|
+
<var>SQL_ACTIVE_STATEMENTS</var>,
|
180
|
+
<var>SQL_ASYNC_MODE</var>,
|
181
|
+
<var>SQL_CATALOG_LOCATION</var>,
|
182
|
+
<var>SQL_CONCAT_NULL_BEHAVIOR</var>,
|
183
|
+
<var>SQL_CORRELATION_NAME</var>,
|
184
|
+
<var>SQL_CURSOR_COMMIT_BEHAVIOR</var>,
|
185
|
+
<var>SQL_CURSOR_ROLLBACK_BEHAVIOR</var>,
|
186
|
+
<var>SQL_CURSOR_SENSITIVITY</var>,
|
187
|
+
<var>SQL_DDL_INDEX</var>,
|
188
|
+
<var>SQL_DEFAULT_TXN_ISOLATION</var>,
|
189
|
+
<var>SQL_DRIVER_HDBC</var>,
|
190
|
+
<var>SQL_DRIVER_HENV</var>,
|
191
|
+
<var>SQL_DRIVER_HDESC</var>,
|
192
|
+
<var>SQL_DRIVER_HLIB</var>,
|
193
|
+
<var>SQL_DRIVER_HSTMT</var>,
|
194
|
+
<var>SQL_FILE_USAGE</var>,
|
195
|
+
<var>SQL_GROUP_BY</var>,
|
196
|
+
<var>SQL_IDENTIFIER_CASE</var>,
|
197
|
+
<var>SQL_MAX_ASYNC_CONCURRENT_STATEMENTS</var>,
|
198
|
+
<var>SQL_MAX_BINARY_LITERAL_LEN</var>,
|
199
|
+
<var>SQL_MAX_CATALOG_NAME_LEN</var>,
|
200
|
+
<var>SQL_MAX_CHAR_LITERAL_LEN</var>,
|
201
|
+
<var>SQL_MAX_COLUMN_NAME_LEN</var>,
|
202
|
+
<var>SQL_MAX_COLUMNS_IN_GROUP_BY</var>,
|
203
|
+
<var>SQL_MAX_COLUMNS_IN_INDEX</var>,
|
204
|
+
<var>SQL_MAX_COLUMNS_IN_ORDER_BY</var>,
|
205
|
+
<var>SQL_MAX_COLUMNS_IN_SELECT</var>,
|
206
|
+
<var>SQL_MAX_COLUMNS_IN_TABLE</var>,
|
207
|
+
<var>SQL_MAX_CONCURRENT_ACTIVITIES</var>,
|
208
|
+
<var>SQL_MAX_CURSOR_NAME_LEN</var>,
|
209
|
+
<var>SQL_MAX_DRIVER_CONNECTIONS</var>,
|
210
|
+
<var>SQL_MAX_IDENTIFIER_LEN</var>,
|
211
|
+
<var>SQL_MAX_INDEX_SIZE</var>,
|
212
|
+
<var>SQL_MAX_OWNER_NAME_LEN</var>,
|
213
|
+
<var>SQL_MAX_PROCEDURE_NAME_LEN</var>,
|
214
|
+
<var>SQL_MAX_QUALIFIER_NAME_LEN</var>,
|
215
|
+
<var>SQL_MAX_ROW_SIZE</var>,
|
216
|
+
<var>SQL_MAX_SCHEMA_NAME_LEN</var>,
|
217
|
+
<var>SQL_MAX_STATEMENT_LEN</var>,
|
218
|
+
<var>SQL_MAX_TABLE_NAME_LEN</var>,
|
219
|
+
<var>SQL_MAX_TABLES_IN_SELECT</var>,
|
220
|
+
<var>SQL_MAX_USER_NAME_LEN</var>,
|
221
|
+
<var>SQL_NON_NULLABLE_COLUMNS</var>,
|
222
|
+
<var>SQL_NULL_COLLATION</var>,
|
223
|
+
<var>SQL_ODBC_API_CONFORMANCE</var>,
|
224
|
+
<var>SQL_ODBC_INTERFACE_CONFORMANCE</var>,
|
225
|
+
<var>SQL_ODBC_SAG_CLI_CONFORMANCE</var>,
|
226
|
+
<var>SQL_ODBC_SQL_CONFORMANCE</var>,
|
227
|
+
<var>SQL_PARAM_ARRAY_ROW_COUNTS</var>,
|
228
|
+
<var>SQL_PARAM_ARRAY_SELECTS</var>,
|
229
|
+
<var>SQL_QUALIFIER_LOCATION</var>,
|
230
|
+
<var>SQL_QUOTED_IDENTIFIER_CASE</var>,
|
231
|
+
<var>SQL_SQL_CONFORMANCE</var>,
|
232
|
+
<var>SQL_TXN_CAPABLE</var>
|
233
|
+
<dt>Info types for
|
234
|
+
<a href=#get_info><code>ODBC::Database.get_info</code></a>
|
235
|
+
yielding bitmasks (integer results):
|
236
|
+
<dd><var>SQL_AGGREGATE_FUNCTIONS</var>,
|
237
|
+
<var>SQL_ALTER_DOMAIN</var>,
|
238
|
+
<var>SQL_ALTER_TABLE</var>,
|
239
|
+
<var>SQL_BATCH_ROW_COUNT</var>,
|
240
|
+
<var>SQL_BATCH_SUPPORT</var>,
|
241
|
+
<var>SQL_BOOKMARK_PERSISTENCE</var>,
|
242
|
+
<var>SQL_CATALOG_USAGE</var>,
|
243
|
+
<var>SQL_CONVERT_BINARY</var>,
|
244
|
+
<var>SQL_CONVERT_BIT</var>,
|
245
|
+
<var>SQL_CONVERT_CHAR</var>,
|
246
|
+
<var>SQL_CONVERT_GUID</var>,
|
247
|
+
<var>SQL_CONVERT_DATE</var>,
|
248
|
+
<var>SQL_CONVERT_DECIMAL</var>,
|
249
|
+
<var>SQL_CONVERT_DOUBLE</var>,
|
250
|
+
<var>SQL_CONVERT_FLOAT</var>,
|
251
|
+
<var>SQL_CONVERT_FUNCTIONS</var>,
|
252
|
+
<var>SQL_CONVERT_INTEGER</var>,
|
253
|
+
<var>SQL_CONVERT_INTERVAL_YEAR_MONTH</var>,
|
254
|
+
<var>SQL_CONVERT_INTERVAL_DAY_TIME</var>,
|
255
|
+
<var>SQL_CONVERT_LONGVARBINARY</var>,
|
256
|
+
<var>SQL_CONVERT_LONGVARCHAR</var>,
|
257
|
+
<var>SQL_CONVERT_NUMERIC</var>,
|
258
|
+
<var>SQL_CONVERT_REAL</var>,
|
259
|
+
<var>SQL_CONVERT_SMALLINT</var>,
|
260
|
+
<var>SQL_CONVERT_TIME</var>,
|
261
|
+
<var>SQL_CONVERT_TIMESTAMP</var>,
|
262
|
+
<var>SQL_CONVERT_TINYINT</var>,
|
263
|
+
<var>SQL_CONVERT_VARBINARY</var>,
|
264
|
+
<var>SQL_CONVERT_VARCHAR</var>,
|
265
|
+
<var>SQL_CONVERT_WCHAR</var>,
|
266
|
+
<var>SQL_CONVERT_WLONGVARCHAR</var>,
|
267
|
+
<var>SQL_CONVERT_WVARCHAR</var>,
|
268
|
+
<var>SQL_CREATE_ASSERTION</var>,
|
269
|
+
<var>SQL_CREATE_CHARACTER_SET</var>,
|
270
|
+
<var>SQL_CREATE_COLLATION</var>,
|
271
|
+
<var>SQL_CREATE_DOMAIN</var>,
|
272
|
+
<var>SQL_CREATE_SCHEMA</var>,
|
273
|
+
<var>SQL_CREATE_TABLE</var>,
|
274
|
+
<var>SQL_CREATE_TRANSLATION</var>,
|
275
|
+
<var>SQL_CREATE_VIEW</var>,
|
276
|
+
<var>SQL_DATETIME_LITERALS</var>,
|
277
|
+
<var>SQL_DROP_ASSERTION</var>,
|
278
|
+
<var>SQL_DROP_CHARACTER_SET</var>,
|
279
|
+
<var>SQL_DROP_COLLATION</var>,
|
280
|
+
<var>SQL_DROP_DOMAIN</var>,
|
281
|
+
<var>SQL_DROP_SCHEMA</var>,
|
282
|
+
<var>SQL_DROP_TABLE</var>,
|
283
|
+
<var>SQL_DROP_TRANSLATION</var>,
|
284
|
+
<var>SQL_DROP_VIEW</var>,
|
285
|
+
<var>SQL_DTC_TRANSITION_COST</var>,
|
286
|
+
<var>SQL_DYNAMIC_CURSOR_ATTRIBUTES1</var>,
|
287
|
+
<var>SQL_DYNAMIC_CURSOR_ATTRIBUTES2</var>,
|
288
|
+
<var>SQL_FETCH_DIRECTION</var>,
|
289
|
+
<var>SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES1</var>,
|
290
|
+
<var>SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2</var>,
|
291
|
+
<var>SQL_GETDATA_EXTENSIONS</var>,
|
292
|
+
<var>SQL_KEYSET_CURSOR_ATTRIBUTES1</var>,
|
293
|
+
<var>SQL_KEYSET_CURSOR_ATTRIBUTES2</var>,
|
294
|
+
<var>SQL_INDEX_KEYWORDS</var>,
|
295
|
+
<var>SQL_INFO_SCHEMA_VIEWS</var>,
|
296
|
+
<var>SQL_INSERT_STATEMENT</var>,
|
297
|
+
<var>SQL_LOCK_TYPES</var>,
|
298
|
+
<var>SQL_NUMERIC_FUNCTIONS</var>,
|
299
|
+
<var>SQL_OJ_CAPABILITIES</var>,
|
300
|
+
<var>SQL_OWNER_USAGE</var>,
|
301
|
+
<var>SQL_POS_OPERATIONS</var>,
|
302
|
+
<var>SQL_POSITIONED_STATEMENTS</var>,
|
303
|
+
<var>SQL_QUALIFIER_USAGE</var>,
|
304
|
+
<var>SQL_SCHEMA_USAGE</var>,
|
305
|
+
<var>SQL_SCROLL_CONCURRENCY</var>,
|
306
|
+
<var>SQL_SCROLL_OPTIONS</var>,
|
307
|
+
<var>SQL_SQL92_DATETIME_FUNCTIONS</var>,
|
308
|
+
<var>SQL_SQL92_FOREIGN_KEY_DELETE_RULE</var>,
|
309
|
+
<var>SQL_SQL92_FOREIGN_KEY_UPDATE_RULE</var>,
|
310
|
+
<var>SQL_SQL92_GRANT</var>,
|
311
|
+
<var>SQL_SQL92_NUMERIC_VALUE_FUNCTIONS</var>,
|
312
|
+
<var>SQL_SQL92_PREDICATES</var>,
|
313
|
+
<var>SQL_SQL92_RELATIONAL_JOIN_OPERATORS</var>,
|
314
|
+
<var>SQL_SQL92_REVOKE</var>,
|
315
|
+
<var>SQL_SQL92_ROW_VALUE_CONSTRUCTOR</var>,
|
316
|
+
<var>SQL_SQL92_STRING_FUNCTIONS</var>,
|
317
|
+
<var>SQL_SQL92_VALUE_EXPRESSIONS</var>,
|
318
|
+
<var>SQL_STANDARD_CLI_CONFORMANCE</var>,
|
319
|
+
<var>SQL_STATIC_CURSOR_ATTRIBUTES1</var>,
|
320
|
+
<var>SQL_STATIC_CURSOR_ATTRIBUTES2</var>,
|
321
|
+
<var>SQL_STATIC_SENSITIVITY</var>,
|
322
|
+
<var>SQL_STRING_FUNCTIONS</var>,
|
323
|
+
<var>SQL_SUBQUERIES</var>,
|
324
|
+
<var>SQL_SYSTEM_FUNCTIONS</var>,
|
325
|
+
<var>SQL_TIMEDATE_ADD_INTERVALS</var>,
|
326
|
+
<var>SQL_TIMEDATE_DIFF_INTERVALS</var>,
|
327
|
+
<var>SQL_TIMEDATE_FUNCTIONS</var>,
|
328
|
+
<var>SQL_TXN_ISOLATION_OPTION</var>,
|
329
|
+
<var>SQL_UNION</var>
|
330
|
+
<dt>Info types for
|
331
|
+
<a href=#get_info><code>ODBC::Database.get_info</code></a>
|
332
|
+
yielding strings:
|
333
|
+
<dd><var>SQL_ACCESSIBLE_PROCEDURES</var>,
|
334
|
+
<var>SQL_ACCESSIBLE_TABLES</var>,
|
335
|
+
<var>SQL_CATALOG_NAME</var>,
|
336
|
+
<var>SQL_CATALOG_NAME_SEPARATOR</var>,
|
337
|
+
<var>SQL_CATALOG_TERM</var>,
|
338
|
+
<var>SQL_COLLATION_SEQ</var>,
|
339
|
+
<var>SQL_COLUMN_ALIAS</var>,
|
340
|
+
<var>SQL_DATA_SOURCE_NAME</var>,
|
341
|
+
<var>SQL_DATA_SOURCE_READ_ONLY</var>,
|
342
|
+
<var>SQL_DATABASE_NAME</var>,
|
343
|
+
<var>SQL_DBMS_NAME</var>,
|
344
|
+
<var>SQL_DBMS_VER</var>,
|
345
|
+
<var>SQL_DESCRIBE_PARAMETER</var>,
|
346
|
+
<var>SQL_DM_VER</var>,
|
347
|
+
<var>SQL_DRIVER_NAME</var>,
|
348
|
+
<var>SQL_DRIVER_ODBC_VER</var>,
|
349
|
+
<var>SQL_DRIVER_VER</var>,
|
350
|
+
<var>SQL_EXPRESSIONS_IN_ORDERBY</var>,
|
351
|
+
<var>SQL_IDENTIFIER_QUOTE_CHAR</var>,
|
352
|
+
<var>SQL_INTEGRITY</var>,
|
353
|
+
<var>SQL_KEYWORDS</var>,
|
354
|
+
<var>SQL_LIKE_ESCAPE_CLAUSE</var>,
|
355
|
+
<var>SQL_MAX_ROW_SIZE_INCLUDES_LONG</var>,
|
356
|
+
<var>SQL_MULT_RESULT_SETS</var>,
|
357
|
+
<var>SQL_MULTIPLE_ACTIVE_TXN</var>,
|
358
|
+
<var>SQL_NEED_LONG_DATA_LEN</var>,
|
359
|
+
<var>SQL_ODBC_SQL_OPT_IEF</var>,
|
360
|
+
<var>SQL_ODBC_VER</var>,
|
361
|
+
<var>SQL_ORDER_BY_COLUMNS_IN_SELECT</var>,
|
362
|
+
<var>SQL_OUTER_JOINS</var>,
|
363
|
+
<var>SQL_OWNER_TERM</var>,
|
364
|
+
<var>SQL_PROCEDURE_TERM</var>,
|
365
|
+
<var>SQL_PROCEDURES</var>,
|
366
|
+
<var>SQL_QUALIFIER_NAME_SEPARATOR</var>,
|
367
|
+
<var>SQL_QUALIFIER_TERM</var>,
|
368
|
+
<var>SQL_ROW_UPDATES</var>,
|
369
|
+
<var>SQL_SCHEMA_TERM</var>,
|
370
|
+
<var>SQL_SEARCH_PATTERN_ESCAPE</var>,
|
371
|
+
<var>SQL_SERVER_NAME</var>,
|
372
|
+
<var>SQL_SPECIAL_CHARACTERS</var>,
|
373
|
+
<var>SQL_TABLE_TERM</var>,
|
374
|
+
<var>SQL_USER_NAME</var>,
|
375
|
+
<var>SQL_XOPEN_CLI_YEAR</var>
|
376
|
+
<dt>Options for
|
377
|
+
<a href="#dbc_get_option"><code>ODBC::Database.get_option</code></a>,
|
378
|
+
<a href="#dbc_set_option"><code>ODBC::Database.set_option</code></a>,
|
379
|
+
<a href="#stmt_get_option"><code>ODBC::Statement.get_option</code></a>,
|
380
|
+
and
|
381
|
+
<a href="#stmt_set_option"><code>ODBC::Statement.set_option</code></a>
|
382
|
+
yielding integers:
|
383
|
+
<dd><var>SQL_AUTOCOMMIT</var>,
|
384
|
+
<var>SQL_CONCURRENCY</var>,
|
385
|
+
<var>SQL_QUERY_TIMEOUT</var>,
|
386
|
+
<var>SQL_MAX_ROWS</var>,
|
387
|
+
<var>SQL_MAX_LENGTH</var>,
|
388
|
+
<var>SQL_NOSCAN</var>,
|
389
|
+
<var>SQL_ROWSET_SIZE</var>,
|
390
|
+
<var>SQL_CURSOR_TYPE</var>
|
391
|
+
</dl>
|
392
|
+
</div>
|
393
|
+
<hr>
|
394
|
+
<div>
|
395
|
+
<h2><a name="ODBC::Object">ODBC::Object</a></h2>
|
396
|
+
<p>
|
397
|
+
The class to represent the root of all other ODBC related objects.
|
398
|
+
</p>
|
399
|
+
<h3>super class:</h3>
|
400
|
+
<code>Object</code>
|
401
|
+
<h3>methods:</h3>
|
402
|
+
<dl>
|
403
|
+
<dt><a name="ODBC::Object.error"><code>error</code></a>
|
404
|
+
<dd>Returns the last error message (String) or nil. For further
|
405
|
+
information see <a href="#ODBC::error">ODBC::error</a>.
|
406
|
+
<dt><a name="ODBC::Object.info"><code>info</code></a>
|
407
|
+
<dd>Returns the last driver/driver manager warning messages
|
408
|
+
(String array) or nil.
|
409
|
+
For further information see
|
410
|
+
<a href="#ODBC::error">ODBC::error</a>.
|
411
|
+
<dt><a name="ODBC::Object.clear_error"><code>clear_error</code></a>
|
412
|
+
<dd>Resets the last driver/driver manager error and warning messages
|
413
|
+
to nil.
|
414
|
+
<dt><a name="ODBC::Object.raise"><code>raise(<var>value</var>)</code>
|
415
|
+
</a>
|
416
|
+
<dd>Raises an <a href="#ODBC::Error">ODBC::Error</a> exception with
|
417
|
+
String error message <var>value</var>.
|
418
|
+
</dl>
|
419
|
+
<h3>singleton methods:</h3>
|
420
|
+
<dl>
|
421
|
+
<dt><a name="ODBC::Object.error2"><code>error</code></a>
|
422
|
+
<dd>Returns the last error message (String array) or nil.
|
423
|
+
For further information see
|
424
|
+
<a href="#ODBC::error">ODBC::error</a>.
|
425
|
+
<dt><a name="ODBC::Object.info2"><code>info</code></a>
|
426
|
+
<dd>Returns the last driver/driver manager warning messages
|
427
|
+
(String array) or nil.
|
428
|
+
For further information see
|
429
|
+
<a href="#ODBC::error">ODBC::error</a>.
|
430
|
+
<dt><a name="ODBC::Object.clear_error2"><code>clear_error</code></a>
|
431
|
+
<dd>Resets the last driver/driver manager error and warning messages
|
432
|
+
to nil.
|
433
|
+
<dt><a name="ODBC::Object.raise2"><code>raise(<var>value</var>)</code>
|
434
|
+
</a>
|
435
|
+
<dd>Raises an <a href="#ODBC::Error">ODBC::Error</a> exception with
|
436
|
+
String error message <var>value</var>.
|
437
|
+
</dl>
|
438
|
+
</div>
|
439
|
+
<hr>
|
440
|
+
<div>
|
441
|
+
<h2><a name="ODBC::Environment">ODBC::Environment</a></h2>
|
442
|
+
<p>
|
443
|
+
The class to represent the environment for
|
444
|
+
<a href="#ODBC::Database">ODBC::Database</a>s.
|
445
|
+
</p>
|
446
|
+
<h3>super class:</h3>
|
447
|
+
<code><a href="#ODBC::Object">ODBC::Object</a></code>
|
448
|
+
<h3>methods:</h3>
|
449
|
+
<dl>
|
450
|
+
<dt><a name="ODBC::Environment.connect"><code>connect(<var>dsn</var>,[<var>user</var>,<var>passwd</var>])</code></a>
|
451
|
+
<dd>Connects to an ODBC data source and returns a
|
452
|
+
<a href="#ODBC::Database">ODBC::Database</a> object.
|
453
|
+
Options are:
|
454
|
+
<dl>
|
455
|
+
<dd><var>dsn</var>: Data source name (String or
|
456
|
+
<a href="#ODBC::DSN">ODBC::DSN</a>)
|
457
|
+
<dd><var>user</var>: Login user name (String)
|
458
|
+
<dd><var>passwd</var>: Login password (String)
|
459
|
+
</dl>
|
460
|
+
<dt><a name="ODBC::Environment.environment"><code>environment</code>
|
461
|
+
</a>
|
462
|
+
<dd>Returns the <a href="#ODBC::Environment">ODBC::Environment</a>
|
463
|
+
of the object.
|
464
|
+
<dt> <a name="commit"><code>commit</code></a>
|
465
|
+
<dd>Commits the current transaction.
|
466
|
+
<dt> <a name="rollback"><code>rollback</code></a>
|
467
|
+
<dd>Rollbacks the current transaction.
|
468
|
+
<dt><a name="ODBC::Environment.transaction">
|
469
|
+
<code>transaction {|<var>env</var>| <var>block</var>}</code></a>
|
470
|
+
<dd>First commits the current transaction, then executes the given
|
471
|
+
block where the paramater is the object itself (an environment or
|
472
|
+
a database connection). If the block raises an exception, the
|
473
|
+
transaction is rolled back, otherwise committed.
|
474
|
+
<dt><a name="ODBC::Environment.connection_pooling">
|
475
|
+
<code>connection_pooling[=<var>value</var>]</code></a>
|
476
|
+
<dd>Gets or sets the connection pooling attribute of the environment.
|
477
|
+
<dt><a name="ODBC::Environment.cp_match">
|
478
|
+
<code>cp_match[=<var>value</var>]</code></a>
|
479
|
+
<dd>Gets or sets the connection pooling match attribute of the
|
480
|
+
environment.
|
481
|
+
<dt><a name="ODBC::Environment.odbc_version">
|
482
|
+
<code>odbc_version[=<var>value</var>]</code></a>
|
483
|
+
<dd>Gets or sets the ODBC version attribute of the environment.
|
484
|
+
</dl>
|
485
|
+
<h3>singleton methods:</h3>
|
486
|
+
<dl>
|
487
|
+
<dt><a name="ODBC::Environment.new"><code>new</code></a>
|
488
|
+
<dd>Returns a new <a href="#ODBC::Environment">ODBC::Environment</a>
|
489
|
+
object.
|
490
|
+
</dl>
|
491
|
+
</div>
|
492
|
+
<hr>
|
493
|
+
<div>
|
494
|
+
<h2><a name="ODBC::Database">ODBC::Database</a></h2>
|
495
|
+
<p>
|
496
|
+
The class to represent a connection to an ODBC data source.
|
497
|
+
</p>
|
498
|
+
<p>
|
499
|
+
When underlying ODBC SQL functions report an error,
|
500
|
+
an <a href="#ODBC::Error">ODBC::Error</a>
|
501
|
+
exception with a corresponding error message from the ODBC
|
502
|
+
driver manager and/or driver is raised.
|
503
|
+
</p>
|
504
|
+
<h3>super class:</h3>
|
505
|
+
<code><a href="#ODBC::Environment">ODBC::Environment</a></code>
|
506
|
+
<h3>methods:</h3>
|
507
|
+
<dl>
|
508
|
+
<dt><a name="connected?"><code>connected?</code></a>
|
509
|
+
<dd>Returns <code>true</code> when the object is in connected
|
510
|
+
state, false otherwise.
|
511
|
+
<dt><a name="drvconnect"><code>drvconnect(<var>drv</var>)</code></a>
|
512
|
+
<dd>Connect to a data source specified by <var>drv</var>
|
513
|
+
(<a href="#ODBC::Driver">ODBC::Driver</a>).
|
514
|
+
<dt><a name="disconnect">
|
515
|
+
<code>disconnect(<var>no_drop=false</var>)</code></a>
|
516
|
+
<dd>Disconnects from the data source, all active statements for the
|
517
|
+
connection are dropped except when the <var>no_drop</var> argument
|
518
|
+
is true. The method returns true when the connection was released,
|
519
|
+
false otherwise.
|
520
|
+
<dt><a name="newstmt"><code>newstmt</code></a>
|
521
|
+
<dd>Returns a new <a href="#ODBC::Statement">ODBC::Statement</a>
|
522
|
+
object without preparing or executing a SQL statement. This allows
|
523
|
+
to use
|
524
|
+
<a href="#stmt_set_option"><code>ODBC::Statement.set_option</code></a>
|
525
|
+
to set special options on the statement before actual execution.
|
526
|
+
<dt><a name="tables"><code>tables([<var>pattern</var>])</code></a>
|
527
|
+
<dd>Returns an <a href="#ODBC::Statement">ODBC::Statement</a> with
|
528
|
+
information of all or some (<var>pattern</var> String given)
|
529
|
+
tables of the data source.
|
530
|
+
<dt><a name="columns"><code>columns([<var>table</var>[,<var>column</var>]])</code></a>
|
531
|
+
<dd>Returns an <a href="#ODBC::Statement">ODBC::Statement</a>
|
532
|
+
with column information
|
533
|
+
of the given <var>table</var> (String) and optional
|
534
|
+
<var>column</var> (String).
|
535
|
+
<dt><a name="indexes">
|
536
|
+
<code>indexes([<var>table</var>[,<var>unique</var>]])</code></a>
|
537
|
+
<dd>Returns an <a href="#ODBC::Statement">ODBC::Statement</a>
|
538
|
+
with index information
|
539
|
+
of the given <var>table</var> (String). If <var>unique</var>
|
540
|
+
is given and true, information for unique indexes only is
|
541
|
+
returned.
|
542
|
+
<dt><a name="types"><code>types([<var>tcode</var>])</code></a>
|
543
|
+
<dd>Returns an <a href="#ODBC::Statement">ODBC::Statement</a>
|
544
|
+
with type information
|
545
|
+
of the numeric SQL type <var>tcode</var> or all types if
|
546
|
+
<var>tcode</var> is omitted.
|
547
|
+
<dt><a name="primary_keys">
|
548
|
+
<code>primary_keys([<var>table</var>])</code></a>
|
549
|
+
<dd>Returns an <a href="#ODBC::Statement">ODBC::Statement</a>
|
550
|
+
with primary key information of the given <var>table</var> (String).
|
551
|
+
<dt><a name="foreign_keys">
|
552
|
+
<code>foreign_keys([<var>table</var>])</code></a>
|
553
|
+
<dd>Returns an <a href="#ODBC::Statement">ODBC::Statement</a>
|
554
|
+
with foreign key information of the given <var>table</var> (String).
|
555
|
+
<dt><a name="table_privileges">
|
556
|
+
<code>table_privileges([<var>table</var>])</code></a>
|
557
|
+
<dd>Returns an <a href="#ODBC::Statement">ODBC::Statement</a>
|
558
|
+
with owner/right information of the given <var>table</var> (String).
|
559
|
+
<dt><a name="procedures"><code>procedures([<var>p</var>])</code></a>
|
560
|
+
<dd>Returns an <a href="#ODBC::Statement">ODBC::Statement</a>
|
561
|
+
with information about stored procedures.
|
562
|
+
<dt><a name="procedure_columns">
|
563
|
+
<code>procedure_columns([<var>p</var>])</code></a>
|
564
|
+
<dd>Returns an <a href="#ODBC::Statement">ODBC::Statement</a>
|
565
|
+
with information about stored procedures.
|
566
|
+
<dt><a name="special_columns">
|
567
|
+
<code>special_columns([<var>table</var>[,<var>id</var>,<var>scope</var>]])</code></a>
|
568
|
+
<dd>Returns an <a href="#ODBC::Statement">ODBC::Statement</a>
|
569
|
+
with column information
|
570
|
+
of the given <var>table</var> (String) indicating the
|
571
|
+
optimal unique or identifying columns.
|
572
|
+
<var>id</var> may
|
573
|
+
be specified as <code>ODBC::SQL_BEST_ROWID</code> or
|
574
|
+
<code>ODBC::SQL_ROW_VER</code>. <var>scope</var> may be
|
575
|
+
specified as <code>ODBC::SQL_SCOPE_CURROW</code>,
|
576
|
+
<code>ODBC::SQL_SCOPE_TRANSACTION</code>, or
|
577
|
+
<code>ODBC::SQL_SCOPE_SESSION</code>. If omitted the
|
578
|
+
defaults are <code>ODBC::SQL_BEST_ROWID</code> and
|
579
|
+
<code>ODBC::SQL_SCOPE_CURROW</code>.
|
580
|
+
<dt><a name="get_info">
|
581
|
+
<code>get_info(<var>info_type</var>[,<var>sql_type</var>])</code></a>
|
582
|
+
<dd>Retrieves database meta data according to <var>info_type</var>
|
583
|
+
and returns numbers or strings. <var>info_type</var> may be specified
|
584
|
+
as integer or string. To force interpretation of the return value
|
585
|
+
of the underlying ODBC function <code>SQLGetInfo()</code> as a
|
586
|
+
specific Ruby type the optional parameter <var>sql_type</var>
|
587
|
+
can be given as e.g.
|
588
|
+
<code>ODBC::SQL_SMALLINT</code> (yielding integer),
|
589
|
+
<code>ODBC::SQL_INTEGER</code> (yielding integer), and
|
590
|
+
<code>ODBC::SQL_CHAR</code> (yielding string).
|
591
|
+
<dt><a name="run"><code>run(<var>sql</var>[,<var>args...</var>])</code></a>
|
592
|
+
<dd>Prepares and executes the query specified by <var>sql</var>
|
593
|
+
with parameters bound from <var>args</var> and returns an
|
594
|
+
<a href="#ODBC::Statement">ODBC::Statement</a> or nil, if
|
595
|
+
the query did not produce a result set, e.g. when executing
|
596
|
+
SQL insert, delete, or update statements.
|
597
|
+
<dt><a name="do"><code>do(<var>sql</var>[,<var>args...</var>])</code></a>
|
598
|
+
<dd>Prepares and executes the query as in
|
599
|
+
<a href="#run"><code>run</code></a>,
|
600
|
+
but returns the number of result rows and automatically drops
|
601
|
+
the statement. Useful for SQL insert, delete, or update statements.
|
602
|
+
<dt><a name="prepare"><code>prepare(<var>sql</var>)</code></a>
|
603
|
+
<dd>Prepares the query specified by <var>sql</var> and returns
|
604
|
+
an <a href="#ODBC::Statement">ODBC::Statement</a>.
|
605
|
+
<dt><a name="proc"><code>proc(<var>sql</var>,[<var>type</var>,<var>size</var>[,<var>n</var>=1]])
|
606
|
+
{|<var>stmt</var>| <var>block</var>}</code></a>
|
607
|
+
<dd>Prepares the query specified by <var>sql</var> within a
|
608
|
+
<a href="#ODBCProc">ODBCProc</a> and returns that procedure.
|
609
|
+
When the procedure is called, the statement is executed with
|
610
|
+
the procedure's arguments bound to the statement's parameters
|
611
|
+
and the statement is bound as parameter in the block, e.g.
|
612
|
+
<pre># add customer given name and id
|
613
|
+
# and return number of affected rows
|
614
|
+
|
615
|
+
addcust = dbc.proc("insert into customer values(?, ?)") { |stmt|
|
616
|
+
stmt.nrows
|
617
|
+
}
|
618
|
+
|
619
|
+
addcust.call("J.R. User", 9999)
|
620
|
+
|
621
|
+
# alternative to call: addcust["J.R. User", 9999]</pre>
|
622
|
+
The optional arguments <var>type</var>, <var>size</var>, and
|
623
|
+
<var>n</var>,
|
624
|
+
make the n-th statement parameter into an output parameter
|
625
|
+
with that given ODBC data type and size. That statement
|
626
|
+
parameter must be omitted when the <a href="#ODBCProc">ODBCProc</a>
|
627
|
+
is called. This can be useful for wrapping stored procedures, e.g.
|
628
|
+
<pre># wrap statement with output parameter
|
629
|
+
|
630
|
+
aproc = dbc.proc("{ ? = call stored_proc(?) }", ODBC::SQL_INTEGER, 4) {}
|
631
|
+
|
632
|
+
# call this statement/procedure, output parameter is result
|
633
|
+
|
634
|
+
result = aproc.call(99)
|
635
|
+
|
636
|
+
# alternative to call: result = aproc[99]</pre>
|
637
|
+
Finalization of an <a href="#ODBCProc">ODBCProc</a> can be
|
638
|
+
done according to this code snippet
|
639
|
+
<pre># aproc is wrapped statement, finalize it now
|
640
|
+
|
641
|
+
aproc.statement.drop</pre>
|
642
|
+
<dt><a name="dbc_get_option">
|
643
|
+
<code>get_option(<var>option</var>)</code></a>
|
644
|
+
<dd>Gets a connection level option. <var>option</var> can be a
|
645
|
+
module constant, e.g. <var>SQL_MAX_ROWS</var>, a number, or a
|
646
|
+
string. This method returns the integer value of that option.
|
647
|
+
<dt><a name="dbc_set_option">
|
648
|
+
<code>set_option(<var>option</var>,<var>intval</var>)</code></a>
|
649
|
+
<dd>Sets a connection level option. <var>option</var> can be a
|
650
|
+
module constant, e.g. <var>SQL_MAX_ROWS</var>, a number, or a
|
651
|
+
string. The second parameter <var>intval</var> can be used to
|
652
|
+
set driver-specific statement options.
|
653
|
+
<dt><a name="autocommit"><code>autocommit[=<var>bool</var>]</code></a>
|
654
|
+
<dd>Sets or queries the autocommit option of the connection.
|
655
|
+
<dt><a name="concurrency">
|
656
|
+
<code>concurrency[=<var>intval</var>]</code></a>
|
657
|
+
<dd>Sets or queries the concurrency mode of cursors opened on
|
658
|
+
the connection.
|
659
|
+
<dt><a name="maxrows"><code>maxrows[=<var>intval</var>]</code></a>
|
660
|
+
<dd>Sets or queries the maximum rows returned in result sets from
|
661
|
+
the connection.
|
662
|
+
<dt><a name="timeout"><code>timeout[=<var>intval</var>]</code></a>
|
663
|
+
<dd>Sets or queries the number of seconds to wait for queries to
|
664
|
+
execute on the connection before returning.
|
665
|
+
<dt><a name="maxlength"><code>maxlength[=<var>intval</var>]</code></a>
|
666
|
+
<dd>Sets or queries the maximum amount of data that will be returned
|
667
|
+
from a character or binary column.
|
668
|
+
<dt><a name="cursortype">
|
669
|
+
<code>cursortype[=<var>intval</var>]</code></a>
|
670
|
+
<dd>Sets or queries the cursor type used for fetches.
|
671
|
+
<dt><a name="noscan"><code>noscan[=<var>bool</var>]</code></a>
|
672
|
+
<dd>Sets or queries whether the driver scans SQL strings for ODBC
|
673
|
+
escape clauses.
|
674
|
+
<dt><a name="rowsetsize"><code>rowsetsize</code></a>
|
675
|
+
<dd>Returns the number of rows in a rowset fetched internally by a
|
676
|
+
call o SQLExtendedFetch (hardcoded to 1).
|
677
|
+
<dt><a name="ignorecase"><code>ignorecase[=<var>bool</var>]</code><a>
|
678
|
+
<dd>Sets or queries the uppercase conversion for column names. If
|
679
|
+
turned on (<var>bool</var> is true),
|
680
|
+
<a href="#ODBC::Statement">ODBC::Statement</a>s
|
681
|
+
created by database methods will report column names in
|
682
|
+
<a href="#ODBC::Column">ODBC::Column</a>
|
683
|
+
or in the statement fetch methods
|
684
|
+
as uppercase strings. Otherwise (the default) column names are
|
685
|
+
passed unmodified.
|
686
|
+
<dt><a name="drop_all"><code>drop_all</code></a>
|
687
|
+
<dd>Releases the resources of all open
|
688
|
+
<a href="#ODBC::Statement">ODBC::Statement</a>s in this
|
689
|
+
database connection.
|
690
|
+
</dl>
|
691
|
+
<h3>singleton methods:</h3>
|
692
|
+
<dl>
|
693
|
+
<dt><a name="ODBC::new"><code>new</code></a>
|
694
|
+
<dd>Creates an unconnected ODBC object, e.g. for a later
|
695
|
+
<code>drvconnect</code> method call.
|
696
|
+
<dt><a name="ODBC::new2"><code>new(<var>dsn</var>,[<var>user</var>,<var>passwd</var>])</code></a>
|
697
|
+
<dd>Connect to an ODBC data source. Options are:
|
698
|
+
<dl>
|
699
|
+
<dd><var>dsn</var>: Data source name (String or
|
700
|
+
<a href="#ODBC::DSN">ODBC::DSN</a>)
|
701
|
+
<dd><var>user</var>: Login user name (String)
|
702
|
+
<dd><var>passwd</var>: Login password (String)
|
703
|
+
</dl>
|
704
|
+
</dl>
|
705
|
+
<h3>Remarks:</h3>
|
706
|
+
The <a href="#run"><code>run</code></a>,
|
707
|
+
<a href="#prepare"><code>prepare</code></a>,
|
708
|
+
<a href="#do"><code>do</code></a>, and info methods
|
709
|
+
(e.g. <a href="#tables"><code>tables</code></a>)
|
710
|
+
can be invoked with a block. In this case the block is executed with
|
711
|
+
the <a href="#ODBC::Statement">ODBC::Statement</a> as parameter. The
|
712
|
+
<a href="#run"><code>run</code></a> and
|
713
|
+
<a href="#do"><code>do</code></a> methods use the ODBC API
|
714
|
+
function <code>SQLExecDirect()</code> when the SQL statement has no
|
715
|
+
parameters.
|
716
|
+
</div>
|
717
|
+
<hr>
|
718
|
+
<div>
|
719
|
+
<h2><a name="ODBC::Statement">ODBC::Statement</a></h2>
|
720
|
+
<p>
|
721
|
+
The class to represent a query and its query result.
|
722
|
+
The object of this class is created as the result of every query.
|
723
|
+
You may need to invoke the <a href="#close"><code>close</code></a>
|
724
|
+
or <a href="#drop"><code>drop</code></a> methods for the
|
725
|
+
finished object for better memory performance.
|
726
|
+
</p>
|
727
|
+
<p>
|
728
|
+
When underlying ODBC SQL functions report an error,
|
729
|
+
an <a href="#ODBC::Error">ODBC::Error</a>
|
730
|
+
exception with a corresponding error message from the ODBC driver
|
731
|
+
manager and/or driver is raised.
|
732
|
+
</p>
|
733
|
+
<p>
|
734
|
+
ODBC to Ruby type mapping:
|
735
|
+
</p>
|
736
|
+
<table><tr><th>ODBC</th><th>Ruby</th></tr>
|
737
|
+
<tr><td>SQL_SMALLINT, SQL_INTEGER, SQL_TINYINT, SQL_BIT</td>
|
738
|
+
<td>T_FIXNUM, T_BIGNUM</td></tr>
|
739
|
+
<tr><td>SQL_FLOAT, SQL_DOUBLE, SQL_REAL</td><td>T_FLOAT</td></tr>
|
740
|
+
<tr><td>SQL_DATE, SQL_TYPE_DATE</td>
|
741
|
+
<td><a href="#ODBC::Date">ODBC::Date</a></td></tr>
|
742
|
+
<tr><td>SQL_TIME, SQL_TYPE_TIME</td>
|
743
|
+
<td><a href="#ODBC::Time">ODBC::Time</a></td></tr>
|
744
|
+
<tr><td>SQL_TIMESTAMP, SQL_TYPE_TIMESTAMP</td>
|
745
|
+
<td><a href="#ODBC::TimeStamp">ODBC::TimeStamp</a></td></tr>
|
746
|
+
<tr><td>all others</td><td>T_STRING</td></tr>
|
747
|
+
</table>
|
748
|
+
<h3>super class:</h3>
|
749
|
+
<p>
|
750
|
+
<code><a href="#ODBC::Database">ODBC::Database</a></code>
|
751
|
+
</p>
|
752
|
+
<h3>mixins:</h3>
|
753
|
+
<p>
|
754
|
+
<code>Enumerable</code>
|
755
|
+
</p>
|
756
|
+
<h3>methods:</h3>
|
757
|
+
<dl>
|
758
|
+
<dt><a name="cancel"><code>cancel</code></a>
|
759
|
+
<dd>Cancel and close the
|
760
|
+
<a href="#ODBC::Statement">ODBC::Statement</a>.
|
761
|
+
<dt><a name="close"><code>close</code></a>
|
762
|
+
<dd>Close the <a href="#ODBC::Statement">ODBC::Statement</a>.
|
763
|
+
<dt><a name="drop"><code>drop</code></a>
|
764
|
+
<dd>Close and free the <a href="#ODBC::Statement">ODBC::Statement</a>.
|
765
|
+
<dt><a name="column"><code>column(<var>n</var>)</code></a>
|
766
|
+
<dd>Returns information of the n-th column of the query result
|
767
|
+
as <a href="#ODBC::Column">ODBC::Column</a>.
|
768
|
+
<dt><a name="columns1"><code>columns(<var>as_ary=false</var>)</code></a>
|
769
|
+
<dd>Returns a hash of column information keyed by column names
|
770
|
+
(Strings) of the query result. If <var>as_ary</var> is true,
|
771
|
+
an array is returned. In both cases the elements are
|
772
|
+
<a href="#ODBC::Column">ODBC::Column</a>s. If the hash keys
|
773
|
+
happen to be not unique later columns get their column number
|
774
|
+
appended, e.g. <code>FOOBAR</code>, <code>FOOBAR#1</code>.
|
775
|
+
<dt><a name="columns2"><code>columns
|
776
|
+
{|<var>col</var>| <var>block</var>}</code></a>
|
777
|
+
<dd>Iterates over the columns of the query result with <var>col</var>
|
778
|
+
bound to each <a href="#ODBC::Column">ODBC::Column</a>.
|
779
|
+
<dt><a name="ncols"><code>ncols</code></a>
|
780
|
+
<dd>Returns the number of columns of the query result.
|
781
|
+
<dt><a name="nrows"><code>nrows</code></a>
|
782
|
+
<dd>Returns the number of rows of the query result.
|
783
|
+
<dt><a name="cursorname"><code>cursorname[=<var>name</var>]</code></a>
|
784
|
+
<dd>Returns or sets the cursor name of the statement.
|
785
|
+
<dt><a name="ignorecase2"><code>ignorecase[=<var>bool</var>]</code><a>
|
786
|
+
<dd>Same as
|
787
|
+
<a href="#ignorecase"><code>ODBC::Database.ignorecase</code></a>
|
788
|
+
but affecting this statement only.
|
789
|
+
Inherited by the current state of the
|
790
|
+
<a href="#ODBC::Database">ODBC::Database</a> at the time the
|
791
|
+
statement is created.
|
792
|
+
<dt><a name="fetch"><code>fetch</code></a>
|
793
|
+
<dd>Returns the next row of the query result as an array.
|
794
|
+
<dt><a name="fetch_first"><code>fetch_first</code></a>
|
795
|
+
<dd>Returns the first row of the query result as an array.
|
796
|
+
<dt><a name="fetch_scroll"><code>fetch_scroll(<var>direction</var>,
|
797
|
+
<var>offset=1</var>)</code></a>
|
798
|
+
<dd>Returns the row addressed by <var>direction</var>, e.g.
|
799
|
+
<code>SQL_FETCH_LAST</code> as an array. <var>offset</var> is
|
800
|
+
used for <code>SQL_FETCH_RELATIVE</code> and
|
801
|
+
<code>SQL_FETCH_ABSOLUTE</code>.
|
802
|
+
<dt><a name="fetch_many"><code>fetch_many(<var>count</var>)</code></a>
|
803
|
+
<dd>Returns an array of the next <var>count</var> rows of the query
|
804
|
+
result, where each row is an array.
|
805
|
+
<dt><a name="fetch_all"><code>fetch_all</code></a>
|
806
|
+
<dd>Same as <code>fetch_many</code> except that all remaining rows
|
807
|
+
are returned.
|
808
|
+
<dt><a name="fetch_hash">
|
809
|
+
<code>fetch_hash(<var>with_table_names=false</var>,<var>use_sym=false</var>)</code></a>
|
810
|
+
<dd>Returns the next row of the query result as a hash keyed by
|
811
|
+
column names. If <var>with_table_names</var> is true,
|
812
|
+
the keys are combined table/column names. For uniqueness of keys
|
813
|
+
the same rules as in the <a href="#columns1"><code>columns</code></a>
|
814
|
+
method are applied. If <var>use_sym</var> is true,
|
815
|
+
the keys are formed by intern'ing the (table and) column names.
|
816
|
+
Alternatively, one hash argument can be presented to
|
817
|
+
<code>fetch_hash</code>, e.g.
|
818
|
+
<code>{ :key => :Symbol, :table_names => false }</code> or
|
819
|
+
<code>{ :key => :String, :table_names => true }</code> or
|
820
|
+
<code>{ :key => :Fixnum }</code>.
|
821
|
+
<dt><a name="each"><code>each {|<var>row</var>|
|
822
|
+
<var>block</var>}</code></a>
|
823
|
+
<dd>Iterates over the query result, performing a <code>fetch</code>
|
824
|
+
for each row.
|
825
|
+
<dt><a name="each_hash">
|
826
|
+
<code>each_hash(<var>with_table_names=false</var>,<var>use_sym=false</var>)
|
827
|
+
{|<var>row</var>| <var>block</var>}</code></a>
|
828
|
+
<dd>Iterates over the query result, performing a
|
829
|
+
<code>fetch_hash</code> for each row. The same
|
830
|
+
rules for arguments as in <code>fetch_hash</code> apply.
|
831
|
+
<dt><a name="execute"><code>execute([<var>args...</var>])</code></a>
|
832
|
+
<dd>Binds <var>args</var> to current query and executes it.
|
833
|
+
<dt><a name="stmt_run">
|
834
|
+
<code>run(<var>sql</var>[,<var>args...</var>])</code></a>
|
835
|
+
<dd>Prepares and executes the query specified by <var>sql</var>
|
836
|
+
with parameters bound from <var>args</var>.
|
837
|
+
<dt><a name="stmt_prep">
|
838
|
+
<code>prepare(<var>sql</var>)</code></a>
|
839
|
+
<dd>Prepares the query specified by <var>sql</var>.
|
840
|
+
<dt><a name="more_results"><code>more_results</code></a>
|
841
|
+
<dd>Returns true and switches over to the next result set,
|
842
|
+
if the query produced more than one result set. Otherwise
|
843
|
+
returns false.
|
844
|
+
<dt><a name="stmt_get_option">
|
845
|
+
<code>get_option(<var>option</var>)</code></a>
|
846
|
+
<dd>Gets a statement level option. <var>option</var> can be a
|
847
|
+
module constant, e.g. <var>SQL_MAX_ROWS</var>, a number, or a
|
848
|
+
string. This method returns the integer value of that option.
|
849
|
+
<dt><a name="stmt_set_option">
|
850
|
+
<code>set_option(<var>option</var>,<var>intval</var>)</code></a>
|
851
|
+
<dd>Sets a statement level option. <var>option</var> can be a
|
852
|
+
module constant, e.g. <var>SQL_MAX_ROWS</var>, a number, or a
|
853
|
+
string. The second parameter <var>intval</var> can be used to
|
854
|
+
set driver-specific statement options.
|
855
|
+
<dt><a name="stmt_concurrency">
|
856
|
+
<code>concurrency[=<var>intval</var>]</code></a>
|
857
|
+
<dd>Sets or queries the concurrency mode of cursors opened on
|
858
|
+
the statement.
|
859
|
+
<dt><a name="stmt_maxrows"><code>maxrows[=<var>intval</var>]</code></a>
|
860
|
+
<dd>Sets or queries the maximum rows returned by the statement.
|
861
|
+
<dt><a name="stmt_timeout"><code>timeout[=<var>intval</var>]</code></a>
|
862
|
+
<dd>Sets or queries the number of seconds to wait for the statement
|
863
|
+
to execute before returning.
|
864
|
+
<dt><a name="stmt_maxlength">
|
865
|
+
<code>maxlength[=<var>intval</var>]</code></a>
|
866
|
+
<dd>Sets or queries the maximum amount of data that will be returned
|
867
|
+
from a character or binary column.
|
868
|
+
<dt><a name="stmt_cursortype">
|
869
|
+
<code>cursortype[=<var>intval</var>]</code></a>
|
870
|
+
<dd>Sets or queries the cursor type used for fetches.
|
871
|
+
<dt><a name="stmt_noscan"><code>noscan[=<var>bool</var>]</code></a>
|
872
|
+
<dd>Sets or queries whether the driver scans SQL strings for ODBC
|
873
|
+
escape clauses.
|
874
|
+
<dt><a name="stmt_rowsetsize"><code>rowsetsize</code></a>
|
875
|
+
<dd>Returns the number of rows in a rowset fetched internally by
|
876
|
+
a call to <var>SQLExtendedFetch</var> (hardcoded to 1).
|
877
|
+
<dt><a name="stmt_nparams"><code>nparams</code></a>
|
878
|
+
<dd>Returns the number of parameters of the statement.
|
879
|
+
<dt><a name="parameter"><code>parameter(<var>n</var>)</code></a>
|
880
|
+
<dd>Returns information of the n-th parameter of the query
|
881
|
+
as <a href="#ODBC::Parameter">ODBC::Parameter</a>.
|
882
|
+
<dt><a name="parameters"><code>parameters</code></a>
|
883
|
+
<dd>Returns an array of
|
884
|
+
<a href="#ODBC::Parameter">ODBC::Parameter</a>s describing
|
885
|
+
all parameters of the query.
|
886
|
+
<dt><a name="stmt_param_type"><code>param_type(<var>n</var>[,<var>type</var>,<var>coldef</var>,<var>scale</var>])</code></a>
|
887
|
+
<dd>Allows to override the type of parameter <var>n</var>
|
888
|
+
and returns the current type. This can be useful
|
889
|
+
when the ODBC driver does not provide proper type information
|
890
|
+
on <var>SQLDescribeParam</var>.
|
891
|
+
<dt><a name="stmt_param_iotype"><code>param_iotype(<var>n</var>[,<var>iotype</var>])</code></a>
|
892
|
+
<dd>Allows to change the input/output type of parameter <var>n</var>
|
893
|
+
and returns the current input/output type. By
|
894
|
+
default, all parameters are <var>ODBC::SQL_PARAM_INPUT</var>.
|
895
|
+
When calling a stored procedure in the statement, the output
|
896
|
+
parameter must be altered using this method, e.g.
|
897
|
+
<pre># assume 1st parameter is input, 2nd is output
|
898
|
+
stmt = conn.prepare("call stored_proc( ?, ?)")
|
899
|
+
# setup 2nd for output of an integer
|
900
|
+
stmt.param_iotype(2, ODBC::SQL_PARAM_OUTPUT)
|
901
|
+
stmt.param_output_type(2, ODBC::SQL_INTEGER)
|
902
|
+
stmt.param_output_size(2, 4)
|
903
|
+
# execute stmt and retrieve value of output parameter
|
904
|
+
stmt.execute(42, nil)
|
905
|
+
stmt.fetch_all
|
906
|
+
out_value = stmt.param_output_value(2);</pre>
|
907
|
+
<dt><a name="stmt_param_output_type"><code>param_output_type(<var>n</var>[,<var>type</var>])</code></a>
|
908
|
+
<dd>Allows to change the SQL type of output parameter <var>n</var>
|
909
|
+
and returns the current type. For further
|
910
|
+
information see the sample code in the
|
911
|
+
<a href="#stmt_param_iotype"><code>param_iotype</code></a> method.
|
912
|
+
<dt><a name="stmt_param_output_size"><code>param_output_size(<var>n</var>[,<var>size</var>])</code></a>
|
913
|
+
<dd>Allows to change the byte size of the buffer for output parameter
|
914
|
+
<var>n</var> and returns the current size.
|
915
|
+
For further information see the sample code in the
|
916
|
+
<a href="#stmt_param_iotype"><code>param_iotype</code></a> method.
|
917
|
+
<dt><a name="stmt_param_output_value"><code>param_output_value(<var>n</var>)</code></a>
|
918
|
+
<dd>Returns the value of the output parameter <var>n</var>.
|
919
|
+
For further information see the sample code in the
|
920
|
+
<a href="#stmt_param_iotype"><code>param_iotype</code></a> method.
|
921
|
+
<dt><a name="make_proc1"><code>make_proc([<var>n</var>])</code></a>
|
922
|
+
<dd>Wraps the statement into a <a href="#ODBCProc">ODBCProc</a> object
|
923
|
+
and returns that object. The optional <var>n</var> argument is
|
924
|
+
the parameter number of the statement which is used as output
|
925
|
+
parameter in the wrapped <a href="#ODBCProc">ODBCProc</a>. For
|
926
|
+
further information refer to the samples in the description of
|
927
|
+
<a href="#proc"><code>ODBC::Database.proc</code></a>.
|
928
|
+
</dl>
|
929
|
+
<h3>singleton methods:</h3>
|
930
|
+
<dl>
|
931
|
+
<dt><a name="make_proc2"><code>make_proc(<var>stmt</var>,[<var>n</var>])</code></a>
|
932
|
+
<dd>Wraps the statement <var>stmt</var> into a
|
933
|
+
<a href="#ODBCProc">ODBCProc</a> object
|
934
|
+
and returns that object. The optional <var>n</var> argument is
|
935
|
+
the parameter number of the statement which is used as output
|
936
|
+
parameter in the wrapped <a href="#ODBCProc">ODBCProc</a>. For
|
937
|
+
further information refer to the samples in the description of
|
938
|
+
<a href="#proc"><code>ODBC::Database.proc</code></a>.
|
939
|
+
</dl>
|
940
|
+
<h3>Remarks:</h3>
|
941
|
+
The <a href="#fetch"><code>fetch</code></a>,
|
942
|
+
<a href="#fetch_hash"><code>fetch_hash</code></a>,
|
943
|
+
and <a href="#execute"><code>execute</code></a>
|
944
|
+
methods can be invoked with a block. In this case the block is
|
945
|
+
executed with one row of the result set (<code>fetch</code> and
|
946
|
+
<code>fetch_hash</code>) or with the
|
947
|
+
<a href="#ODBC::Statement">ODBC::Statement</a> (<code>execute</code>)
|
948
|
+
as parameter.
|
949
|
+
<p>If the <a href="#ignorecase2"><code>ignorecase</code></a> option
|
950
|
+
is turned on, all column names used in the <code>column</code>,
|
951
|
+
<code>columns</code>, and <code>*_hash</code> methods are converted to
|
952
|
+
upper case.
|
953
|
+
</div>
|
954
|
+
<hr>
|
955
|
+
<div>
|
956
|
+
<h2><a name="ODBC::Column">ODBC::Column</a></h2>
|
957
|
+
<p>
|
958
|
+
The class to represent (read-only) information of a column of a query.
|
959
|
+
Objects of this class are created as result of the
|
960
|
+
<a href="#column"><code>column</code></a>
|
961
|
+
and <a href="#columns1"><code>columns</code></a> methods of
|
962
|
+
<a href="#ODBC::Statement">ODBC::Statement</a>.
|
963
|
+
</p>
|
964
|
+
<h3>super class:</h3>
|
965
|
+
<p>
|
966
|
+
<code><a href="#ODBC::Object">ODBC::Object</a></code>
|
967
|
+
</p>
|
968
|
+
<h3>methods:</h3>
|
969
|
+
<dl>
|
970
|
+
<dt><code>name</code></a>
|
971
|
+
<dd>Returns the column name (String).
|
972
|
+
<dt><code>table</code></a>
|
973
|
+
<dd>Returns the table name (String).
|
974
|
+
<dt><code>length</code></a>
|
975
|
+
<dd>Returns the length of the column (Integer).
|
976
|
+
<dt><code>nullable</code></a>
|
977
|
+
<dd>Returns the nullable state of the column (Boolean).
|
978
|
+
<dt><code>searchable</code></a>
|
979
|
+
<dd>Returns the searchable state of the column (Boolean).
|
980
|
+
<dt><code>unsigned</code></a>
|
981
|
+
<dd>Returns the unsigned flag of the column (Boolean).
|
982
|
+
<dt><code>precision</code></a>
|
983
|
+
<dd>Returns the precision of the column (Integer).
|
984
|
+
<dt><code>scale</code></a>
|
985
|
+
<dd>Returns the scale of the column (Integer).
|
986
|
+
<dt><code>type</code></a>
|
987
|
+
<dd>Returns the SQL type of the column (Integer).
|
988
|
+
<dt><code>autoincrement</code></a>
|
989
|
+
<dd>Returns true if the column automatically increments,
|
990
|
+
false, if not, and nil if that information cannot be
|
991
|
+
determined from the column.
|
992
|
+
</dl>
|
993
|
+
</div>
|
994
|
+
<hr>
|
995
|
+
<div>
|
996
|
+
<h2><a name="ODBC::Parameter">ODBC::Parameter</a></h2>
|
997
|
+
<p>
|
998
|
+
The class to represent (read-only) information of a parameter of a
|
999
|
+
query.
|
1000
|
+
Objects of this class are created as result of the
|
1001
|
+
<a href="#parameter"><code>parameter</code></a> and
|
1002
|
+
<a href="#parameters"><code>parameters</code><a> methods of
|
1003
|
+
<a href="#ODBC::Statement">ODBC::Statement</a>.
|
1004
|
+
</p>
|
1005
|
+
<h3>super class:</h3>
|
1006
|
+
<p>
|
1007
|
+
<code><a href="#ODBC::Object">ODBC::Object</a></code>
|
1008
|
+
</p>
|
1009
|
+
<h3>methods:</h3>
|
1010
|
+
<dl>
|
1011
|
+
<dt><code>type</code></a>
|
1012
|
+
<dd>Returns the parameter's type, e.g. ODBC::SQL_CHAR.
|
1013
|
+
<dt><code>precision</code></a>
|
1014
|
+
<dd>Returns the parameter's precision (Integer).
|
1015
|
+
<dt><code>length</code></a>
|
1016
|
+
<dd>Returns the parameter's scale (Integer).
|
1017
|
+
<dt><code>nullable</code></a>
|
1018
|
+
<dd>Returns the nullable state of the column (Boolean).
|
1019
|
+
<dt><code>iotype</code></a>
|
1020
|
+
<dd>Returns the parameter's input/output type,
|
1021
|
+
e.g. ODBC::SQL_PARAM_INPUT.
|
1022
|
+
<dt><code>output_type</code></a>
|
1023
|
+
<dd>Returns the parameter's output type, only useful when the
|
1024
|
+
parameter is an output parameter (ODBC::SQL_PARAM_OUTPUT or
|
1025
|
+
ODBC::SQL_PARAM_INPUT_OUTPUT).
|
1026
|
+
<dt><code>output_size</code></a>
|
1027
|
+
<dd>Returns the parameter's output buffer size, only useful when the
|
1028
|
+
parameter is an output parameter (ODBC::SQL_PARAM_OUTPUT).
|
1029
|
+
</dl>
|
1030
|
+
</div>
|
1031
|
+
<hr>
|
1032
|
+
<div>
|
1033
|
+
<h2><a name="ODBC::Date">ODBC::Date</a></h2>
|
1034
|
+
<p>
|
1035
|
+
The class to represent a <code>SQL_DATE</code> column in a table
|
1036
|
+
or a <code>SQL_DATE</code> query parameter.
|
1037
|
+
</p>
|
1038
|
+
<h3>super class:</h3>
|
1039
|
+
<p>
|
1040
|
+
<code><a href="#ODBC::Object">ODBC::Object</a></code>
|
1041
|
+
</p>
|
1042
|
+
<h3>mixins:</h3>
|
1043
|
+
<p>
|
1044
|
+
<code>Comparable</code>
|
1045
|
+
</p>
|
1046
|
+
<h3>methods:</h3>
|
1047
|
+
<dl>
|
1048
|
+
<dt><a name="date.cmp"><code><=>(<var>adate</var>)</code></a>
|
1049
|
+
<dd>Comparison, compares date with <var>adate</var> and returns
|
1050
|
+
0, 1, or -1.
|
1051
|
+
<dt><a name="date.day"><code>day[=<var>num</var>]</code></a>
|
1052
|
+
<dd>Returns or sets the day component of the date object.
|
1053
|
+
<dt><a name="date.month"><code>month[=<var>num</var>]</code></a>
|
1054
|
+
<dd>Returns or sets the month component of the date object.
|
1055
|
+
<dt><a name="date.year"><code>year[=<var>num</var>]</code></a>
|
1056
|
+
<dd>Returns or sets the year component of the date object.
|
1057
|
+
<dt><a name="date.to_s"><code>to_s</code></a>
|
1058
|
+
<dd>Returns a string representation of the object with format
|
1059
|
+
<code>YYYY-MM-DD</code>.
|
1060
|
+
<dt><a name="date.clone"><code>clone</code></a>
|
1061
|
+
<dd>Returns a fresh copy of the date object.
|
1062
|
+
</dl>
|
1063
|
+
<h3>singleton methods:</h3>
|
1064
|
+
<dl>
|
1065
|
+
<dt><a name="date.new"><code>new([<var>year</var>, <var>month</var>,
|
1066
|
+
<var>day</var>])</code></a>
|
1067
|
+
<dt><code>new(<var>date</var>)</code>
|
1068
|
+
<dt><code>new(<var>time</var>)</code>
|
1069
|
+
<dt><code>new(<var>string</var>)</code>
|
1070
|
+
<dd>Creates a new date object from numeric values or from
|
1071
|
+
a <code>Date</code>, <code>Time</code>, or <code>String</code>
|
1072
|
+
object. Recognized string formats are e.g.
|
1073
|
+
<pre>2001-01-01
|
1074
|
+
2001-01-01 12:00:01
|
1075
|
+
{ts '2001-01-01 12:00:01.1'}
|
1076
|
+
{d '2001-01-01'}</pre>
|
1077
|
+
</dl>
|
1078
|
+
</div>
|
1079
|
+
<hr>
|
1080
|
+
<div>
|
1081
|
+
<h2><a name="ODBC::Time">ODBC::Time</a></h2>
|
1082
|
+
<p>
|
1083
|
+
The class to represent a <code>SQL_TIME</code> column in a table
|
1084
|
+
or a <code>SQL_TIME</code> query parameter.
|
1085
|
+
</p>
|
1086
|
+
<h3>super class:</h3>
|
1087
|
+
<p>
|
1088
|
+
<code><a href="#ODBC::Object">ODBC::Object</a></code>
|
1089
|
+
</p>
|
1090
|
+
<h3>mixins:</h3>
|
1091
|
+
<p>
|
1092
|
+
<code>Comparable</code>
|
1093
|
+
</p>
|
1094
|
+
<h3>methods:</h3>
|
1095
|
+
<dl>
|
1096
|
+
<dt><a name="time.cmp"><code><=>(<var>atime</var>)</code></a>
|
1097
|
+
<dd>Comparison, compares time with <var>atime</var> and returns
|
1098
|
+
0, 1, or -1.
|
1099
|
+
<dt><a name="time.second"><code>second[=<var>num</var>]</code></a>
|
1100
|
+
<dd>Returns or sets the second component of the time object.
|
1101
|
+
<dt><a name="time.minute"><code>minute[=<var>num</var>]</code></a>
|
1102
|
+
<dd>Returns or sets the minute component of the time object.
|
1103
|
+
<dt><a name="time.hour"><code>hour[=<var>num</var>]</code></a>
|
1104
|
+
<dd>Returns or sets the hour component of the time object.
|
1105
|
+
<dt><a name="time.to_s"><code>to_s</code></a>
|
1106
|
+
<dd>Returns a string representation of the object with format
|
1107
|
+
<code>hh:mm:ss</code>.
|
1108
|
+
<dt><a name="time.clone"><code>clone</code></a>
|
1109
|
+
<dd>Returns a fresh copy of the time object.
|
1110
|
+
</dl>
|
1111
|
+
<h3>singleton methods:</h3>
|
1112
|
+
<dl>
|
1113
|
+
<dt><a name="time.new"><code>new([<var>hour</var>, <var>minute</var>,
|
1114
|
+
<var>second</var>])</code></a>
|
1115
|
+
<dt><code>new(<var>time</var>)</code>
|
1116
|
+
<dt><code>new(<var>string</var>)</code>
|
1117
|
+
<dd>Creates a new time object from numeric values or from
|
1118
|
+
a <code>Time</code> or <code>String</code> object.
|
1119
|
+
Recognized string formats are e.g.
|
1120
|
+
<pre>12:00:01
|
1121
|
+
2001-01-01 12:00:01
|
1122
|
+
{ts '2001-01-01 12:00:01.1'}
|
1123
|
+
{t '12:00:01'}</pre>
|
1124
|
+
</dl>
|
1125
|
+
</div>
|
1126
|
+
<hr>
|
1127
|
+
<div>
|
1128
|
+
<h2><a name="ODBC::TimeStamp">ODBC::TimeStamp</a></h2>
|
1129
|
+
<p>
|
1130
|
+
The class to represent a <code>SQL_TIMESTAMP</code> column in a table
|
1131
|
+
or a <code>SQL_TIMESTAMP</code> query parameter.
|
1132
|
+
</p>
|
1133
|
+
<h3>super class:</h3>
|
1134
|
+
<p>
|
1135
|
+
<code><a href="#ODBC::Object">ODBC::Object</a></code>
|
1136
|
+
</p>
|
1137
|
+
<h3>mixins:</h3>
|
1138
|
+
<p>
|
1139
|
+
<code>Comparable</code>
|
1140
|
+
</p>
|
1141
|
+
<h3>methods:</h3>
|
1142
|
+
<dl>
|
1143
|
+
<dt><a name="ts.cmp"><code><=>(<var>atimestamp</var>)</code></a>
|
1144
|
+
<dd>Comparison, compares time stamp with <var>atimestamp</var>
|
1145
|
+
and returns 0, 1, or -1.
|
1146
|
+
<dt><a name="ts.fraction"><code>fraction[=<var>num</var>]</code></a>
|
1147
|
+
<dd>Returns or sets the fraction component of the time stamp object.
|
1148
|
+
Note that this is expressed in nanoseconds.
|
1149
|
+
<dt><a name="ts.second"><code>second[=<var>num</var>]</code></a>
|
1150
|
+
<dd>Returns or sets the second component of the time stamp object.
|
1151
|
+
<dt><a name="ts.minute"><code>minute[=<var>num</var>]</code></a>
|
1152
|
+
<dd>Returns or sets the minute component of the time stamp object.
|
1153
|
+
<dt><a name="ts.hour"><code>hour[=<var>num</var>]</code></a>
|
1154
|
+
<dd>Returns or sets the hour component of the time stamp object.
|
1155
|
+
<dt><a name="ts.day"><code>day[=<var>num</var>]</code></a>
|
1156
|
+
<dd>Returns or sets the day component of the time stamp object.
|
1157
|
+
<dt><a name="ts.month"><code>month[=<var>num</var>]</code></a>
|
1158
|
+
<dd>Returns or sets the month component of the time stamp object.
|
1159
|
+
<dt><a name="ts.year"><code>year[=<var>num</var>]</code></a>
|
1160
|
+
<dd>Returns or sets the year component of the time stamp object.
|
1161
|
+
<dt><a name="ts.to_s"><code>to_s</code></a>
|
1162
|
+
<dd>Returns a string representation of the object with format
|
1163
|
+
<code>YYYY-MM-DD hh:mm:ss fraction</code>.
|
1164
|
+
<dt><a name="ts.clone"><code>clone</code></a>
|
1165
|
+
<dd>Returns a fresh copy of the time stamp object.
|
1166
|
+
</dl>
|
1167
|
+
<h3>singleton methods:</h3>
|
1168
|
+
<dl>
|
1169
|
+
<dt><a name="ts.new"><code>new([<var>year</var>, <var>month</var>,
|
1170
|
+
<var>day</var>, <var>hour</var>, <var>minute</var>,
|
1171
|
+
<var>second</var>, <var>fraction</var>])</code></a>
|
1172
|
+
<dt><code>new(<var>time</var>)</code>
|
1173
|
+
<dt><code>new(<var>string</var>)</code>
|
1174
|
+
<dd>Creates a new time stamp object from numeric values or from
|
1175
|
+
a <code>Time</code> or <code>String</code> object.
|
1176
|
+
Recognized string formats are e.g.
|
1177
|
+
<pre>12:00:01
|
1178
|
+
2001-01-01
|
1179
|
+
2001-01-01 12:00:01
|
1180
|
+
{ts '2001-01-01 12:00:01.1'}
|
1181
|
+
{d '2001-01-01'}
|
1182
|
+
{t '12:00:01'}</pre>
|
1183
|
+
</dl>
|
1184
|
+
</div>
|
1185
|
+
<hr>
|
1186
|
+
<div>
|
1187
|
+
<h2><a name="ODBC::DSN">ODBC::DSN</a></h2>
|
1188
|
+
<p>
|
1189
|
+
The class to represent a data source name. Objects of this class are
|
1190
|
+
created as result of a
|
1191
|
+
<a href="#ODBC::datasources"><code>ODBC::datasources</code></a>
|
1192
|
+
module function call.
|
1193
|
+
</p>
|
1194
|
+
<h3>super class:</h3>
|
1195
|
+
<p>
|
1196
|
+
<code><a href="#ODBC::Object">ODBC::Object</a></code>
|
1197
|
+
</p>
|
1198
|
+
<h3>methods:</h3>
|
1199
|
+
<dl>
|
1200
|
+
<dt><code>name[=<var>name</var>]</code></a>
|
1201
|
+
<dd>Queries or sets the <var>name</var> (String) of the data source.
|
1202
|
+
<dt><code>descr[=<var>descr</var>]</code></a>
|
1203
|
+
<dd>Queries or sets the <var>descr</var> (description, String)
|
1204
|
+
of the data source.
|
1205
|
+
</dl>
|
1206
|
+
<h3>singleton methods:</h3>
|
1207
|
+
<dl>
|
1208
|
+
<dt><a name="ODBC::DSN.new"><code>new</code></a>
|
1209
|
+
<dd>Returns an empty <a href="#ODBC::DSN">ODBC::DSN</a> object.
|
1210
|
+
</dl>
|
1211
|
+
</div>
|
1212
|
+
<hr>
|
1213
|
+
<div>
|
1214
|
+
<h2><a name="ODBC::Driver">ODBC::Driver</a></h2>
|
1215
|
+
<p>
|
1216
|
+
The class to represent an ODBC driver with name and attributes.
|
1217
|
+
Objects of this class are
|
1218
|
+
created as result of a
|
1219
|
+
<a href="#ODBC::drivers"><code>ODBC::drivers</code></a>
|
1220
|
+
module function call.
|
1221
|
+
</p>
|
1222
|
+
<h3>super class:</h3>
|
1223
|
+
<p>
|
1224
|
+
<code><a href="#ODBC::Object">ODBC::Object</a></code>
|
1225
|
+
</p>
|
1226
|
+
<h3>methods:</h3>
|
1227
|
+
<dl>
|
1228
|
+
<dt><code>name[=<var>name</var>]</code></a>
|
1229
|
+
<dd>Queries or sets the <var>name</var> (String) of the ODBC driver.
|
1230
|
+
<dt><code>attrs[[<var>key</var>][=<var>value</var>]]</code></a>
|
1231
|
+
<dd>Queries or sets attributes in the <var>attrs</var> Hash of the
|
1232
|
+
ODBC driver object. The <var>key</var>s and <var>value</var>s
|
1233
|
+
should be Strings.
|
1234
|
+
</dl>
|
1235
|
+
<h3>singleton methods:</h3>
|
1236
|
+
<dl>
|
1237
|
+
<dt><a name="ODBC::Driver.new"><code>new</code></a>
|
1238
|
+
<dd>Returns an empty <a href="#ODBC::Driver">ODBC::Driver</a> object.
|
1239
|
+
</dl>
|
1240
|
+
</div>
|
1241
|
+
<div>
|
1242
|
+
<hr>
|
1243
|
+
<h2><a name="ODBCProc">ODBCProc</a></h2>
|
1244
|
+
<p>
|
1245
|
+
The class to represent a procedure with ODBC database/statement
|
1246
|
+
context.
|
1247
|
+
Objects of this class are created as result of a
|
1248
|
+
<a href="#proc"><code>ODBC::Database.proc</code></a> method call.
|
1249
|
+
</p>
|
1250
|
+
<h3>super class:</h3>
|
1251
|
+
<p>
|
1252
|
+
<code>Proc</a></code>
|
1253
|
+
</p>
|
1254
|
+
<h3>methods:</h3>
|
1255
|
+
<dl>
|
1256
|
+
<dt><a name="call"><code>call([<var>args*</var>])</code></a>
|
1257
|
+
<dd>Executes the SQL statement with parameters set from <var>args</var>
|
1258
|
+
and then invokes the procedure's block, setting the block's
|
1259
|
+
single parameter to the
|
1260
|
+
<a href="#ODBC::Statement">ODBC::Statement</a>.
|
1261
|
+
<dt><code>[[<var>args*</var>]]</code>
|
1262
|
+
<dd>Synonym for <code>call</code>.
|
1263
|
+
</dl>
|
1264
|
+
</div>
|
1265
|
+
<div>
|
1266
|
+
<hr>
|
1267
|
+
<h2><a name="ODBC::Error">ODBC::Error</a></h2>
|
1268
|
+
<p>
|
1269
|
+
The class to represent ODBC related exceptions. The descriptive
|
1270
|
+
string is made up of the first ODBC driver or driver manager
|
1271
|
+
message as concatenation of SQL state, native error, driver manager
|
1272
|
+
name, database name/vendor, DSN, and error text, e.g. <pre>
|
1273
|
+
S1000 (1146) [unixODBC][TCX][MySQL]Table 'test.foo' doesn't exist</pre>
|
1274
|
+
For internally generated errors, e.g. method invocation on
|
1275
|
+
a broken connection, the descriptive string starts with
|
1276
|
+
'INTERN' and native error 0, e.g. <pre>
|
1277
|
+
INTERN (0) [RubyODBC]No connection</pre>
|
1278
|
+
For errors programmatically generated by the
|
1279
|
+
<a href="#ODBC::Object.raise"><code>raise</code></a> method,
|
1280
|
+
the descriptive string starts with 'INTERN' and native error 1,
|
1281
|
+
e.g. <pre>
|
1282
|
+
INTERN (1) [RubyODBC]Programmer forgot to RTFM</pre>
|
1283
|
+
</p>
|
1284
|
+
<h3>super class:</h3>
|
1285
|
+
<p>
|
1286
|
+
<code>StandardError</a></code>
|
1287
|
+
</p>
|
1288
|
+
</div>
|
1289
|
+
<div>
|
1290
|
+
<hr>
|
1291
|
+
<h2>Undocumented</h2>
|
1292
|
+
<h3>Use The Source, Luke!</h3>
|
1293
|
+
<p>
|
1294
|
+
<code>ODBC::add_dsn(<var>driver</var>,<var>issys=false</var>)</code><br>
|
1295
|
+
<code>ODBC::add_dsn(<var>name</var>,<var>attrs</var>,<var>issys=false</var>)</code><br>
|
1296
|
+
<code>ODBC::config_dsn(<var>driver</var>,<var>issys=false</var>)</code><br>
|
1297
|
+
<code>ODBC::config_dsn(<var>name</var>,<var>attrs</var>,<var>issys=false</var>)</code><br>
|
1298
|
+
<code>ODBC::del_dsn(<var>driver</var>,<var>issys=false</var>)</code><br>
|
1299
|
+
<code>ODBC::del_dsn(<var>name</var>,<var>attrs</var>,<var>issys=false</var>)</code><br>
|
1300
|
+
<code>ODBC::write_file_dsn(<var>filename</var>,<var>appname</var>,<var>key</var>[,<var>value</var>])</code><br>
|
1301
|
+
<code>ODBC::read_file_dsn(<var>filename</var>,<var>appname</var>,<var>key</var>)</code><br>
|
1302
|
+
<code>ODBC::trace([<var>mask</var>])</code><br>
|
1303
|
+
<br>
|
1304
|
+
<code>ODBC::Statement.fetch!</code><br>
|
1305
|
+
<code>ODBC::Statement.fetch_first!</code><br>
|
1306
|
+
<code>ODBC::Statement.fetch_first_hash(<var>with_table_names=false</var>,<var>use_sym=false</var>)</code><br>
|
1307
|
+
<code>ODBC::Statement.fetch_scroll!(<var>direction</var>,<var>offset=1</var>)</code><br>
|
1308
|
+
<code>ODBC::Statement.fetch_hash!(<var>with_table_names=false</var>,<var>use_sym=false</var>)</code><br>
|
1309
|
+
</p>
|
1310
|
+
<hr>
|
1311
|
+
<address>
|
1312
|
+
mailto:<a href="mailto:chw@ch-werner.de">Christian Werner</a>
|
1313
|
+
</address>
|
1314
|
+
</body>
|
1315
|
+
</html>
|