I have written the following PL/SQL code block and it uses a long array of 4 digit strings in the array.
The program block will loop over the array using the array(i) position as a query variable to return the the r_LDR_IORG record which is then printed with i, array(i), and r_LRD_IORG.PS_ORG_ID.
1 DECLARE
2 type array_t is varray(692) of varchar2(6);
3 array array_t := array_t('0118','0118','01R1','01R1','01R2','01R2','01R4','01R4',
4 '01R5','01R5','01R7','01R7','03BB','03BB','03BB','03BB',
5 '03R3','03R4','03R8','0684','0684','0684','0685','0685',
6 '0685','06CN','06CN','06CN','06GG','06GG','0799','0799',
7 '079T','079T','079T','079T','07R1','07R1','07R1','07R1',
8 '07R3','07R3','07R3','07R3','07R5','07R5','07R5','07R5',
9 '07R6','07R6','07R6','07R6','07R7','07R7','07R7','07R7',
10 '0954','0954','0954','0956','0956','0956','0959','0959',
11 '0959','09ZZ','09ZZ','09ZZ','14R1','14R1','14R1','14R2',
12 '14R2','14R2','16C4','16C4','16C4','16R3','16R3','16R5',
13 '16R5','16R5','16R5','16R7','16R7','16R7','16U4','16U4',
14 '16U4','16U4','1850','1850','1851','1852','1899','20R1',
15 '20R1','20R2','20R2','2181','2181','2181','2181','2182',
16 '2182','2182','2182','2184','2184','2184','2184','2186',
17 '2186','2186','2186','23C1','23C1','23C1','23C1','23C1',
18 '23C1','23C2','23C2','23C2','23C2','23C2','23C2','23FF',
19 '23FF','23FF','23FF','23R1','23R1','23R1','23R1','23R1',
20 '23R1','23R1','23R1','23R2','23R2','23R2','23R2','23R2',
21 '23R2','23R2','23R2','23R3','23R3','23R3','23R3','23R3',
22 '23R3','23R3','23R3','23R5','23R5','23R5','23R5','23R5',
23 '23R5','23R5','23R5','23R6','23R6','23R6','23R6','23R6',
24 '23R6','23R6','23R6','23R7','23R7','23R7','23R7','23R8',
25 '23R8','23R8','23R8','23R8','23R8','23R8','23VP','23VP',
26 '23VP','23VP','23X1','23X1','23X1','23X1','23X2','23X2',
27 '23X2','23X2','23X3','23X3','23X3','23X3','23X4','23X4',
28 '23X4','23X4','23XX','23XX','23XX','23XX','24MA','24MA',
29 '24MA','24MB','24MB','24MB','24MG','24MG','24MQ','24MQ',
30 '24MQ','24MR','24MR','24MR','26R2','26R2','26R4','26R4',
31 '299T','299T','299T','29R1','29R1','29R1','29R2','29R2',
32 '29R2','29R3','29R3','29R4','29R4','29R4','3071','3071',
33 '3071','3071','3072','3072','3072','3072','3075','3075',
34 '3075','3075','3083','3083','3083','3083','3084','3084',
35 '3084','3084','30XB','30XB','30XB','30XB','32M2','32M2',
36 '32M2','32M2','32M2','32M3','32M3','32M3','32M3','32M3',
37 '32M4','32M4','32M4','32M4','32M4','32M5','32M5','32M5',
38 '32M5','32M5','32M6','32M6','32M6','32M6','32M6','32M7',
39 '32M7','32M7','32M7','32M7','32M8','32M8','32M8','32M8',
40 '32M8','32MB','32MB','32MB','32MB','32MB','32MD','32MD',
41 '32MD','32MD','32MD','32ME','32ME','32ME','32ME','32ME',
42 '32MF','32MF','32MF','32MF','32MF','32MG','32MG','32MG',
43 '32MG','32MG','32MH','32MH','32MH','32MH','32MH','32MJ',
44 '32MJ','32MJ','32MJ','32MJ','32MK','32MK','32MK','32MK',
45 '32MK','32ML','32ML','32ML','32ML','32ML','32MM','32MM',
46 '32MM','32MM','32MM','32MN','32MN','32MN','32MN','32MN',
47 '32MP','32MP','32MP','32MP','32MP','32MV','32MV','32MV',
48 '32MV','32MV','32MW','32MW','32MW','32MW','32MW','32R2',
49 '32R2','32R2','32R2','32R2','32R3','32R3','32R3','32R3',
50 '32R3','32R4','32R4','32R4','32R4','32R4','32R5','32R5',
51 '32R5','32R5','32R5','32R6','32R6','32R6','32R6','32R6',
52 '32R7','32R7','32R7','32R7','32R7','32R8','32R8','32R8',
53 '32R8','32R8','32RA','32RA','32RA','32RA','32RA','32RB',
54 '32RB','32RB','32RB','32RB','32RC','32RC','32RC','32RC',
55 '32RC','32RD','32RD','32RD','32RD','32RD','32RE','32RE',
56 '32RE','32RE','32RE','32RF','32RF','32RF','32RF','32RF',
57 '32RG','32RG','32RG','32RG','32RG','32RH','32RH','32RH',
58 '32RH','32RH','32RJ','32RJ','32RJ','32RJ','32RJ','32RK',
59 '32RK','32RK','32RK','32RK','32RL','32RL','32RL','32RL',
60 '32RL','32RM','32RM','32RM','32RM','32RM','32RN','32RN',
61 '32RN','32RN','32RN','32RP','32RP','32RP','32RP','32RP',
62 '32RQ','32RQ','32RQ','32RQ','32RQ','32RW','32RW','32RW',
63 '32RW','32RW','341R','341R','341R','35R1','35R1','35R1',
64 '35R1','35R2','35R2','35R2','35R3','35R3','35R3','35R3',
65 '39Z1','4175','4175','4175','4175','4176','4176','4176',
66 '4176','4177','4177','4177','4177','4179','4179','4179',
67 '4179','41U1','41U1','41U1','41U1','41U2','41U2','41U2',
68 '41U2','41U3','41U3','41U3','41U3','41U4','41U4','41U4',
69 '41U4','41Z1','41Z1','41Z1','41Z1','4290','4290','4290',
70 '4290','4293','4293','4293','4293','42B7','42B7','42B7',
71 '42N7','42N7','42N7','42N7','4350','4350','4350','4351',
72 '4351','4351','4390','4390','4390','4390','4391','4391',
73 '4391','4391','43C9','43C9','43C9','43C9','44R1','44R1',
74 '44R1','44R1','46MM','46MM','46MM','46R1','46R1','46R1',
75 '46R2','46R2','46R2','46R2','489B','489B','48R1','48R1',
76 '48R3','48R3','5185','5185','5279','5279','5279','5297',
77 '5297','5297','521U','521U','521U','52R1','52R1','52R1',
78 '53R1','53R1','53R1','53R1','53R2','53R2','53R2','53R2',
79 '53R4','53R4','53R4','53R4','53R6','53R6','53R6','53R6',
80 '53R7','53R7','53R7','53R7','5480','5480','5481','5481',
81 '5482','5482','5501','5501','5501','5501','5501','5501',
82 '5501','5501','5501','5502','5502','5502','5502','5502',
83 '5502','5502','5502','5502','5502','5503','5503','5503',
84 '5503','5503','5503','5503','5503','5503','5503','55X6',
85 '55X6','55X6','55X6','560X','560X','560X','560X','561X',
86 '561X','561X','561X','56PP','56PP','56PP','56PP','62R2',
87 '62R2','65BT','65BT','65Z1','65Z1','65Z1','2R88','2R88',
88 '2S50','2S50','2S99','2S99','3E99','3E99','3E99','3E99',
89 '3EL1','3EL1','3EL1','3EL1'); -- Initialise it
90 BEGIN
91 for i in 1..array.count loop
92 for r_LRD_IORG IN (select * from LRDLicnse.LRD_IORG where IORG_TYP_DSC = 'BRANCH' and Record_status = 'A' and LGCY_IORG_ID = array(i)) loop
93 dbms_output.put_line(i, array(i), r_LRD_IORG.PS_ORG_ID);
94 end loop;
95 end loop;
96 END
97 /
After trying to compile the code block and run it I get the following error messages.
Error starting at line : 1 in command -
DECLARE
type array_t is varray(692) of varchar2(6);
array array_t := array_t('0118','0118','01R1','01R1','01R2','01R2','01R4','01R4',
'01R5','01R5','01R7','01R7','03BB','03BB','03BB','03BB',
'03R3','03R4','03R8','0684','0684','0684','0685','0685',
'0685','06CN','06CN','06CN','06GG','06GG','0799','0799',
'079T','079T','079T','079T','07R1','07R1','07R1','07R1',
'07R3','07R3','07R3','07R3','07R5','07R5','07R5','07R5',
'07R6','07R6','07R6','07R6','07R7','07R7','07R7','07R7',
'0954','0954','0954','0956','0956','0956','0959','0959',
'0959','09ZZ','09ZZ','09ZZ','14R1','14R1','14R1','14R2',
'14R2','14R2','16C4','16C4','16C4','16R3','16R3','16R5',
'16R5','16R5','16R5','16R7','16R7','16R7','16U4','16U4',
'16U4','16U4','1850','1850','1851','1852','1899','20R1',
'20R1','20R2','20R2','2181','2181','2181','2181','2182',
'2182','2182','2182','2184','2184','2184','2184','2186',
'2186','2186','2186','23C1','23C1','23C1','23C1','23C1',
'23C1','23C2','23C2','23C2','23C2','23C2','23C2','23FF',
'23FF','23FF','23FF','23R1','23R1','23R1','23R1','23R1',
'23R1','23R1','23R1','23R2','23R2','23R2','23R2','23R2',
'23R2','23R2','23R2','23R3','23R3','23R3','23R3','23R3',
'23R3','23R3','23R3','23R5','23R5','23R5','23R5','23R5',
'23R5','23R5','23R5','23R6','23R6','23R6','23R6','23R6',
'23R6','23R6','23R6','23R7','23R7','23R7','23R7','23R8',
'23R8','23R8','23R8','23R8','23R8','23R8','23VP','23VP',
'23VP','23VP','23X1','23X1','23X1','23X1','23X2','23X2',
'23X2','23X2','23X3','23X3','23X3','23X3','23X4','23X4',
'23X4','23X4','23XX','23XX','23XX','23XX','24MA','24MA',
'24MA','24MB','24MB','24MB','24MG','24MG','24MQ','24MQ',
'24MQ','24MR','24MR','24MR','26R2','26R2','26R4','26R4',
'299T','299T','299T','29R1','29R1','29R1','29R2','29R2',
'29R2','29R3','29R3','29R4','29R4','29R4','3071','3071',
'3071','3071','3072','3072','3072','3072','3075','3075',
'3075','3075','3083','3083','3083','3083','3084','3084',
'3084','3084','30XB','30XB','30XB','30XB','32M2','32M2',
'32M2','32M2','32M2','32M3','32M3','32M3','32M3','32M3',
'32M4','32M4','32M4','32M4','32M4','32M5','32M5','32M5',
'32M5','32M5','32M6','32M6','32M6','32M6','32M6','32M7',
'32M7','32M7','32M7','32M7','32M8','32M8','32M8','32M8',
'32M8','32MB','32MB','32MB','32MB','32MB','32MD','32MD',
'32MD','32MD','32MD','32ME','32ME','32ME','32ME','32ME',
'32MF','32MF','32MF','32MF','32MF','32MG','32MG','32MG',
'32MG','32MG','32MH','32MH','32MH','32MH','32MH','32MJ',
'32MJ','32MJ','32MJ','32MJ','32MK','32MK','32MK','32MK',
'32MK','32ML','32ML','32ML','32ML','32ML','32MM','32MM',
'32MM','32MM','32MM','32MN','32MN','32MN','32MN','32MN',
'32MP','32MP','32MP','32MP','32MP','32MV','32MV','32MV',
'32MV','32MV','32MW','32MW','32MW','32MW','32MW','32R2',
'32R2','32R2','32R2','32R2','32R3','32R3','32R3','32R3',
'32R3','32R4','32R4','32R4','32R4','32R4','32R5','32R5',
'32R5','32R5','32R5','32R6','32R6','32R6','32R6','32R6',
'32R7','32R7','32R7','32R7','32R7','32R8','32R8','32R8',
'32R8','32R8','32RA','32RA','32RA','32RA','32RA','32RB',
'32RB','32RB','32RB','32RB','32RC','32RC','32RC','32RC',
'32RC','32RD','32RD','32RD','32RD','32RD','32RE','32RE',
'32RE','32RE','32RE','32RF','32RF','32RF','32RF','32RF',
'32RG','32RG','32RG','32RG','32RG','32RH','32RH','32RH',
'32RH','32RH','32RJ','32RJ','32RJ','32RJ','32RJ','32RK',
'32RK','32RK','32RK','32RK','32RL','32RL','32RL','32RL',
'32RL','32RM','32RM','32RM','32RM','32RM','32RN','32RN',
'32RN','32RN','32RN','32RP','32RP','32RP','32RP','32RP',
'32RQ','32RQ','32RQ','32RQ','32RQ','32RW','32RW','32RW',
'32RW','32RW','341R','341R','341R','35R1','35R1','35R1',
'35R1','35R2','35R2','35R2','35R3','35R3','35R3','35R3',
'39Z1','4175','4175','4175','4175','4176','4176','4176',
'4176','4177','4177','4177','4177','4179','4179','4179',
'4179','41U1','41U1','41U1','41U1','41U2','41U2','41U2',
'41U2','41U3','41U3','41U3','41U3','41U4','41U4','41U4',
'41U4','41Z1','41Z1','41Z1','41Z1','4290','4290','4290',
'4290','4293','4293','4293','4293','42B7','42B7','42B7',
'42N7','42N7','42N7','42N7','4350','4350','4350','4351',
'4351','4351','4390','4390','4390','4390','4391','4391',
'4391','4391','43C9','43C9','43C9','43C9','44R1','44R1',
'44R1','44R1','46MM','46MM','46MM','46R1','46R1','46R1',
'46R2','46R2','46R2','46R2','489B','489B','48R1','48R1',
'48R3','48R3','5185','5185','5279','5279','5279','5297',
'5297','5297','521U','521U','521U','52R1','52R1','52R1',
'53R1','53R1','53R1','53R1','53R2','53R2','53R2','53R2',
'53R4','53R4','53R4','53R4','53R6','53R6','53R6','53R6',
'53R7','53R7','53R7','53R7','5480','5480','5481','5481',
'5482','5482','5501','5501','5501','5501','5501','5501',
'5501','5501','5501','5502','5502','5502','5502','5502',
'5502','5502','5502','5502','5502','5503','5503','5503',
'5503','5503','5503','5503','5503','5503','5503','55X6',
'55X6','55X6','55X6','560X','560X','560X','560X','561X',
'561X','561X','561X','56PP','56PP','56PP','56PP','62R2',
'62R2','65BT','65BT','65Z1','65Z1','65Z1','2R88','2R88',
'2S50','2S50','2S99','2S99','3E99','3E99','3E99','3E99',
'3EL1','3EL1','3EL1','3EL1'); -- Initialise it
BEGIN
for i in 1..array.count loop
for r_LRD_IORG IN (select * from LRDLicnse.LRD_IORG where IORG_TYP_DSC = 'BRANCH' and Record_status = 'A' and LGCY_IORG_ID = array(i)) loop
dbms_output.put_line(i, array(i), r_LRD_IORG.PS_ORG_ID);
end loop;
end loop;
END
Error report -
ORA-06550: line 97, column 0:
PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:
; <an identifier> <a double-quoted delimited-identifier>
The symbol ";" was substituted for "end-of-file" to continue.
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
If you could help getting this pl/sql block up and running I would be much appreciative about it.
Thank you,
Steve Brooks
Obvious error, which causes this exception to be thrown: The END command, before the slash on a line by itself, must be ended in semicolon. Like this:
........
end loop;
END; -- notice the semicolon
/
After you fix this, you will run into another error. put_line takes only one argument, not three. If you want a string including those bits of data, and commas and spaces, you will have to build it using single-quotes for the parts that are hard-coded (comma, space) and the concatenation operator. The more common way would be something like this:
........
dbms_output.put_line('i = ' || i || ', array(i) = ' || array(i) ||
', PS_ORG_ID = ' || r.LRD_IORG.PS_ORG_ID);