-
Notifications
You must be signed in to change notification settings - Fork 82
/
Copy pathcreate_schema.sql
1521 lines (1312 loc) · 47 KB
/
create_schema.sql
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
/*-----------------------------------------------------------------------------
* Copyright (c) 2020, 2025, Oracle and/or its affiliates.
*
* This software is dual-licensed to you under the Universal Permissive License
* (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License
* 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose
* either license.*
*
* If you elect to accept the software under the Apache License, Version 2.0,
* the following applies:
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*---------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------------
* create_schema.sql
*
* Performs the actual work of creating and populating the schemas with the
* database objects used by the python-oracledb test suite. It is executed by
* the Python script create_schema.py.
*---------------------------------------------------------------------------*/
alter session set nls_date_format = 'YYYY-MM-DD HH24:MI:SS'
/
alter session set nls_numeric_characters='.,'
/
alter session set time_zone='+00:00'
/
create user &main_user identified by &main_password
/
create user &proxy_user identified by &proxy_password
/
alter user &proxy_user grant connect through &main_user
/
grant create session to &proxy_user
/
grant
create session,
create table,
create procedure,
create type,
create view,
select any dictionary,
change notification,
unlimited tablespace,
ctxapp
to &main_user
/
grant aq_administrator_role to &main_user
/
begin
for r in
( select role
from dba_roles
where role in ('SODA_APP')
) loop
execute immediate 'grant ' || r.role || ' to &main_user';
end loop;
end;
/
-- create edition
create edition &edition_name
/
grant use on edition &edition_name to &main_user
/
-- create types
create type &main_user..udt_SubObject as object (
SubNumberValue number,
SubStringValue varchar2(60)
);
/
create type &main_user..udt_ObjectArray as
varray(10) of &main_user..udt_SubObject;
/
create type &main_user..udt_Object as object (
NumberValue number,
StringValue varchar2(60),
FixedCharValue char(10),
NStringValue nvarchar2(60),
NFixedCharValue nchar(10),
RawValue raw(16),
IntValue integer,
SmallIntValue smallint,
RealValue real,
DoublePrecisionValue double precision,
FloatValue float,
BinaryFloatValue binary_float,
BinaryDoubleValue binary_double,
DateValue date,
TimestampValue timestamp,
TimestampTZValue timestamp with time zone,
TimestampLTZValue timestamp with local time zone,
CLOBValue clob,
NCLOBValue nclob,
BLOBValue blob,
SubObjectValue &main_user..udt_SubObject,
SubObjectArray &main_user..udt_ObjectArray
);
/
create type &main_user..udt_Array as varray(10) of number;
/
create type &main_user..udt_UnconstrainedTable as table of number;
/
create or replace type &main_user..udt_Building as object (
BuildingId number(9),
NumFloors number(3),
Description varchar2(60),
DateBuilt date
);
/
create or replace type &main_user..udt_Book as object (
Title varchar2(100),
Authors varchar2(100),
Price number(5,2)
);
/
create or replace type &main_user..udt_ObjectWithXmlType as object (
NumberValue number(9),
XMLValue sys.xmltype,
StringValue varchar2(60)
);
/
create or replace type &main_user..udt_XmlTypeArray
as table of sys.xmltype;
/
-- create tables
create table &main_user..TestNumbers (
IntCol number(9) not null,
LongIntCol number(16) not null,
NumberCol number(9, 2) not null,
FloatCol float not null,
UnconstrainedCol number not null,
NullableCol number(38)
)
/
create table &main_user..TestStrings (
IntCol number(9) not null,
StringCol varchar2(20) not null,
RawCol raw(30) not null,
FixedCharCol char(40) not null,
NullableCol varchar2(50)
)
/
create table &main_user..TestUnicodes (
IntCol number(9) not null,
UnicodeCol nvarchar2(20) not null,
FixedUnicodeCol nchar(40) not null,
NullableCol nvarchar2(50)
)
/
create table &main_user..TestDates (
IntCol number(9) not null,
DateCol date not null,
NullableCol date
)
/
create table &main_user..TestCLOBs (
IntCol number(9) not null,
CLOBCol clob not null,
ExtraNumCol1 number(9),
ExtraCLOBCol1 clob,
ExtraNumCol2 number(9),
ExtraCLOBCol2 clob
)
/
create table &main_user..TestNCLOBs (
IntCol number(9) not null,
NCLOBCol nclob not null,
ExtraNumCol1 number(9),
ExtraNCLOBCol1 nclob,
ExtraNumCol2 number(9),
ExtraNCLOBCol2 nclob
)
/
create table &main_user..TestBLOBs (
IntCol number(9) not null,
BLOBCol blob not null,
ExtraNumCol1 number(9),
ExtraBLOBCol1 blob,
ExtraNumCol2 number(9),
ExtraBLOBCol2 blob
)
/
create table &main_user..TestBfiles (
IntCol number(9) not null,
BfileCol bfile not null
)
/
create table &main_user..TestXML (
IntCol number(9) not null,
XMLCol xmltype not null
)
/
create table &main_user..TestTempXML (
IntCol number(9) not null,
XMLCol xmltype not null
)
/
create table &main_user..TestLongs (
IntCol number(9) not null,
LongCol long
) nocompress
/
create table &main_user..TestLongRaws (
IntCol number(9) not null,
LongRawCol long raw
) nocompress
/
create table &main_user..TestTempTable (
IntCol number(9) not null,
StringCol1 varchar2(400),
StringCol2 varchar2(400),
NumberCol number(25,2),
constraint TestTempTable_pk primary key (IntCol)
)
/
create table &main_user..TestArrayDML (
IntCol number(9) not null,
StringCol varchar2(100),
IntCol2 number(3),
constraint TestArrayDML_pk primary key (IntCol)
)
/
create table &main_user..TestObjects (
IntCol number(9) not null,
ObjectCol &main_user..udt_Object,
ArrayCol &main_user..udt_Array
)
/
create table &main_user..TestTimestamps (
IntCol number(9) not null,
TimestampCol timestamp not null,
NullableCol timestamp,
TimestampPrecisionCol timestamp(4)
)
/
create table &main_user..TestTimestampLTZs (
IntCol number(9) not null,
TimestampLTZCol timestamp with local time zone not null,
NullableCol timestamp with local time zone,
TimestampLTZPrecisionCol timestamp(5) with local time zone
)
/
create table &main_user..TestTimestampTZs (
IntCol number(9) not null,
TimestampTZCol timestamp with time zone not null,
NullableCol timestamp with time zone,
TimestampTZPrecisionCol timestamp(7) with time zone
)
/
create table &main_user..TestIntervals (
IntCol number(9) not null,
IntervalCol interval day to second not null,
NullableCol interval day to second,
IntervalPrecisionCol interval day(7) to second,
IntervalPrecisionScaleCol interval day(8) to second(9)
)
/
create table &main_user..TestIntervalYMs (
IntCol number(9) not null,
IntervalCol interval year to month not null,
NullableCol interval year to month,
IntervalPrecisionCol interval year(3) to month
)
/
create table &main_user..TestUniversalRowids (
IntCol number(9) not null,
StringCol varchar2(250) not null,
DateCol date not null,
constraint TestUniversalRowids_pk primary key (IntCol, StringCol, DateCol)
) organization index
/
create table &main_user..TestBuildings (
BuildingId number(9) not null,
BuildingObj &main_user..udt_Building not null
)
/
create table &main_user..TestRowids (
IntCol number(9) not null,
RowidCol rowid,
URowidCol urowid
)
/
create table &main_user..TestJsonCols (
IntCol number(9) not null,
JsonVarchar varchar2(4000) not null,
JsonClob clob not null,
JsonBlob blob not null,
constraint TestJsonCols_ck_1 check (JsonVarchar is json format json),
constraint TestJsonCols_ck_2 check (JsonClob is json format json),
constraint TestJsonCols_ck_3 check (JsonBlob is json format json)
)
/
create table &main_user..TestAllTypes (
NumberValue number,
StringValue varchar2(60),
FixedCharValue char(10),
NStringValue nvarchar2(60),
NFixedCharValue nchar(10),
RawValue raw(16),
IntValue integer,
SmallIntValue smallint,
RealValue real,
DoublePrecisionValue double precision,
FloatValue float,
BinaryFloatValue binary_float,
BinaryDoubleValue binary_double,
DateValue date,
TimestampValue timestamp,
TimestampTZValue timestamp with time zone,
TimestampLTZValue timestamp with local time zone,
CLOBValue clob,
NCLOBValue nclob,
BLOBValue blob,
SubObjectValue &main_user..udt_SubObject,
SubObjectArray &main_user..udt_ObjectArray,
InvisibleValue number invisible
)
/
create table &main_user..PlsqlSessionCallbacks (
RequestedTag varchar2(250),
ActualTag varchar2(250),
FixupTimestamp timestamp
)
/
create table &main_user..TestDataframe (
Id number(9),
FirstName varchar2(100),
LastName varchar2(100),
City varchar2(100),
Country varchar2(100),
DateOfBirth date,
Salary number(9, 2),
CreditScore number(3, 0),
LastUpdated timestamp
)
/
-- create queue table and queues for testing advanced queuing
begin
dbms_aqadm.create_queue_table('&main_user..BOOK_QUEUE_TAB',
'&main_user..UDT_BOOK');
dbms_aqadm.create_queue('&main_user..TEST_BOOK_QUEUE',
'&main_user..BOOK_QUEUE_TAB');
dbms_aqadm.start_queue('&main_user..TEST_BOOK_QUEUE');
dbms_aqadm.create_queue_table('&main_user..RAW_QUEUE_TAB', 'RAW');
dbms_aqadm.create_queue('&main_user..TEST_RAW_QUEUE',
'&main_user..RAW_QUEUE_TAB');
dbms_aqadm.start_queue('&main_user..TEST_RAW_QUEUE');
dbms_aqadm.create_queue_table('&main_user..BOOK_QUEUE_MULTI_TAB',
'&main_user..UDT_BOOK', multiple_consumers => TRUE);
dbms_aqadm.create_queue('&main_user..BOOK_QUEUE_MULTI',
'&main_user..BOOK_QUEUE_MULTI_TAB');
dbms_aqadm.start_queue('&main_user..BOOK_QUEUE_MULTI');
dbms_aqadm.add_subscriber('&main_user..BOOK_QUEUE_MULTI',
sys.aq$_agent('Sub1', null, null));
end;
/
-- create transformations
begin
dbms_transform.create_transformation('&main_user', 'transform1',
'&main_user', 'UDT_BOOK', '&main_user', 'UDT_BOOK',
'&main_user..UDT_BOOK(source.user_data.TITLE, ' ||
'source.user_data.AUTHORS, source.user_data.PRICE + 5)');
dbms_transform.create_transformation('&main_user', 'transform2',
'&main_user', 'UDT_BOOK', '&main_user', 'UDT_BOOK',
'&main_user..UDT_BOOK(source.user_data.TITLE, ' ||
'source.user_data.AUTHORS, source.user_data.PRICE + 10)');
end;
/
-- populate tables
begin
for i in 1..10 loop
insert into &main_user..TestNumbers
values (i, power(38, i), i + i * 0.25, i + i * .75, i * i * i + i *.5,
decode(mod(i, 2), 0, null, power(143, i)));
end loop;
end;
/
declare
t_RawValue raw(30);
function ConvertHexDigit(a_Value number) return varchar2 is
begin
if a_Value between 0 and 9 then
return to_char(a_Value);
end if;
return chr(ascii('A') + a_Value - 10);
end;
function ConvertToHex(a_Value varchar2) return varchar2 is
t_HexValue varchar2(60);
t_Digit number;
begin
for i in 1..length(a_Value) loop
t_Digit := ascii(substr(a_Value, i, 1));
t_HexValue := t_HexValue ||
ConvertHexDigit(trunc(t_Digit / 16)) ||
ConvertHexDigit(mod(t_Digit, 16));
end loop;
return t_HexValue;
end;
begin
for i in 1..10 loop
t_RawValue := hextoraw(ConvertToHex('Raw ' || to_char(i)));
insert into &main_user..TestStrings
values (i, 'String ' || to_char(i), t_RawValue,
'Fixed Char ' || to_char(i),
decode(mod(i, 2), 0, null, 'Nullable ' || to_char(i)));
end loop;
end;
/
begin
for i in 1..10 loop
insert into &main_user..TestUnicodes
values (i, 'Unicode ' || unistr('\3042') || ' ' || to_char(i),
'Fixed Unicode ' || to_char(i),
decode(mod(i, 2), 0, null, unistr('Nullable ') || to_char(i)));
end loop;
end;
/
begin
for i in 1..10 loop
insert into &main_user..TestDates
values (i, to_date(20021209, 'YYYYMMDD') + i + i * .1,
decode(mod(i, 2), 0, null,
to_date(20021209, 'YYYYMMDD') + i + i + i * .15));
end loop;
end;
/
begin
for i in 1..100 loop
insert into &main_user..TestXML
values (i, '<?xml version="1.0"?><records>' ||
dbms_random.string('x', 1024) || '</records>');
end loop;
end;
/
begin
for i in 1..10 loop
insert into &main_user..TestTimestamps
values (i, to_timestamp('20021209', 'YYYYMMDD') +
to_dsinterval(to_char(i) || ' 00:00:' || to_char(i * 2) ||
'.' || to_char(i * 50)),
decode(mod(i, 2), 0, to_timestamp(null, 'YYYYMMDD'),
to_timestamp('20021209', 'YYYYMMDD') +
to_dsinterval(to_char(i + 1) || ' 00:00:' ||
to_char(i * 3) || '.' || to_char(i * 125))),
to_timestamp('20091214', 'YYYYMMDD'));
end loop;
end;
/
begin
for i in 1..10 loop
insert into &main_user..TestTimestampLTZs
values (i, to_timestamp_tz('20220602 ' ||
decode(mod(i, 2), 0, '-', '+') ||
ltrim(to_char(i, '00')) || ':' ||
decode(mod(i, 4), 0, '00', '30'), 'YYYYMMDD TZH:TZM') +
to_dsinterval(to_char(i) || ' 00:00:' || to_char(i * 2) ||
'.' || to_char(i * 50)),
decode(mod(i, 2), 0, to_timestamp(null, 'YYYYMMDD'),
to_timestamp_tz('20220602 00:00', 'YYYYMMDD TZH:TZM') +
to_dsinterval(to_char(i + 1) || ' 00:00:' ||
to_char(i * 3) || '.' || to_char(i * 125))),
to_timestamp_tz('20091214 00:00', 'YYYYMMDD TZH:TZM'));
end loop;
end;
/
begin
for i in 1..10 loop
insert into &main_user..TestTimestampTZs
values (i, to_timestamp_tz('20220603 ' ||
decode(mod(i, 2), 0, '-', '+') ||
ltrim(to_char(i, '00')) || ':' ||
decode(mod(i, 4), 0, '00', '30'), 'YYYYMMDD TZH:TZM') +
to_dsinterval(to_char(i) || ' 00:00:' || to_char(i * 2) ||
'.' || to_char(i * 50)),
decode(mod(i, 2), 0, to_timestamp(null, 'YYYYMMDD'),
to_timestamp_tz('20220603 00:00', 'YYYYMMDD TZH:TZM') +
to_dsinterval(to_char(i + 1) || ' 00:00:' ||
to_char(i * 3) || '.' || to_char(i * 125))),
to_timestamp_tz('20091214 00:00', 'YYYYMMDD TZH:TZM'));
end loop;
end;
/
begin
for i in 1..10 loop
insert into &main_user..TestIntervals
values (i, to_dsinterval(to_char(i) || ' ' || to_char(i) || ':' ||
to_char(i * 2) || ':' || to_char(i * 3)),
decode(mod(i, 2), 0, to_dsinterval(null),
to_dsinterval(to_char(i + 5) || ' ' || to_char(i + 2) || ':' ||
to_char(i * 2 + 5) || ':' || to_char(i * 3 + 5))),
to_dsinterval('8 05:15:00'),
to_dsinterval('10 12:15:15'));
end loop;
end;
/
begin
for i in 1..10 loop
insert into &main_user..TestIntervalYMs
values (i, to_yminterval(to_char(i - 5) || '-' || to_char(i)),
decode(mod(i, 2), 0, to_yminterval(null),
to_yminterval(to_char(i + 5) || '-' || to_char(i + 2))),
to_yminterval('3-8'));
end loop;
end;
/
insert into &main_user..TestObjects values (1,
&main_user..udt_Object(1, 'First row', 'First', 'N First Row', 'N First',
'52617720446174612031', 2, 5, 12.125, 0.5, 12.5, 25.25, 50.125,
to_date(20070306, 'YYYYMMDD'),
to_timestamp('20080912 16:40:00', 'YYYYMMDD HH24:MI:SS'),
to_timestamp_tz('20091013 17:50:00 00:00',
'YYYYMMDD HH24:MI:SS TZH:TZM'),
to_timestamp_tz('20101114 18:55:00 00:00',
'YYYYMMDD HH24:MI:SS TZH:TZM'),
'Short CLOB value', 'Short NCLOB Value',
utl_raw.cast_to_raw('Short BLOB value'),
&main_user..udt_SubObject(11, 'Sub object 1'),
&main_user..udt_ObjectArray(
&main_user..udt_SubObject(5, 'first element'),
&main_user..udt_SubObject(6, 'second element'))),
&main_user..udt_Array(5, 10, null, 20))
/
insert into &main_user..TestObjects values (2, null,
&main_user..udt_Array(3, null, 9, 12, 15))
/
insert into &main_user..TestObjects values (3,
&main_user..udt_Object(3, 'Third row', 'Third', 'N Third Row', 'N Third',
'52617720446174612033', 4, 10, 6.5, 0.75, 43.25, 86.5, 192.125,
to_date(20070621, 'YYYYMMDD'),
to_timestamp('20071213 07:30:45', 'YYYYMMDD HH24:MI:SS'),
to_timestamp_tz('20170621 23:18:45 00:00',
'YYYYMMDD HH24:MI:SS TZH:TZM'),
to_timestamp_tz('20170721 08:27:13 00:00',
'YYYYMMDD HH24:MI:SS TZH:TZM'),
'Another short CLOB value', 'Another short NCLOB Value',
utl_raw.cast_to_raw('Yet another short BLOB value'),
&main_user..udt_SubObject(13, 'Sub object 3'),
&main_user..udt_ObjectArray(
&main_user..udt_SubObject(10, 'element #1'),
&main_user..udt_SubObject(20, 'element #2'),
&main_user..udt_SubObject(30, 'element #3'),
&main_user..udt_SubObject(40, 'element #4'))), null)
/
insert into &main_user..TestJsonCols values (1,
'[1, 2, 3]', '[4, 5, 6]', utl_raw.cast_to_raw('[7, 8, 9]'))
/
insert into &main_user..TestJsonCols values (2,
'null', empty_clob(), empty_blob())
/
commit
/
-- create procedures for testing callproc()
create procedure &main_user..proc_Test (
a_InValue varchar2,
a_InOutValue in out number,
a_OutValue out number
) as
begin
a_InOutValue := a_InOutValue * length(a_InValue);
a_OutValue := length(a_InValue);
end;
/
create procedure &main_user..proc_Test2 (
a_InValue varchar2,
a_InOutValue in out number,
a_OutValue out boolean
) as
begin
a_InOutValue := a_InOutValue * length(a_InValue);
a_OutValue := false;
if length(a_InValue) >= 2 then
a_OutValue := true;
end if;
end;
/
create procedure &main_user..proc_TestNoArgs as
begin
null;
end;
/
-- create procedure for testing refcursor
create procedure &main_user..myrefcursorproc (
a_RefCursor out sys_refcursor
) as
begin
open a_RefCursor for
select *
from TestTempTable;
end;
/
-- create functions for testing callfunc()
create function &main_user..func_Test (
a_String varchar2,
a_ExtraAmount number
) return number as
begin
return length(a_String) + a_ExtraAmount;
end;
/
create function &main_user..func_Test2 (
a_String varchar2,
a_ExtraAmount number,
a_Boolean boolean
) return number as
begin
if a_Boolean then
return length(a_String) + a_ExtraAmount;
end if;
return length(a_String) - a_ExtraAmount;
end;
/
create function &main_user..func_TestNoArgs
return number as
begin
return 712;
end;
/
-- create packages
create or replace package &main_user..pkg_TestStringArrays as
type udt_StringList is table of varchar2(100) index by binary_integer;
function TestInArrays (
a_StartingLength number,
a_Array udt_StringList
) return number;
procedure TestInOutArrays (
a_NumElems number,
a_Array in out nocopy udt_StringList
);
procedure TestOutArrays (
a_NumElems number,
a_Array out nocopy udt_StringList
);
procedure TestIndexBy (
a_Array out nocopy udt_StringList
);
end;
/
create or replace package body &main_user..pkg_TestStringArrays as
function TestInArrays (
a_StartingLength number,
a_Array udt_StringList
) return number is
t_Length number;
begin
t_Length := a_StartingLength;
for i in 1..a_Array.count loop
t_Length := t_Length + length(a_Array(i));
end loop;
return t_Length;
end;
procedure TestInOutArrays (
a_NumElems number,
a_Array in out udt_StringList
) is
begin
for i in 1..a_NumElems loop
a_Array(i) := 'Converted element # ' ||
to_char(i) || ' originally had length ' ||
to_char(length(a_Array(i)));
end loop;
end;
procedure TestOutArrays (
a_NumElems number,
a_Array out udt_StringList
) is
begin
for i in 1..a_NumElems loop
a_Array(i) := 'Test out element # ' || to_char(i);
end loop;
end;
procedure TestIndexBy (
a_Array out nocopy udt_StringList
) is
begin
a_Array(-1048576) := 'First element';
a_Array(-576) := 'Second element';
a_Array(284) := 'Third element';
a_Array(8388608) := 'Fourth element';
end;
end;
/
create or replace package &main_user..pkg_TestUnicodeArrays as
type udt_UnicodeList is table of nvarchar2(100) index by binary_integer;
function TestInArrays (
a_StartingLength number,
a_Array udt_UnicodeList
) return number;
procedure TestInOutArrays (
a_NumElems number,
a_Array in out nocopy udt_UnicodeList
);
procedure TestOutArrays (
a_NumElems number,
a_Array out nocopy udt_UnicodeList
);
end;
/
create or replace package body &main_user..pkg_TestUnicodeArrays as
function TestInArrays (
a_StartingLength number,
a_Array udt_UnicodeList
) return number is
t_Length number;
begin
t_Length := a_StartingLength;
for i in 1..a_Array.count loop
t_Length := t_Length + length(a_Array(i));
end loop;
return t_Length;
end;
procedure TestInOutArrays (
a_NumElems number,
a_Array in out udt_UnicodeList
) is
begin
for i in 1..a_NumElems loop
a_Array(i) := unistr('Converted element ' || unistr('\3042') ||
' # ') || to_char(i) || ' originally had length ' ||
to_char(length(a_Array(i)));
end loop;
end;
procedure TestOutArrays (
a_NumElems number,
a_Array out udt_UnicodeList
) is
begin
for i in 1..a_NumElems loop
a_Array(i) := unistr('Test out element ') || unistr('\3042') ||
' # ' || to_char(i);
end loop;
end;
end;
/
create or replace package &main_user..pkg_TestNumberArrays as
type udt_NumberList is table of number index by binary_integer;
function TestInArrays (
a_StartingValue number,
a_Array udt_NumberList
) return number;
procedure TestInOutArrays (
a_NumElems number,
a_Array in out nocopy udt_NumberList
);
procedure TestOutArrays (
a_NumElems number,
a_Array out nocopy udt_NumberList
);
end;
/
create or replace package body &main_user..pkg_TestNumberArrays as
function TestInArrays (
a_StartingValue number,
a_Array udt_NumberList
) return number is
t_Value number;
begin
t_Value := a_StartingValue;
for i in 1..a_Array.count loop
t_Value := t_Value + a_Array(i);
end loop;
return t_Value;
end;
procedure TestInOutArrays (
a_NumElems number,
a_Array in out udt_NumberList
) is
begin
for i in 1..a_NumElems loop
a_Array(i) := a_Array(i) * 10;
end loop;
end;
procedure TestOutArrays (
a_NumElems number,
a_Array out udt_NumberList
) is
begin
for i in 1..a_NumElems loop
a_Array(i) := i * 100;
end loop;
end;
end;
/
create or replace package &main_user..pkg_TestDateArrays as
type udt_DateList is table of date index by binary_integer;
function TestInArrays (
a_StartingValue number,
a_BaseDate date,
a_Array udt_DateList
) return number;
procedure TestInOutArrays (
a_NumElems number,
a_Array in out nocopy udt_DateList
);
procedure TestOutArrays (
a_NumElems number,
a_Array out nocopy udt_DateList
);
end;
/
create or replace package body &main_user..pkg_TestDateArrays as
function TestInArrays (
a_StartingValue number,
a_BaseDate date,
a_Array udt_DateList
) return number is
t_Value number;
begin
t_Value := a_StartingValue;
for i in 1..a_Array.count loop
t_Value := t_Value + a_Array(i) - a_BaseDate;
end loop;
return t_Value;
end;
procedure TestInOutArrays (
a_NumElems number,
a_Array in out udt_DateList
) is
begin
for i in 1..a_NumElems loop
a_Array(i) := a_Array(i) + 7;
end loop;
end;
procedure TestOutArrays (
a_NumElems number,
a_Array out udt_DateList
) is
begin
for i in 1..a_NumElems loop
a_Array(i) := to_date(20021212, 'YYYYMMDD') + i * 1.2;
end loop;
end;
end;
/
create or replace package &main_user..pkg_TestRefCursors as
procedure TestOutCursor (
a_MaxIntValue number,
a_Cursor out sys_refcursor
);
function TestInCursor (
a_Cursor sys_refcursor
) return varchar2;
function TestReturnCursor (
a_MaxIntValue number
) return sys_refcursor;
procedure TestLobCursor (
a_Value varchar2,
a_Cursor out sys_refcursor
);
procedure TestCloseCursor (
a_Cursor sys_refcursor
);
end;
/
create or replace package body &main_user..pkg_TestRefCursors as
procedure TestOutCursor (