fireruby 0.2.2-i586-linux
Sign up to get free protection for your applications and to get access to all the features.
- data/doc/README +289 -0
- data/doc/license.txt +411 -0
- data/examples/example01.rb +60 -0
- data/lib/fireruby.bundle +0 -0
- data/lib/fireruby.so +0 -0
- data/lib/mkdoc +1 -0
- data/lib/src.rb +879 -0
- data/test/ConnectionTest.rb +92 -0
- data/test/DDLTest.rb +50 -0
- data/test/DatabaseTest.rb +81 -0
- data/test/GeneratorTest.rb +48 -0
- data/test/ResultSetTest.rb +97 -0
- data/test/RowTest.rb +49 -0
- data/test/SQLTest.rb +171 -0
- data/test/StatementTest.rb +124 -0
- data/test/TestSetup.rb +10 -0
- data/test/TransactionTest.rb +108 -0
- data/test/UnitTest.rb +11 -0
- metadata +58 -0
data/lib/src.rb
ADDED
@@ -0,0 +1,879 @@
|
|
1
|
+
#
|
2
|
+
# This file is a stand-in that allows for the generation of rdoc documentation
|
3
|
+
# for the FireRuby extension for the Ruby programming language. The extension
|
4
|
+
# is coded in C and documented with Doxygen comments, so this file is used to
|
5
|
+
# generate the native Ruby documentation instead.
|
6
|
+
#
|
7
|
+
|
8
|
+
#
|
9
|
+
# This module contains all of the classes and definitions relating to the
|
10
|
+
# FireRuby extension for the Ruby language.
|
11
|
+
#
|
12
|
+
module FireRuby
|
13
|
+
#
|
14
|
+
# This class provides the exception type used by the FireRuby library.
|
15
|
+
#
|
16
|
+
class FireRubyException
|
17
|
+
#
|
18
|
+
# This is the constructor for the FireRubyError class.
|
19
|
+
#
|
20
|
+
# ==== Parameters
|
21
|
+
# message:: A string containing the error message for the object.
|
22
|
+
#
|
23
|
+
def initialize(message)
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
#
|
28
|
+
# This is the accessor for the error message attribute
|
29
|
+
#
|
30
|
+
def message
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
#
|
35
|
+
# This is the accessor for the SQL code attribute.
|
36
|
+
#
|
37
|
+
def sql_code
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
#
|
42
|
+
# This is the accessor for the database code attribute.
|
43
|
+
#
|
44
|
+
def db_code
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
#
|
49
|
+
# This function generates a simple description string for a FireRubyError
|
50
|
+
# object.
|
51
|
+
#
|
52
|
+
def to_s
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
#
|
58
|
+
# This class represents an existing database that can be connected to.
|
59
|
+
#
|
60
|
+
class Database
|
61
|
+
#
|
62
|
+
# This is the constructor for the Database class.
|
63
|
+
#
|
64
|
+
# ==== Parameters
|
65
|
+
# file:: A string containing the database file specifier. This can
|
66
|
+
# include details for a remote server if needed.
|
67
|
+
#
|
68
|
+
def initialize(file)
|
69
|
+
end
|
70
|
+
|
71
|
+
|
72
|
+
#
|
73
|
+
# This is the accessor for the database file specification attribute.
|
74
|
+
#
|
75
|
+
def file
|
76
|
+
end
|
77
|
+
|
78
|
+
|
79
|
+
#
|
80
|
+
# This method attempts to establish a connection to a database. If
|
81
|
+
# successful then a Connection instance is returned. If a block is
|
82
|
+
# provided to the method then the connection is closed after the
|
83
|
+
# block completes. If a block is specified the connection is provided
|
84
|
+
# as a parameter to the block.
|
85
|
+
#
|
86
|
+
# ==== Parameters
|
87
|
+
# user:: The user name to be used in making the connection.
|
88
|
+
# password:: The password to be used in making the connection.
|
89
|
+
#
|
90
|
+
# ==== Exceptions
|
91
|
+
# Exception:: Thrown whenever a problem occurs connecting with the
|
92
|
+
# database.
|
93
|
+
#
|
94
|
+
def connect(user, password)
|
95
|
+
yield(connection)
|
96
|
+
end
|
97
|
+
|
98
|
+
|
99
|
+
#
|
100
|
+
# This method attempts to drop the database referred to by the details
|
101
|
+
# in a Database object.
|
102
|
+
#
|
103
|
+
# ==== Parameters
|
104
|
+
# user:: The user name to be used in dropping the database.
|
105
|
+
# password:: The password to be used in dropping the database.
|
106
|
+
#
|
107
|
+
# ==== Exceptions
|
108
|
+
# FireRubyError:: Thrown whenever a problem occurs dropping the database
|
109
|
+
# instance.
|
110
|
+
#
|
111
|
+
def drop(user, password)
|
112
|
+
end
|
113
|
+
|
114
|
+
|
115
|
+
#
|
116
|
+
# This method can be used to programmatically created a database file.
|
117
|
+
# If successful this method returns a Database object.
|
118
|
+
#
|
119
|
+
# ==== Parameters
|
120
|
+
# file:: A string containing the path and name of the database file
|
121
|
+
# to be created.
|
122
|
+
# user:: A string containing the user name that will be used in
|
123
|
+
# creating the file.
|
124
|
+
# password:: A string containing the user password that will be used in
|
125
|
+
# creating the file.
|
126
|
+
# size:: The page size setting to be used with the new database file.
|
127
|
+
# This should be 1024, 2048, 4096 or 8192.
|
128
|
+
# set:: The name of the default character set to be assigned to the
|
129
|
+
# new database file.
|
130
|
+
#
|
131
|
+
# ==== Exceptions
|
132
|
+
# Exception:: Generated whenever an invalid parameter is specified or a
|
133
|
+
# problem occurs creating the database file.
|
134
|
+
#
|
135
|
+
def Database.create(file, user, password, size, set)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
|
140
|
+
#
|
141
|
+
# This class represents a connection with a Firebird database.
|
142
|
+
#
|
143
|
+
class Connection
|
144
|
+
#
|
145
|
+
# This is the constructor for the Connection class.
|
146
|
+
#
|
147
|
+
# ==== Parameters
|
148
|
+
# database:: A reference to the Database object to be connected to.
|
149
|
+
# user:: A reference to the user name to be used in making the
|
150
|
+
# database connection.
|
151
|
+
# password:: A reference to the user password to be used in making the
|
152
|
+
# connection.
|
153
|
+
#
|
154
|
+
# ==== Exceptions
|
155
|
+
# Exception:: Generated whenever an invalid database is specified to
|
156
|
+
# the method or an issue occurs establishing the database
|
157
|
+
# connection.
|
158
|
+
#
|
159
|
+
def initialize(database, user, password)
|
160
|
+
end
|
161
|
+
|
162
|
+
|
163
|
+
#
|
164
|
+
# This method is used to determine whether a Connection object represents
|
165
|
+
# an active database connection.
|
166
|
+
#
|
167
|
+
def open?
|
168
|
+
end
|
169
|
+
|
170
|
+
|
171
|
+
#
|
172
|
+
# This method is used to determine whether a Connection object represents
|
173
|
+
# an inactive database connection.
|
174
|
+
#
|
175
|
+
def closed?
|
176
|
+
end
|
177
|
+
|
178
|
+
|
179
|
+
#
|
180
|
+
# This method detaches a Connection object from a database. The object
|
181
|
+
# may not be used for database functionality following a successful call
|
182
|
+
# to this method. The close method will fail if there are outstanding
|
183
|
+
# transactions for a connection.
|
184
|
+
#
|
185
|
+
# ==== Exceptions
|
186
|
+
# Exception:: Generated whenever the connection has at least one open
|
187
|
+
# transaction or an error occurs closing the connection.
|
188
|
+
#
|
189
|
+
def close
|
190
|
+
end
|
191
|
+
|
192
|
+
|
193
|
+
#
|
194
|
+
# This is the accessor method for the database attribute.
|
195
|
+
#
|
196
|
+
def database
|
197
|
+
end
|
198
|
+
|
199
|
+
|
200
|
+
#
|
201
|
+
# This method retrieves the user name that was used in creating a
|
202
|
+
# Connection object.
|
203
|
+
#
|
204
|
+
def user
|
205
|
+
end
|
206
|
+
|
207
|
+
|
208
|
+
#
|
209
|
+
# This method generates a simple descriptive string for a Connection
|
210
|
+
# object.
|
211
|
+
#
|
212
|
+
def to_s
|
213
|
+
end
|
214
|
+
|
215
|
+
|
216
|
+
#
|
217
|
+
# This method starts a new transaction against a connection. A successful
|
218
|
+
# call to this method returns a Transaction object. The transaction that
|
219
|
+
# is started relates to the Connection it was called upon only. To start
|
220
|
+
# a transaction that covers multiple connections use the Transaction
|
221
|
+
# class. This method accepts a block, taking a single parameter which
|
222
|
+
# will be the transaction created. This transaction is committed if the
|
223
|
+
# block completes normally or rolls back if an exception is thrown from
|
224
|
+
# the block.
|
225
|
+
#
|
226
|
+
# ==== Exceptions
|
227
|
+
# Exception:: Thrown whenever a problem occurs starting the transaction.
|
228
|
+
#
|
229
|
+
def start_transaction
|
230
|
+
yield transaction
|
231
|
+
end
|
232
|
+
|
233
|
+
|
234
|
+
#
|
235
|
+
# This function executes a SQL statement against a connection. If the
|
236
|
+
# statement represented a SQL query then a result set is returned. If
|
237
|
+
# the statement wasn't a query then nil is returned. The method also
|
238
|
+
# accepts a block that takes a single parameter. This block will be
|
239
|
+
# executed once for each row in any result set generated.
|
240
|
+
#
|
241
|
+
# ==== Parameters
|
242
|
+
# sql:: The SQL statement to be executed.
|
243
|
+
# transaction:: The transaction to execute the SQL statement within.
|
244
|
+
#
|
245
|
+
# ==== Exceptions
|
246
|
+
# Exception:: Generated if an error occurs executing the SQL statement.
|
247
|
+
#
|
248
|
+
def execute(sql, transaction)
|
249
|
+
yield(row)
|
250
|
+
end
|
251
|
+
|
252
|
+
|
253
|
+
#
|
254
|
+
# This function executes a SQL statement against a connection. This
|
255
|
+
# differs from the execute method in that an anonymous transaction is
|
256
|
+
# used in executing the statement. The output from this method is the
|
257
|
+
# same as for the execute method. The method also accepts a block that
|
258
|
+
# takes a single parameter. This block will be executed once for each
|
259
|
+
# row in any result set generated.
|
260
|
+
#
|
261
|
+
# ==== Parameters
|
262
|
+
# sql:: The SQL statement to be executed.
|
263
|
+
#
|
264
|
+
# ==== Exceptions
|
265
|
+
# Exception:: Generated whenever a problem occurs executing the SQL
|
266
|
+
# statement.
|
267
|
+
#
|
268
|
+
def execute_immediate(sql)
|
269
|
+
yield(row)
|
270
|
+
end
|
271
|
+
end
|
272
|
+
|
273
|
+
|
274
|
+
#
|
275
|
+
# This class represents a Firebird database transaction. There may be
|
276
|
+
# multiple transaction outstanding against a connection at any one time.
|
277
|
+
#
|
278
|
+
class Transaction
|
279
|
+
TPB_VERSION_1 = 1
|
280
|
+
TPB_VERSION_3 = 3
|
281
|
+
TPB_CONSISTENCY = 1
|
282
|
+
TPB_CONCURRENCY = 2
|
283
|
+
TPB_SHARED = 3
|
284
|
+
TPB_PROTECTED = 4
|
285
|
+
TPB_EXCLUSIVE = 5
|
286
|
+
TPB_WAIT = 6
|
287
|
+
TPB_NO_WAIT = 7
|
288
|
+
TPB_READ = 8
|
289
|
+
TPB_WRITE = 9
|
290
|
+
TPB_LOCK_READ = 10
|
291
|
+
TPB_LOCK_WRITE = 11
|
292
|
+
TPB_VERB_TIME = 12
|
293
|
+
TPB_COMMIT_TIME = 13
|
294
|
+
TPB_IGNORE_LIMBO = 14
|
295
|
+
TPB_READ_COMMITTED = 15
|
296
|
+
TPB_AUTO_COMMIT = 16
|
297
|
+
TPB_REC_VERSION = 17
|
298
|
+
TPB_NO_REC_VERSION = 18
|
299
|
+
TPB_RESTART_REQUESTS = 19
|
300
|
+
# Transaction parameter buffer value constants.
|
301
|
+
TPB_NO_AUTO_UNDO = 20
|
302
|
+
|
303
|
+
|
304
|
+
#
|
305
|
+
# This is the constructor for the Transaction class.
|
306
|
+
#
|
307
|
+
# ==== Parameters
|
308
|
+
# connections:: Either a single instance of the Connection class or
|
309
|
+
# an array of Connection instances to specify a
|
310
|
+
# multi-database transaction.
|
311
|
+
#
|
312
|
+
# ==== Exceptions
|
313
|
+
# Exception:: Generated whenever the method is passed an invalid
|
314
|
+
# parameter or a problem occurs creating the transaction.
|
315
|
+
#
|
316
|
+
def initialize(connections)
|
317
|
+
end
|
318
|
+
|
319
|
+
|
320
|
+
#
|
321
|
+
# This method is used to determine whether a Transaction object is still
|
322
|
+
# valid for use (i.e. commit or rollback has not been called for the
|
323
|
+
# Transaction).
|
324
|
+
#
|
325
|
+
def active?
|
326
|
+
end
|
327
|
+
|
328
|
+
|
329
|
+
#
|
330
|
+
# This is the accessor for the connections attribute. This method returns
|
331
|
+
# an array of the connections that the transaction applies to.
|
332
|
+
#
|
333
|
+
def connections
|
334
|
+
end
|
335
|
+
|
336
|
+
|
337
|
+
#
|
338
|
+
# This method is used to determine whether a given Transaction applies to
|
339
|
+
# a specified Connection.
|
340
|
+
#
|
341
|
+
# ==== Parameters
|
342
|
+
# connection:: A reference to the Connection object to perform the test
|
343
|
+
# for.
|
344
|
+
#
|
345
|
+
def for_connection?(connection)
|
346
|
+
end
|
347
|
+
|
348
|
+
|
349
|
+
#
|
350
|
+
# This method commits the details outstanding against a Transaction
|
351
|
+
# object. The Transaction object may not be reused after a successful
|
352
|
+
# call to this method.
|
353
|
+
#
|
354
|
+
# ==== Exceptions
|
355
|
+
# Exception:: Generated whenever a problem occurs committing the details
|
356
|
+
# of the transaction.
|
357
|
+
#
|
358
|
+
def commit
|
359
|
+
end
|
360
|
+
|
361
|
+
|
362
|
+
#
|
363
|
+
# This method rolls back the details outstanding against a Transaction
|
364
|
+
# object. The Transaction object may not be reused after a successful
|
365
|
+
# call to this method.
|
366
|
+
#
|
367
|
+
# ==== Exceptions
|
368
|
+
# Exception:: Generated whenever a problem occurs rolling back the
|
369
|
+
# details of the transaction.
|
370
|
+
#
|
371
|
+
def rollback
|
372
|
+
end
|
373
|
+
|
374
|
+
|
375
|
+
#
|
376
|
+
# This method executes a SQL statement using a Transaction object. This
|
377
|
+
# method will only work whenever a Transaction object applies to a
|
378
|
+
# single Connection as it would otherwise be impossible to determine
|
379
|
+
# which connection to execute against. If the statement executed was a
|
380
|
+
# SQL query then the method returns a ResultSet object, otherwise it
|
381
|
+
# returns nil. The method also accepts a block that takes a single
|
382
|
+
# parameter. If the SQL statement was a query the block will be invoked
|
383
|
+
# and passed each row retrieved.
|
384
|
+
#
|
385
|
+
# ==== Parameters
|
386
|
+
# sql:: A string containing the SQL statement to be executed.
|
387
|
+
#
|
388
|
+
# ==== Exceptions
|
389
|
+
# Exception:: Generated whenever the Transaction object represents more
|
390
|
+
# than one connection or a problem occurs executing the SQL
|
391
|
+
# statement.
|
392
|
+
#
|
393
|
+
def execute(sql)
|
394
|
+
yield(row)
|
395
|
+
end
|
396
|
+
|
397
|
+
|
398
|
+
#
|
399
|
+
# This method allows for the creation of a Transaction object with
|
400
|
+
# non-standard settings.
|
401
|
+
#
|
402
|
+
# ==== Parameters
|
403
|
+
# connections:: Either a single Connection object or an array of
|
404
|
+
# Connection objects that the new Transaction will
|
405
|
+
# be associated with.
|
406
|
+
# parameters:: An array of the parameters to be used in creating
|
407
|
+
# the new constants. Populate this from the TPB
|
408
|
+
# constants defined within the class.
|
409
|
+
#
|
410
|
+
# ==== Exceptions
|
411
|
+
# FireRubyError:: Generated whenever a problem occurs creating the
|
412
|
+
# transaction.
|
413
|
+
#
|
414
|
+
def Transaction.create(connections, parameters)
|
415
|
+
end
|
416
|
+
end
|
417
|
+
|
418
|
+
|
419
|
+
#
|
420
|
+
# This class represents a prepared SQL statement that may be executed more
|
421
|
+
# than once.
|
422
|
+
#
|
423
|
+
class Statement
|
424
|
+
#
|
425
|
+
# This is the constructor for the Statement class.
|
426
|
+
#
|
427
|
+
# ==== Parameters
|
428
|
+
# connection:: The Connection object that the SQL statement will be
|
429
|
+
# executed through.
|
430
|
+
# transaction:: The Transaction object that the SQL statement will be
|
431
|
+
# executed under.
|
432
|
+
# sql:: The SQL statement to be prepared for execution.
|
433
|
+
# dialect:: The Firebird dialect to be used in preparing the SQL
|
434
|
+
# statement.
|
435
|
+
#
|
436
|
+
def initialize(connection, transaction, sql, dialect)
|
437
|
+
end
|
438
|
+
|
439
|
+
|
440
|
+
#
|
441
|
+
# This is the accessor for the connection attribute.
|
442
|
+
#
|
443
|
+
def connection
|
444
|
+
end
|
445
|
+
|
446
|
+
|
447
|
+
#
|
448
|
+
# This is the accessor for the transaction attribute.
|
449
|
+
#
|
450
|
+
def transaction
|
451
|
+
end
|
452
|
+
|
453
|
+
|
454
|
+
#
|
455
|
+
# This is the accessor for the SQL statement attribute.
|
456
|
+
#
|
457
|
+
def sql
|
458
|
+
end
|
459
|
+
|
460
|
+
|
461
|
+
#
|
462
|
+
# This is the accessor for the dialect attribute.
|
463
|
+
#
|
464
|
+
def dialect
|
465
|
+
end
|
466
|
+
|
467
|
+
|
468
|
+
#
|
469
|
+
# This method is used to determine whether a Statement object represents
|
470
|
+
# a SQL query.
|
471
|
+
#
|
472
|
+
def is_query?
|
473
|
+
end
|
474
|
+
|
475
|
+
|
476
|
+
#
|
477
|
+
# This method fetches a count of the number of dynamic parameters for
|
478
|
+
# a statement object (i.e. the number of parameters that must be provided
|
479
|
+
# with values before the SQL statement can be executed).
|
480
|
+
#
|
481
|
+
def parameter_count
|
482
|
+
end
|
483
|
+
|
484
|
+
|
485
|
+
#
|
486
|
+
# This method executes the SQL statement within a Statement object. This
|
487
|
+
# method returns a ResultSet object if the statement executed was a SQL
|
488
|
+
# query, otherwise it returns nil. This method accepts a block taking a
|
489
|
+
# single parameter. If this block is provided and the statement is a
|
490
|
+
# query then the rows returned by the query will be passed, one at a
|
491
|
+
# time, to the block.
|
492
|
+
#
|
493
|
+
# ==== Exception
|
494
|
+
# Exception:: Generated if the Statement object actual requires some
|
495
|
+
# parameters or a problem occurs executing the SQL statement.
|
496
|
+
#
|
497
|
+
def execute
|
498
|
+
yield row
|
499
|
+
end
|
500
|
+
|
501
|
+
|
502
|
+
#
|
503
|
+
# This method executes the SQL statement within a Statement object and
|
504
|
+
# passes it a set of parameters. Parameterized statements use question
|
505
|
+
# marks as place holders for values that may change between calls to
|
506
|
+
# execute the statement. This method returns a ResultSet object if the
|
507
|
+
# statement executed was a SQL query, otherwise it returns nil. This
|
508
|
+
# method accepts a block taking a single parameter. If this block is
|
509
|
+
# provided and the statement is a query then the rows returned by the
|
510
|
+
# query will be passed, one at a time, to the block.
|
511
|
+
#
|
512
|
+
# ==== Parameters
|
513
|
+
# parameters:: An array of the parameters for the statement. An effort
|
514
|
+
# will be made to convert the values passed in to the
|
515
|
+
# appropriate types but no guarantees are made (especially
|
516
|
+
# in the case of text fields, which will simply use to_s
|
517
|
+
# if the object passed is not a String).
|
518
|
+
#
|
519
|
+
# ==== Exception
|
520
|
+
# Exception:: Generated whenever a problem occurs translating one of the
|
521
|
+
# input parameters or executing the SQL statement.
|
522
|
+
#
|
523
|
+
def execute_for(parameters)
|
524
|
+
yield row
|
525
|
+
end
|
526
|
+
|
527
|
+
|
528
|
+
#
|
529
|
+
# This method releases the database resources associated with a Statement
|
530
|
+
# object and should be explicitly called when a Statement object is of
|
531
|
+
# no further use.
|
532
|
+
#
|
533
|
+
# ==== Exceptions
|
534
|
+
# FireRubyError:: Generated whenever a problem occurs closing the
|
535
|
+
# statement object.
|
536
|
+
#
|
537
|
+
def close
|
538
|
+
end
|
539
|
+
end
|
540
|
+
|
541
|
+
|
542
|
+
#
|
543
|
+
# This class represents the results of a SQL query executed against a
|
544
|
+
# database.
|
545
|
+
#
|
546
|
+
class ResultSet
|
547
|
+
#
|
548
|
+
# This is the constructor for the ResultSet object.
|
549
|
+
#
|
550
|
+
# ==== Parameters
|
551
|
+
# statement:: A reference to the Statement object that the ResultSet
|
552
|
+
# will be based on.
|
553
|
+
#
|
554
|
+
def initialize(statement)
|
555
|
+
end
|
556
|
+
|
557
|
+
|
558
|
+
#
|
559
|
+
# This is the accessor for the statement attribute.
|
560
|
+
#
|
561
|
+
def statement
|
562
|
+
end
|
563
|
+
|
564
|
+
|
565
|
+
#
|
566
|
+
# This method fetches a count of the number of columns in a row of data
|
567
|
+
# that the ResultSet can fetch.
|
568
|
+
#
|
569
|
+
def column_count
|
570
|
+
end
|
571
|
+
|
572
|
+
|
573
|
+
#
|
574
|
+
# This method fetches the name associated with a specified column for a
|
575
|
+
# ResultSet object.
|
576
|
+
#
|
577
|
+
# ==== Parameters
|
578
|
+
# column:: A reference to the column number to fetch the details for.
|
579
|
+
# Column numbers start at zero.
|
580
|
+
#
|
581
|
+
def column_name(column)
|
582
|
+
end
|
583
|
+
|
584
|
+
|
585
|
+
#
|
586
|
+
# This method fetches the alias associated with a specified column for a
|
587
|
+
# ResultSet object.
|
588
|
+
#
|
589
|
+
# ==== Parameters
|
590
|
+
# column:: A reference to the column number to fetch the details for.
|
591
|
+
# Column numbers start at zero.
|
592
|
+
#
|
593
|
+
def column_alias(column)
|
594
|
+
end
|
595
|
+
|
596
|
+
|
597
|
+
#
|
598
|
+
# This method fetches the table name associated with a specified column
|
599
|
+
# for a ResultSet object.
|
600
|
+
#
|
601
|
+
# ==== Parameters
|
602
|
+
# column:: A reference to the column number to fetch the details for.
|
603
|
+
# Column numbers start at zero.
|
604
|
+
#
|
605
|
+
def column_table(column)
|
606
|
+
end
|
607
|
+
|
608
|
+
|
609
|
+
#
|
610
|
+
# This method fetches a single rows worth of data from the ResultSet
|
611
|
+
# object. If the set contains more rows then an array containing the
|
612
|
+
# row data will be retrieved. If the ResultSet is exhausted (i.e. all
|
613
|
+
# rows have been fetched) then nil is returned. Translation of the row
|
614
|
+
# data into an appropriate Ruby type is performed on the row data that
|
615
|
+
# is extracted.
|
616
|
+
#
|
617
|
+
def fetch
|
618
|
+
end
|
619
|
+
|
620
|
+
|
621
|
+
#
|
622
|
+
# This method is used to determine if all of the rows have been retrieved
|
623
|
+
# from a ResultSet object. This method will always return false until
|
624
|
+
# the fetch method has been called at least once so it cannot be used to
|
625
|
+
# detect a result set that returns no rows.
|
626
|
+
#
|
627
|
+
def exhausted?
|
628
|
+
end
|
629
|
+
|
630
|
+
|
631
|
+
#
|
632
|
+
# This method fetches a count of the total number of rows retrieved
|
633
|
+
# from a result set.
|
634
|
+
#
|
635
|
+
def row_count
|
636
|
+
end
|
637
|
+
|
638
|
+
|
639
|
+
#
|
640
|
+
# This method provides an iterator for the (remaining) rows contained in
|
641
|
+
# a ResultSet object.
|
642
|
+
#
|
643
|
+
# ==== Parameters
|
644
|
+
# block:: A block that takes a single parameter. This will be called for
|
645
|
+
# and passed each remaining row (as per the fetch method) from
|
646
|
+
# the ResultSet.
|
647
|
+
#
|
648
|
+
def each(&block)
|
649
|
+
end
|
650
|
+
|
651
|
+
|
652
|
+
#
|
653
|
+
# This method releases the database resources associated with a ResultSet
|
654
|
+
# object and should be explicitly called when a ResultSet object is of
|
655
|
+
# no further use. The method is implicitly called if the rows available
|
656
|
+
# from a ResultSet are exhausted but calling this method at that time
|
657
|
+
# will not cause an error.
|
658
|
+
#
|
659
|
+
# ==== Exceptions
|
660
|
+
# FireRubyError:: Generated whenever a problem occurs closing the result
|
661
|
+
# set object.
|
662
|
+
#
|
663
|
+
def close
|
664
|
+
end
|
665
|
+
end
|
666
|
+
|
667
|
+
|
668
|
+
#
|
669
|
+
# This class models a row of data fetched as part of a SQL query.
|
670
|
+
#
|
671
|
+
class Row
|
672
|
+
#
|
673
|
+
# This is the constructor for the Row class. This method shouldn't really
|
674
|
+
# be used as Row objects are automatically created by ResultSets.
|
675
|
+
#
|
676
|
+
# ==== Parameters
|
677
|
+
# results:: The ResultSet object that the row relates to.
|
678
|
+
# data:: An array containing the row data values.
|
679
|
+
# number:: The row number for the new row.
|
680
|
+
#
|
681
|
+
def initialize(results, data, number)
|
682
|
+
end
|
683
|
+
|
684
|
+
#
|
685
|
+
# This is the accessor for the row number attribute. This will generally
|
686
|
+
# reflect the order the row was fetched from the result set in, with 1
|
687
|
+
# being the first row retrieved.
|
688
|
+
#
|
689
|
+
def number
|
690
|
+
end
|
691
|
+
|
692
|
+
|
693
|
+
#
|
694
|
+
# This method fetches a count of the number of columns of data that are
|
695
|
+
# available from a row.
|
696
|
+
#
|
697
|
+
def column_count
|
698
|
+
end
|
699
|
+
|
700
|
+
|
701
|
+
#
|
702
|
+
# This method fetches the name of a column within a row of data.
|
703
|
+
#
|
704
|
+
# ==== Parameters
|
705
|
+
# index:: The index of the column to fetch the name for. The first
|
706
|
+
# column in the row is at offset zero.
|
707
|
+
#
|
708
|
+
def column_name(index)
|
709
|
+
end
|
710
|
+
|
711
|
+
|
712
|
+
#
|
713
|
+
# This method fetches the alias of a column within a row of data.
|
714
|
+
#
|
715
|
+
# ==== Parameters
|
716
|
+
# index:: The index of the column to fetch the alias for. The first
|
717
|
+
# column in the row is at offset zero.
|
718
|
+
#
|
719
|
+
def column_alias(index)
|
720
|
+
end
|
721
|
+
|
722
|
+
|
723
|
+
#
|
724
|
+
# This method fetches the value associated with a column within a Row
|
725
|
+
# object.
|
726
|
+
#
|
727
|
+
# ==== Parameters
|
728
|
+
# index:: Either the offset of the column to retrieve the value of or
|
729
|
+
# the name of the column to retrieve the value of (column name
|
730
|
+
# comparisons are case sensitive).
|
731
|
+
#
|
732
|
+
def [](index)
|
733
|
+
end
|
734
|
+
end
|
735
|
+
|
736
|
+
#
|
737
|
+
# This class represents Blob data fetched from the database. The class defers
|
738
|
+
# the actual loading of the blob until requested. The class is somewhat basic
|
739
|
+
# and maybe expanded upon in later releases.
|
740
|
+
#
|
741
|
+
class Blob
|
742
|
+
#
|
743
|
+
# This is the constructor for the Blob class. This shouldn't really be
|
744
|
+
# used outside of the FireRuby library.
|
745
|
+
#
|
746
|
+
def initialize
|
747
|
+
end
|
748
|
+
|
749
|
+
|
750
|
+
#
|
751
|
+
# This method loads the entire data set for a blob as a string.
|
752
|
+
#
|
753
|
+
def to_s
|
754
|
+
end
|
755
|
+
|
756
|
+
|
757
|
+
#
|
758
|
+
# This method closes a blob, freeing any resources associated with it.
|
759
|
+
#
|
760
|
+
def close
|
761
|
+
end
|
762
|
+
|
763
|
+
|
764
|
+
#
|
765
|
+
# This method loads the segments of a blob one after another. The blob
|
766
|
+
# segments are passed as strings to the block passed to the method.
|
767
|
+
#
|
768
|
+
def each
|
769
|
+
yield segment
|
770
|
+
end
|
771
|
+
end
|
772
|
+
|
773
|
+
|
774
|
+
#
|
775
|
+
# This class represents a Firebird generator entity.
|
776
|
+
#
|
777
|
+
class Generator
|
778
|
+
#
|
779
|
+
# This is the constructor for the Generator class. Note, this method
|
780
|
+
# assumes that the named generator already exists. If it doesn't then
|
781
|
+
# the object will be constructed but will fail during use.
|
782
|
+
#
|
783
|
+
# ==== Parameters
|
784
|
+
# name:: A string containing the generator name.
|
785
|
+
# connection:: A reference to the Connection object that will be used
|
786
|
+
# to access the generator.
|
787
|
+
#
|
788
|
+
def initialize(name, connection)
|
789
|
+
end
|
790
|
+
|
791
|
+
|
792
|
+
#
|
793
|
+
# This is the accessor for the name attribute.
|
794
|
+
#
|
795
|
+
def name
|
796
|
+
end
|
797
|
+
|
798
|
+
|
799
|
+
#
|
800
|
+
# This is the accessor for the connection attribute.
|
801
|
+
#
|
802
|
+
def connection
|
803
|
+
end
|
804
|
+
|
805
|
+
|
806
|
+
#
|
807
|
+
# This method fetches the last value generator from a generator.
|
808
|
+
#
|
809
|
+
# ==== Exceptions
|
810
|
+
# Exception:: Generated whenever a problem occurs accessing the
|
811
|
+
# database generator.
|
812
|
+
#
|
813
|
+
def last
|
814
|
+
end
|
815
|
+
|
816
|
+
|
817
|
+
#
|
818
|
+
# This method drops a generator from the database. After a successful
|
819
|
+
# call to this method the Generator object may not be used to obtain
|
820
|
+
# values unless it is recreated.
|
821
|
+
#
|
822
|
+
# ==== Exceptions
|
823
|
+
# Exception:: Generated whenever a problem occurs dropping the generator
|
824
|
+
# from the database.
|
825
|
+
#
|
826
|
+
def drop
|
827
|
+
end
|
828
|
+
|
829
|
+
|
830
|
+
#
|
831
|
+
# This method fetches the next value, depending on a specified increment,
|
832
|
+
# from a generator.
|
833
|
+
#
|
834
|
+
# ==== Parameters
|
835
|
+
# step:: The step interval to be applied to the generator to obtain the
|
836
|
+
# next value.
|
837
|
+
#
|
838
|
+
# ==== Exceptions
|
839
|
+
# Exception:: Generated whenever a problem occurs accessing the
|
840
|
+
# database generator.
|
841
|
+
#
|
842
|
+
def next(step)
|
843
|
+
end
|
844
|
+
|
845
|
+
|
846
|
+
#
|
847
|
+
# This method is used to determine whether a named generator exists
|
848
|
+
# within a database.
|
849
|
+
#
|
850
|
+
# ==== Parameters
|
851
|
+
# name:: A string containing the generator name to check for.
|
852
|
+
# connection:: A reference to the Connection object to be used in
|
853
|
+
# performing the check.
|
854
|
+
#
|
855
|
+
# ==== Exceptions
|
856
|
+
# Exception:: Generated whenever a problem occurs determining the
|
857
|
+
# existence of the generator.
|
858
|
+
#
|
859
|
+
def Generator.exists?(name, connection)
|
860
|
+
end
|
861
|
+
|
862
|
+
|
863
|
+
#
|
864
|
+
# This method creates a new generator within a database. This method
|
865
|
+
# returns a Generator object is successful.
|
866
|
+
#
|
867
|
+
# ==== Parameters
|
868
|
+
# name:: A string containing the name for the new generator.
|
869
|
+
# connection:: A reference to the Connection object that will be used to
|
870
|
+
# create the generator.
|
871
|
+
#
|
872
|
+
# ==== Exceptions
|
873
|
+
# Exception:: Generated whenever a problem occurs creating the new
|
874
|
+
# generator in the database.
|
875
|
+
#
|
876
|
+
def Generator.create(name, connection)
|
877
|
+
end
|
878
|
+
end
|
879
|
+
end
|