-
Notifications
You must be signed in to change notification settings - Fork 1
/
ODBC.pck.st
3026 lines (2642 loc) · 93.4 KB
/
ODBC.pck.st
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
'From Cuis7.1 [latest update: #6797] on 30 October 2024 at 9:06:56 pm'!
'Description '!
!provides: 'ODBC' 1 9!
!requires: 'FFI' 1 40 nil!
SystemOrganization addCategory: #'ODBC-Constants'!
SystemOrganization addCategory: #'ODBC-Core'!
SystemOrganization addCategory: #'ODBC-Support'!
!classDefinition: #ODBCConstants category: #'ODBC-Constants'!
SharedPool subclass: #ODBCConstants
instanceVariableNames: ''
classVariableNames: 'BUFFERSIZE SQLATTRAUTOCOMMIT SQLAUTOCOMMITOFF SQLAUTOCOMMITON SQLCBIT SQLCCHAR SQLCDATE SQLCDOUBLE SQLCFLOAT SQLCINTEGER SQLCNUMERIC SQLCOMMIT SQLCSMALLINTEGER SQLCTIME SQLCTIMESTAMP SQLDATE SQLDOUBLE SQLHANDLEDBC SQLINTEGER SQLNODATAFOUND SQLNULLDATA SQLROLLBACK SQLSUCCESS SQLSUCCESSWITHINFO SQLTIME SQLTIMESTAMP SQLUINTEGER SQLVARCHAR'
poolDictionaries: ''
category: 'ODBC-Constants'!
!classDefinition: 'ODBCConstants class' category: #'ODBC-Constants'!
ODBCConstants class
instanceVariableNames: ''!
!classDefinition: #ODBCResultTable category: #'ODBC-Core'!
OrderedCollection subclass: #ODBCResultTable
instanceVariableNames: 'columns preferredColumnWidths extraLinkBlock extraLinkTitle columnPrintBlock'
classVariableNames: ''
poolDictionaries: ''
category: 'ODBC-Core'!
!classDefinition: 'ODBCResultTable class' category: #'ODBC-Core'!
ODBCResultTable class
instanceVariableNames: ''!
!classDefinition: #ODBCRow category: #'ODBC-Core'!
IdentityDictionary subclass: #ODBCRow
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: 'ODBCConstants'
category: 'ODBC-Core'!
!classDefinition: 'ODBCRow class' category: #'ODBC-Core'!
ODBCRow class
instanceVariableNames: ''!
!classDefinition: #ODBCResultSet category: #'ODBC-Core'!
Stream subclass: #ODBCResultSet
instanceVariableNames: 'connection statement handle columns nextRow'
classVariableNames: ''
poolDictionaries: 'ODBCConstants'
category: 'ODBC-Core'!
!classDefinition: 'ODBCResultSet class' category: #'ODBC-Core'!
ODBCResultSet class
instanceVariableNames: ''!
!classDefinition: #ODBCError category: #'ODBC-Core'!
Error subclass: #ODBCError
instanceVariableNames: 'details'
classVariableNames: ''
poolDictionaries: 'ODBCConstants'
category: 'ODBC-Core'!
!classDefinition: 'ODBCError class' category: #'ODBC-Core'!
ODBCError class
instanceVariableNames: ''!
!classDefinition: #ODBCWarning category: #'ODBC-Core'!
Notification subclass: #ODBCWarning
instanceVariableNames: 'details'
classVariableNames: ''
poolDictionaries: 'ODBCConstants'
category: 'ODBC-Core'!
!classDefinition: 'ODBCWarning class' category: #'ODBC-Core'!
ODBCWarning class
instanceVariableNames: ''!
!classDefinition: #ODBCLibrary category: #'ODBC-Support'!
ExternalLibrary subclass: #ODBCLibrary
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'ODBC-Support'!
!classDefinition: 'ODBCLibrary class' category: #'ODBC-Support'!
ODBCLibrary class
instanceVariableNames: 'default'!
!classDefinition: #SQLByte category: #'ODBC-Support'!
ExternalStructure subclass: #SQLByte
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'ODBC-Support'!
!classDefinition: 'SQLByte class' category: #'ODBC-Support'!
SQLByte class
instanceVariableNames: ''!
!classDefinition: #SQLDate category: #'ODBC-Support'!
ExternalStructure subclass: #SQLDate
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'ODBC-Support'!
!classDefinition: 'SQLDate class' category: #'ODBC-Support'!
SQLDate class
instanceVariableNames: ''!
!classDefinition: #SQLDouble category: #'ODBC-Support'!
ExternalStructure subclass: #SQLDouble
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'ODBC-Support'!
!classDefinition: 'SQLDouble class' category: #'ODBC-Support'!
SQLDouble class
instanceVariableNames: ''!
!classDefinition: #SQLFloat category: #'ODBC-Support'!
ExternalStructure subclass: #SQLFloat
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'ODBC-Support'!
!classDefinition: 'SQLFloat class' category: #'ODBC-Support'!
SQLFloat class
instanceVariableNames: ''!
!classDefinition: #SQLHDBC category: #'ODBC-Support'!
ExternalStructure subclass: #SQLHDBC
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'ODBC-Support'!
!classDefinition: 'SQLHDBC class' category: #'ODBC-Support'!
SQLHDBC class
instanceVariableNames: ''!
!classDefinition: #SQLHENV category: #'ODBC-Support'!
ExternalStructure subclass: #SQLHENV
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'ODBC-Support'!
!classDefinition: 'SQLHENV class' category: #'ODBC-Support'!
SQLHENV class
instanceVariableNames: ''!
!classDefinition: #SQLHSTMT category: #'ODBC-Support'!
ExternalStructure subclass: #SQLHSTMT
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'ODBC-Support'!
!classDefinition: 'SQLHSTMT class' category: #'ODBC-Support'!
SQLHSTMT class
instanceVariableNames: ''!
!classDefinition: #SQLInteger category: #'ODBC-Support'!
ExternalStructure subclass: #SQLInteger
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'ODBC-Support'!
!classDefinition: 'SQLInteger class' category: #'ODBC-Support'!
SQLInteger class
instanceVariableNames: ''!
!classDefinition: #SQLShort category: #'ODBC-Support'!
ExternalStructure subclass: #SQLShort
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'ODBC-Support'!
!classDefinition: 'SQLShort class' category: #'ODBC-Support'!
SQLShort class
instanceVariableNames: ''!
!classDefinition: #SQLSmallInteger category: #'ODBC-Support'!
ExternalStructure subclass: #SQLSmallInteger
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'ODBC-Support'!
!classDefinition: 'SQLSmallInteger class' category: #'ODBC-Support'!
SQLSmallInteger class
instanceVariableNames: ''!
!classDefinition: #SQLTime category: #'ODBC-Support'!
ExternalStructure subclass: #SQLTime
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'ODBC-Support'!
!classDefinition: 'SQLTime class' category: #'ODBC-Support'!
SQLTime class
instanceVariableNames: ''!
!classDefinition: #SQLTimestamp category: #'ODBC-Support'!
ExternalStructure subclass: #SQLTimestamp
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'ODBC-Support'!
!classDefinition: 'SQLTimestamp class' category: #'ODBC-Support'!
SQLTimestamp class
instanceVariableNames: ''!
!classDefinition: #SQLUInteger category: #'ODBC-Support'!
ExternalStructure subclass: #SQLUInteger
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'ODBC-Support'!
!classDefinition: 'SQLUInteger class' category: #'ODBC-Support'!
SQLUInteger class
instanceVariableNames: ''!
!classDefinition: #ODBCBoundParameter category: #'ODBC-Core'!
Object subclass: #ODBCBoundParameter
instanceVariableNames: 'data cType sqlType colWidth digits size'
classVariableNames: ''
poolDictionaries: ''
category: 'ODBC-Core'!
!classDefinition: 'ODBCBoundParameter class' category: #'ODBC-Core'!
ODBCBoundParameter class
instanceVariableNames: ''!
!classDefinition: #ODBCColumn category: #'ODBC-Core'!
Object subclass: #ODBCColumn
instanceVariableNames: 'connection resultSet resultSetHandle number name dataType cType convertSelector initializeSelector size decimals nullable buffer bufferLength'
classVariableNames: 'DataTypes'
poolDictionaries: 'ODBCConstants'
category: 'ODBC-Core'!
!classDefinition: 'ODBCColumn class' category: #'ODBC-Core'!
ODBCColumn class
instanceVariableNames: ''!
!classDefinition: #ODBCConnection category: #'ODBC-Core'!
Object subclass: #ODBCConnection
instanceVariableNames: 'hEnv hdbc connected dsn user password version features statements openTransaction asyncStatements'
classVariableNames: 'Registry'
poolDictionaries: 'ODBCConstants'
category: 'ODBC-Core'!
!classDefinition: 'ODBCConnection class' category: #'ODBC-Core'!
ODBCConnection class
instanceVariableNames: ''!
!classDefinition: #ODBCErrorDetail category: #'ODBC-Core'!
Object subclass: #ODBCErrorDetail
instanceVariableNames: 'state message nativeError'
classVariableNames: ''
poolDictionaries: 'ODBCConstants'
category: 'ODBC-Core'!
!classDefinition: 'ODBCErrorDetail class' category: #'ODBC-Core'!
ODBCErrorDetail class
instanceVariableNames: ''!
!classDefinition: #ODBCParamDescription category: #'ODBC-Core'!
Object subclass: #ODBCParamDescription
instanceVariableNames: 'dataType paramSize digits nullable'
classVariableNames: ''
poolDictionaries: ''
category: 'ODBC-Core'!
!classDefinition: 'ODBCParamDescription class' category: #'ODBC-Core'!
ODBCParamDescription class
instanceVariableNames: ''!
!classDefinition: #ODBCStatement category: #'ODBC-Core'!
Object subclass: #ODBCStatement
instanceVariableNames: 'connection handle query resultSets argBuffers'
classVariableNames: ''
poolDictionaries: 'ODBCConstants'
category: 'ODBC-Core'!
!classDefinition: 'ODBCStatement class' category: #'ODBC-Core'!
ODBCStatement class
instanceVariableNames: ''!
!classDefinition: #ODBCPreparedStatement category: #'ODBC-Core'!
ODBCStatement subclass: #ODBCPreparedStatement
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: 'ODBCConstants'
category: 'ODBC-Core'!
!classDefinition: 'ODBCPreparedStatement class' category: #'ODBC-Core'!
ODBCPreparedStatement class
instanceVariableNames: ''!
!ODBCBoundParameter commentStamp: '<historical>' prior: 0!
A bound parameter for an ODBC query.!
!ODBCConstants class methodsFor: 'class initialization' stamp: 'ar 8/10/2008 17:46'!
initialize
"Initialize the pool"
BUFFERSIZE := (1024 * 8).
SQLNULLDATA := -1.
SQLSUCCESS := 0.
SQLSUCCESSWITHINFO := 1.
SQLNODATAFOUND :=100.
SQLCCHAR := 1.
SQLCNUMERIC := 2.
SQLCINTEGER := 4.
SQLCSMALLINTEGER := 5.
SQLCFLOAT := 7.
SQLCDOUBLE := 8.
SQLCDATE := 9.
SQLCTIME := 10.
SQLCTIMESTAMP := 11.
SQLCBIT := -7.
SQLUINTEGER := -5.
SQLATTRAUTOCOMMIT :=102.
SQLAUTOCOMMITON :=1.
SQLAUTOCOMMITOFF :=0.
SQLHANDLEDBC := 2.
SQLCOMMIT := 0.
SQLROLLBACK := 1.
"XXXX: Incomplete XXXX"
SQLINTEGER := 4.
SQLDOUBLE := 8.
SQLDATE := 9.
SQLTIME := 10.
SQLTIMESTAMP := 11.
SQLVARCHAR := 12.
! !
!ODBCResultTable methodsFor: 'adding' stamp: 'rjl 9/4/2008 16:06'!
add: row
self maxWidthOfColumnsForRow: row.
^ super add: row! !
!ODBCResultTable methodsFor: 'converting' stamp: 'rjl 9/4/2008 16:07'!
asMorph
| twoWayScroller report title window |
report := TextMorph new
backgroundColor: Color transparent;
borderWidth: 0;
margins: 6;
beAllFont: (StrikeFont
familyName: #BitstreamVeraSansMono
size: 12);
contents: (Text streamContents: [ :stream | self printTextOn: stream ]).
twoWayScroller := TwoWayScrollPane new
borderWidth: 0;
setScrollDeltas.
twoWayScroller scroller addMorph: report.
title := String streamContents:
[ :stream |
stream
nextPutAll: 'Query Results (';
nextPutAll: self size asString , ' row'.
self size ~= 1 ifTrue: [ stream nextPut: $s ].
stream nextPut: $) ].
window := (SystemWindow labelled: title) paneColor: (Color
r: 1.0
g: 0.903
b: 0.258).
window extent: 700 @ 400.
window position: (Display extent - window extent) // 2.
^ window
addMorph: twoWayScroller
fullFrame: (LayoutFrame fractions: (0 @ 0 extent: 1 @ 1))! !
!ODBCResultTable methodsFor: 'converting' stamp: 'rjl 9/4/2008 16:07'!
openAsMorph
self asMorph openAsIsIn: ActiveWorld! !
!ODBCResultTable methodsFor: 'accessing' stamp: 'rjl 9/4/2008 16:07'!
columnNames
^ self columns collect: [ :each | each name ]! !
!ODBCResultTable methodsFor: 'accessing' stamp: 'rjl 9/4/2008 16:07'!
columnPrintBlock
^ columnPrintBlock ifNil: [ self standardColumnPrintBlock ]! !
!ODBCResultTable methodsFor: 'accessing' stamp: 'rjl 9/4/2008 16:07'!
columnPrintBlock: aThreeArgBlock
columnPrintBlock := aThreeArgBlock! !
!ODBCResultTable methodsFor: 'accessing' stamp: 'rjl 9/4/2008 16:07'!
columns
^ columns! !
!ODBCResultTable methodsFor: 'accessing' stamp: 'rjl 9/4/2008 16:07'!
columns: aList
columns := aList reject:
[ :each |
#(
#DBConnect
#DBName
#DatabaseName
#ImportVersion
#Locked
) includes: each name ]! !
!ODBCResultTable methodsFor: 'accessing' stamp: 'rjl 9/4/2008 16:07'!
extraLinkTitle: aString do: aOneArgumentBlock
extraLinkTitle := aString.
extraLinkBlock := aOneArgumentBlock! !
!ODBCResultTable methodsFor: 'accessing' stamp: 'rjl 9/4/2008 16:07'!
maxWidthOfColumn: anODBCColumn
^ (preferredColumnWidths at: anODBCColumn) + 2! !
!ODBCResultTable methodsFor: 'accessing' stamp: 'rjl 9/4/2008 16:07'!
maxWidthOfColumnsForRow: row
self columns do:
[ :each |
| currentWidth |
currentWidth := preferredColumnWidths
at: each
ifAbsentPut: [ each name size ].
preferredColumnWidths
at: each
put: (currentWidth max: (row at: each name) printString size) ]! !
!ODBCResultTable methodsFor: 'accessing' stamp: 'rjl 9/4/2008 16:07'!
preferredColumnWidths
"Return a list of associations so that column order is preserved"
^ self columns collect: [ :each | each -> (self maxWidthOfColumn: each) ]! !
!ODBCResultTable methodsFor: 'accessing' stamp: 'rjl 9/4/2008 16:09'!
standardColumnPrintBlock
^
[ :row :column :textStream |
| columnValue |
columnValue := row at: column key name.
columnValue isFraction ifTrue: [ columnValue := columnValue asFloat ].
textStream nextPutAll: (self class
formatItem: columnValue asString
toWidth: column value) ]! !
!ODBCResultTable methodsFor: 'initialization' stamp: 'rjl 9/4/2008 16:07'!
initialize
preferredColumnWidths := Dictionary new! !
!ODBCResultTable methodsFor: 'printing' stamp: 'rjl 9/4/2008 16:07'!
printHeaderOn: aStream
self columns do:
[ :each |
| columnHeader |
columnHeader := self class
formatItem: each name
toWidth: (self maxWidthOfColumn: each).
aStream nextPutAll: columnHeader ].
aStream cr.
self columns do:
[ :each |
aStream
nextPutAll: (String
new: (self maxWidthOfColumn: each) - 1
withAll: $-);
nextPut: $ ].
aStream cr! !
!ODBCResultTable methodsFor: 'printing' stamp: 'rjl 9/4/2008 16:07'!
printOn: aStream
self printHeaderOn: aStream.
self do:
[ :each |
each
printOn: aStream
withColumnDefinitions: self preferredColumnWidths.
aStream cr ]! !
!ODBCResultTable methodsFor: 'printing' stamp: 'rjl 9/4/2008 16:09'!
printTextForRow: aRow on: aTextStream
self preferredColumnWidths do:
[ :each |
self columnPrintBlock
value: aRow
value: each
value: aTextStream ].
extraLinkTitle ifNotNil:
[ aTextStream
withAttribute: (PluggableTextAttribute evalBlock: [ extraLinkBlock value: aRow ])
do: [ aTextStream nextPutAll: extraLinkTitle ] ].
aTextStream
space;
cr! !
!ODBCResultTable methodsFor: 'printing' stamp: 'rjl 9/4/2008 16:09'!
printTextOn: aTextStream
self printHeaderOn: aTextStream.
self do:
[ :each |
self
printTextForRow: each
on: aTextStream ]! !
!ODBCResultTable methodsFor: 'private' stamp: 'rjl 9/4/2008 16:09'!
species
^ OrderedCollection! !
!ODBCResultTable class methodsFor: 'formatting' stamp: 'bvs 4/14/2004 14:15'!
formatItem: aString toWidth: aNumber
^ aString
padded: #right
to: aNumber
with: $ ! !
!ODBCResultTable class methodsFor: 'instance creation' stamp: 'jrp 3/10/2004 13:23'!
new
^ super new initialize! !
!ODBCResultTable class methodsFor: 'instance creation' stamp: 'rjl 9/4/2008 16:06'!
newFrom: anODBCResultSet
| table |
table := self new.
table columns: anODBCResultSet columns.
anODBCResultSet do: [ :each | table add: each ].
anODBCResultSet close.
^ table! !
!ODBCRow methodsFor: 'error handling' stamp: 'rjl 9/4/2008 15:25'!
doesNotUnderstand: aMessage
| originalSelector |
originalSelector := aMessage selector.
originalSelector isUnary ifFalse: [ ^ super doesNotUnderstand: aMessage ].
{
originalSelector. "Camel case"
(originalSelector capitalized) "Pascal case"
} do:
[ :each |
self
at: each asSymbol
ifPresent: [ :val | ^ val ] ].
^ super doesNotUnderstand: aMessage! !
!ODBCRow methodsFor: 'printing' stamp: 'rjl 9/4/2008 16:00'!
printOn: aStream withColumnDefinitions: aList
aList do:
[ :each |
aStream nextPutAll: (ODBCResultTable
formatItem: (self at: each key name) asString
toWidth: each value) ]! !
!ODBCResultSet methodsFor: 'converting' stamp: 'rjl 9/4/2008 15:59'!
asTable
^ ODBCResultTable newFrom: self! !
!ODBCResultSet methodsFor: 'testing' stamp: 'dgd 5/27/2002 23:14'!
atEnd
self checkConnected.
^ nextRow isNil! !
!ODBCResultSet methodsFor: 'testing' stamp: 'dgd 6/2/2002 21:56'!
closed
"asnwer if the receiver is closed"
^ self isConnected not! !
!ODBCResultSet methodsFor: 'testing' stamp: 'dgd 5/27/2002 23:49'!
isConnected
"answer if the receiver is connected"
^ handle notNil! !
!ODBCResultSet methodsFor: 'private' stamp: 'dgd 5/27/2002 23:14'!
checkConnected
"private - check if the recevier is connected"
self isConnected
ifFalse: [^ self error: 'unconnected!!']! !
!ODBCResultSet methodsFor: 'private' stamp: 'dgd 5/27/2002 01:17'!
fetchNextRow
"private - fetch the next row"
nextRow := self fetchRow! !
!ODBCResultSet methodsFor: 'connecting' stamp: 'jfr 11/13/2023 16:02:12'!
close
"close the receiver"
self isConnected
ifFalse: [^ self].
columns notNil ifTrue:[
columns
do: [:each | each free]].
""
"SQL:=DROP"
connection
checkSQLReturn: (ODBCLibrary default sqlFreeStmt: handle option: 1)
statement: handle.
handle := nil.
self unregisterForFinalization! !
!ODBCResultSet methodsFor: 'connecting' stamp: 'jfr 11/13/2023 16:02:19'!
closeNotFail
"close the receiver without signaling errors"
self isConnected
ifFalse: [^ self].
columns notNil ifTrue:[
columns
do: [:each | each free]].
""
"SQL:=DROP"
ODBCLibrary default sqlFreeStmt: handle option: 1.
handle := nil.
self unregisterForFinalization! !
!ODBCResultSet methodsFor: 'accessing' stamp: 'dgd 5/31/2002 20:20'!
columns
"answer the receiver's columns.
It's an array of ODBCColumns with metadata information"
^ columns! !
!ODBCResultSet methodsFor: 'accessing' stamp: 'dgd 5/30/2002 23:42'!
connection
"answer the receiver's connection"
^ connection! !
!ODBCResultSet methodsFor: 'accessing' stamp: 'dgd 5/27/2002 00:44'!
contents
^ self shouldNotImplement! !
!ODBCResultSet methodsFor: 'accessing' stamp: 'jfr 11/13/2023 16:02:24'!
fetchRow
"private - fetch the next row"
| row ret |
ret := ODBCLibrary default sqlFetch: handle.
ret == SQLNODATAFOUND ifTrue: [^ nil].
connection checkSQLReturn: ret statement: handle.
""
row := ODBCRow new.
columns do: [:each | row at: each name put: each data].
^ row! !
!ODBCResultSet methodsFor: 'accessing' stamp: 'dgd 5/29/2002 23:32'!
handle
^ handle! !
!ODBCResultSet methodsFor: 'accessing' stamp: 'dgd 5/27/2002 23:13'!
next
"answer the next row, nil if none"
| result |
self checkConnected.
result := nextRow.
result notNil
ifTrue: [self fetchNextRow].
^ result! !
!ODBCResultSet methodsFor: 'accessing' stamp: 'dgd 5/27/2002 00:45'!
nextPut: anObject
^ self shouldNotImplement! !
!ODBCResultSet methodsFor: 'accessing' stamp: 'jfr 11/13/2023 16:02:37'!
rowCount
"answer the receiver's rowCount
use with carefull, some odbc drivers answer -1
"
| rows |
rows := SQLSmallInteger new.
connection
checkSQLReturn: (ODBCLibrary default sqlRowCount: handle rowCount: rows)
statement: handle.
^ rows value! !
!ODBCResultSet methodsFor: 'private - finalization' stamp: 'dgd 5/27/2002 22:57'!
finalize
self closeNotFail! !
!ODBCResultSet methodsFor: 'private - finalization' stamp: 'dgd 5/27/2002 22:58'!
registerForFinalization
"private - register the receiver to the class side registry for finalization
notification"
connection class register: self! !
!ODBCResultSet methodsFor: 'private - finalization' stamp: 'dgd 5/27/2002 22:58'!
unregisterForFinalization
"private - unregister the receiver to the class side registry for
finalization notification"
connection class unregister: self! !
!ODBCResultSet methodsFor: 'initialization' stamp: 'jfr 11/13/2023 16:02:30'!
initializeConnection: aConnection statement: aStatement
"initialize the receiver"
| columnCount |
connection := aConnection.
statement := aStatement.
statement addResulSet: self.
handle := statement handle.
self registerForFinalization.
columnCount := SQLSmallInteger new.
connection
checkSQLReturn: (ODBCLibrary default sqlNumResultCols: handle columnCount: columnCount)
statement: handle.
columns := (1 to: columnCount value)
collect: [:each | ODBCColumn resultSet: self number: each].
""
columns notEmpty
ifTrue: [self fetchNextRow]! !
!ODBCResultSet methodsFor: 'printing' stamp: 'ar 8/2/2008 13:58'!
printContentsOn: stream
stream
nextPutAll: (self isConnected
ifTrue: [' (connected)']
ifFalse: [' (not connected)'])! !
!ODBCResultSet methodsFor: 'printing' stamp: 'jfr 11/14/2023 16:13:24'!
printOn: aStream
"Append to the argument, aStream, a sequence of characters that
identifies the receiver."
aStream
nextPutAll: self class name withArticle.
self printContentsOn: aStream.! !
!ODBCResultSet class methodsFor: 'instance creation' stamp: 'dgd 5/27/2002 22:44'!
connection: aConnection statement: aStatement
^ self basicNew initializeConnection: aConnection statement: aStatement ! !
!ODBCError methodsFor: 'initialization' stamp: 'dgd 6/3/2002 19:16'!
initializeDetails: aCollection
details := aCollection.
""
self messageText: self asString! !
!ODBCError methodsFor: 'printing' stamp: 'dgd 6/3/2002 19:17'!
printOn: aStream
super printOn: aStream.
aStream nextPutAll: ' '.
details
do: [:each | aStream nextPutAll: each asString]
separatedBy: [aStream nextPutAll: ', ']! !
!ODBCError class methodsFor: 'instance creation' stamp: 'dgd 6/3/2002 19:16'!
details: aCollection
^ self new initializeDetails: aCollection! !
!ODBCWarning methodsFor: 'printing' stamp: 'ar 8/2/2008 15:10'!
defaultAction
ToolSet default debugError: self! !
!ODBCWarning methodsFor: 'printing' stamp: 'dgd 6/3/2002 19:18'!
printOn: aStream
super printOn: aStream.
aStream nextPutAll: ' '.
details
do: [:each | aStream nextPutAll: each asString]
separatedBy: [aStream nextPutAll: ', ']! !
!ODBCWarning methodsFor: 'initialization' stamp: 'dgd 6/3/2002 19:18'!
initializeDetails: aCollection
details := aCollection.
""
self messageText: self asString! !
!ODBCWarning class methodsFor: 'instance creation' stamp: 'dgd 6/3/2002 19:18'!
details: aCollection
^ self new initializeDetails: aCollection! !
!ODBCLibrary methodsFor: 'primitives - connections' stamp: 'jfr 11/14/2023 17:19:58'!
sqlAllocConnectEnvironment: environmentHandle connection: connectionHandle
"SQLRETURN
SQLAllocConnect(
SQLHENV EnvironmentHandle,
SQLHDBC *ConnectionHandle);"
<cdecl: int16 'SQLAllocConnect' (SQLHENV SQLHDBC*)>
^ self externalCallFailed! !
!ODBCLibrary methodsFor: 'primitives - connections' stamp: 'jfr 11/14/2023 17:20:02'!
sqlConnect: connectionHandle dsn: dsnString dsnLength: dsnLengthInteger user: userString userLength: userLengthInteger authentication: authenticationString authenticationLength: authenticationLengthInteger
"SQLRETURN
SQLConnect(SQLHDBC ConnectionHandle,
SQLCHAR *ServerName,
SQLSMALLINT NameLength1,
SQLCHAR *UserName,
SQLSMALLINT NameLength2,
SQLCHAR *Authentication,
SQLSMALLINT NameLength3);"
<cdecl: int16 'SQLConnect' (SQLHDBC uint8* int16 uint8* int16 uint8* int16)>
^ self externalCallFailed! !
!ODBCLibrary methodsFor: 'primitives - connections' stamp: 'jfr 11/14/2023 17:20:08'!
sqlDisconnect: connectionHandle
"SQLRETURN SQLDisconnect(SQLHDBC ConnectionHandle);"
<cdecl: int16 'SQLDisconnect' (SQLHDBC)>
^ self externalCallFailed! !
!ODBCLibrary methodsFor: 'primitives - connections' stamp: 'jfr 11/14/2023 17:40:03'!
sqlDriverConnect: connectionHandle with: hWnd with: inConnStr with: inStrLength with: outConnStr with: outStrLength with: outSizePtr with: flags
"SQLRETURN SQLDriverConnect(
SQLHDBC ConnectionHandle,
SQLHWND WindowHandle,
SQLCHAR * InConnectionString,
SQLSMALLINT StringLength1,
SQLCHAR * OutConnectionString,
SQLSMALLINT BufferLength,
SQLSMALLINT * StringLength2Ptr,
SQLUSMALLINT DriverCompletion);"
<cdecl: int16 'SQLDriverConnect' (SQLHDBC void* uint8* int16 uint8* int16 SQLSmallInteger* uint3264)>
^ self externalCallFailed! !
!ODBCLibrary methodsFor: 'primitives - connections' stamp: 'jfr 11/14/2023 17:26:04'!
sqlEndTran: type handle: aHandle completionType: completionType
"SQLRETURN
SQLEndTran(
SQLSMALLINT HandleType,
SQLHANDLE Handle,
SQLSMALLINT CompletionType);"
<cdecl: int16 'SQLEndTran' (int16 SQLHDBC int16)>
^ self externalCallFailed! !
!ODBCLibrary methodsFor: 'primitives - connections' stamp: 'jfr 11/14/2023 17:20:27'!
sqlFreeConnect: connectionHandle
"SQLRETURN SQLFreeConnect(SQLHDBC ConnectionHandle);"
<cdecl: int16 'SQLFreeConnect' (SQLHDBC)>
^ self externalCallFailed! !
!ODBCLibrary methodsFor: 'primitives - connections' stamp: 'jfr 11/14/2023 17:30:33'!
sqlGetConnectAttr: connectionHandle attribute: attribute value: value length: length valueLength: valueLength
"SQLRETURN SQLGetConnectAttr(
SQLHDBC ConnectionHandle,
SQLINTEGER Attribute,
SQLPOINTER ValuePtr,
SQLINTEGER BufferLength,
SQLINTEGER * StringLengthPtr);"
<cdecl: int16 'SQLGetConnectAttr' (SQLHDBC int3264 void* int3264 SQLInteger*)>
^ self externalCallFailed! !
!ODBCLibrary methodsFor: 'primitives - connections' stamp: 'jfr 11/14/2023 17:21:01'!
sqlGetInfo: hdbc with: infoType with: resultPtr with: size with: resultLenPtr
"SQLRETURN SQLGetInfo(
SQLHDBC ConnectionHandle,
SQLUSMALLINT InfoType,
SQLPOINTER InfoValuePtr,
SQLSMALLINT BufferLength,
SQLSMALLINT * StringLengthPtr);"
<cdecl: int16 'SQLGetInfo' (SQLHDBC uint16 void* int16 SQLSmallInteger*)>
^ self externalCallFailed! !
!ODBCLibrary methodsFor: 'primitives - connections' stamp: 'jfr 11/14/2023 17:30:45'!
sqlSetConnectAttr: connectionHandle attribute: attribute value: value length: length
"SQLRETURN SQLSetConnectAttr(
SQLHDBC ConnectionHandle,
SQLINTEGER Attribute,
SQLPOINTER ValuePtr,
SQLINTEGER StringLength);"
<cdecl: int16 'SQLSetConnectAttr' (SQLHDBC int3264 int3264 int3264)>
^ self externalCallFailed! !
!ODBCLibrary methodsFor: 'primitives - environments' stamp: 'jfr 11/14/2023 17:21:25'!
sqlAllocEnv: environmentHandle
"SQLRETURN SQLAllocEnv(SQLHENV *EnvironmentHandle);"
<cdecl: int16 'SQLAllocEnv' (SQLHENV*)>
^ self externalCallFailed! !
!ODBCLibrary methodsFor: 'primitives - environments' stamp: 'jfr 11/14/2023 17:21:32'!
sqlFreeEnv: environmentHandle
"SQLRETURN SQLFreeEnv(SQLHENV EnvironmentHandle);"
<cdecl: int16 'SQLFreeEnv' (SQLHENV)>
^ self externalCallFailed! !
!ODBCLibrary methodsFor: 'primitives - environments' stamp: 'jfr 11/14/2023 17:30:57'!
sqlSetEnvAttr: hEnv attr: attr value: value length: length
"SQLRETURN SQLSetEnvAttr(
SQLHENV EnvironmentHandle,
SQLINTEGER Attribute,
SQLPOINTER ValuePtr,
SQLINTEGER StringLength);"
<cdecl: int16 'SQLSetEnvAttr' (SQLHENV int3264 int3264 int3264)>
^ self externalCallFailed! !
!ODBCLibrary methodsFor: 'primitives - environments' stamp: 'jfr 11/14/2023 17:31:04'!
sqlSetEnvAttrPtr: hEnv attr: attr value: value length: length
"SQLRETURN SQLSetEnvAttr(
SQLHENV EnvironmentHandle,
SQLINTEGER Attribute,
SQLPOINTER ValuePtr,
SQLINTEGER StringLength);"
<cdecl: int16 'SQLSetEnvAttr' (SQLHENV int3264 void* int3264)>
^ self externalCallFailed! !
!ODBCLibrary methodsFor: 'primitives - statements' stamp: 'jfr 11/14/2023 17:21:57'!
sqlAllocStmtConnection: environmentHandle statement: statementHandle
"SQLRETURN
SQLAllocStmt(
SQLHDBC ConnectionHandle,
SQLHSTMT *StatementHandle); "
<cdecl: int16 'SQLAllocStmt' (SQLHDBC SQLHSTMT*)>
^ self externalCallFailed! !
!ODBCLibrary methodsFor: 'primitives - statements' stamp: 'jfr 11/14/2023 17:31:13'!
sqlBindCol: statementHandle columnNumber: columnNumber targetType: targetType targetValue: targetValue bufferLength: bufferLength strLength: strLenght
"SQLRETURN
SQLGetData(
SQLHSTMT StatementHandle,
SQLUSMALLINT ColumnNumber,
SQLSMALLINT TargetType,
SQLPOINTER TargetValue,
SQLINTEGER BufferLength,
SQLINTEGER *StrLen:=or:=Ind);"
<cdecl: int16 'SQLBindCol' (SQLHSTMT uint16 int16 void* int3264 SQLInteger*)>
^ self externalCallFailed! !
!ODBCLibrary methodsFor: 'primitives - statements' stamp: 'jfr 11/14/2023 17:31:21'!
sqlBindParam: statementHandle at: paramIdx appType: dtype sqlType: ptype columSize: sz digits: digits value: vptr length: lenPtr
"SQLRETURN SQL_API SQLBindParam(
SQLHSTMT StatementHandle,
SQLUSMALLINT ParameterNumber,
SQLSMALLINT ValueType,
SQLSMALLINT ParameterType,
SQLULEN LengthPrecision,
SQLSMALLINT ParameterScale,
SQLPOINTER ParameterValue,
SQLLEN *StrLen_or_Ind);"
<cdecl: int16 'SQLBindParam' (SQLHSTMT uint16 int16 int16 uint3264 int16 void* SQLInteger*)>
^ self externalCallFailed! !
!ODBCLibrary methodsFor: 'primitives - statements' stamp: 'jfr 11/14/2023 17:31:31'!
sqlBindParameter: statementHandle at: paramIdx ioType: ioType valueType: dtype paramType: ptype columSize: sz digits: digits value: vptr bufferSize: bfsz length: lenPtr
"SQLRETURN SQL_API SQLBindParameter(
SQLHSTMT hstmt,
SQLUSMALLINT ipar,
SQLSMALLINT fParamType,
SQLSMALLINT fCType,
SQLSMALLINT fSqlType,
SQLULEN cbColDef,
SQLSMALLINT ibScale,
SQLPOINTER rgbValue,
SQLLEN cbValueMax,
SQLLEN *pcbValue);"
<cdecl: int16 'SQLBindParam' (SQLHSTMT uint16 int16 int16 int16 uint3264 int16 void* int3264 SQLInteger*)>
^ self externalCallFailed! !
!ODBCLibrary methodsFor: 'primitives - statements' stamp: 'jfr 11/14/2023 17:23:05'!
sqlDescribeParam: statementHandle at: paramIdx dataType: typePtr paramSize: lengthPtr digits: scalePtr nullable: nullable
"SQLRETURN SQL_API SQLDescribeParam(
SQLHSTMT hstmt,
SQLUSMALLINT ipar,
SQLSMALLINT *pfSqlType,
SQLULEN *pcbParamDef,
SQLSMALLINT *pibScale,
SQLSMALLINT *pfNullable);"
<cdecl: int16 'SQLDescribeParam' (SQLHSTMT uint16 SQLSmallInteger* SQLInteger* SQLSmallInteger* SQLSmallInteger*)>
^ self externalCallFailed! !
!ODBCLibrary methodsFor: 'primitives - statements' stamp: 'jfr 11/14/2023 17:35:16'!
sqlExecDirect: statementHandle statement: statementString length: statementLength
"SQLRETURN
SQLExecDirect(
SQLHSTMT StatementHandle,
SQLCHAR *StatementText,
SQLINTEGER TextLength);"
<cdecl: int16 'SQLExecDirect' (SQLHSTMT uint8* int3264)>
^ self externalCallFailed! !
!ODBCLibrary methodsFor: 'primitives - statements' stamp: 'jfr 11/14/2023 17:23:26'!
sqlExecute: hstmt
"SQLRETURN SQL_API SQLExecute(
SQLHSTMT hstmt);"
<cdecl: int16 'SQLExecute' (SQLHSTMT)>
^ self externalCallFailed! !
!ODBCLibrary methodsFor: 'primitives - statements' stamp: 'jfr 11/14/2023 17:23:33'!
sqlFetch: statementHandle
"SQLRETURN SQLFetch(SQLHSTMT StatementHandle);"
<cdecl: int16 'SQLFetch' (SQLHSTMT)>
^ self externalCallFailed! !
!ODBCLibrary methodsFor: 'primitives - statements' stamp: 'jfr 11/14/2023 17:23:43'!
sqlFreeStmt: statementHandle option: optionInteger
"SQLRETURN
SQLFreeStmt(
SQLHSTMT StatementHandle,
SQLUSMALLINT Option); "
<cdecl: int16 'SQLFreeStmt' (SQLHSTMT uint16)>
^ self externalCallFailed! !
!ODBCLibrary methodsFor: 'primitives - statements' stamp: 'jfr 11/14/2023 17:31:51'!
sqlGetData: statementHandle columnNumber: columnNumber targetType: targetType targetValue: targetValue bufferLength: bufferLength strLength: strLenght
"SQLRETURN
SQLGetData(
SQLHSTMT StatementHandle,
SQLUSMALLINT ColumnNumber,
SQLSMALLINT TargetType,
SQLPOINTER TargetValue,
SQLINTEGER BufferLength,
SQLINTEGER *StrLen:=or:=Ind);"
<cdecl: int16 'SQLGetData' (SQLHSTMT uint3264 int16 void* int3264 SQLInteger*)>
^ self externalCallFailed! !
!ODBCLibrary methodsFor: 'primitives - statements' stamp: 'jfr 11/14/2023 17:24:04'!
sqlGetTypeInfo: hstmt with: dataType
"SQLRETURN SQLGetTypeInfo(
SQLHSTMT StatementHandle,
SQLSMALLINT DataType);"
<cdecl: int16 'SQLGetTypeInfo' (SQLHSTMT uint16)>
^ self externalCallFailed! !
!ODBCLibrary methodsFor: 'primitives - statements' stamp: 'jfr 11/14/2023 17:24:12'!
sqlNumParams: statementHandle into: shortArray
"SQLRETURN
SQLNumParams(
SQLHSTMT StatementHandle,
SQLSMALLINT *pcpar);"
<cdecl: int16 'SQLNumParams' (SQLHSTMT SQLSmallInteger*)>
^ self externalCallFailed! !
!ODBCLibrary methodsFor: 'primitives - statements' stamp: 'jfr 11/14/2023 17:35:30'!
sqlPrepare: statementHandle statement: statementString length: statementLength
"SQLRETURN
SQLPrepare(
SQLHSTMT StatementHandle,
SQLCHAR *StatementText,