PLS-00103: Encountered the symbol "SELECT" when expecting one of the following:
( - + mod not null others <an identifier>
<a double-quoted delimited-identifier> <a bind variable> avg
count current exists max min prior sql stddev sum variance
execute forall time timestamp interval date
<a string literal with character set specification>
<a number> <a single-quoted SQL string>
PLS-00103: Encountered the symbol "FROM" when expecting one of the following:
; return returning and or
If I comment out the long insert statement, it compiles fine. If I run the insert statement separately, it also works fine. When I include it in the PROC, I have tried every imaginable variance, but am constantly getting this error or one similar. I have bolded the actual INSERT statement and underlined the SELECT and FROM words the 2 errors were pointing to. When I tested the INSERT statement separately, I used the literal to_date('09/27/2007/) in the place of CUR_PERIOD. I hope someone has some ideas on this.
CREATE OR REPLACE PROCEDURE tstINS_RATE_ROUTE_RECORDS_PROC (GET_CUR_PERIOD IN DATE) IS
-- Inserts records into RATE_ROUTE from the month
-- end reports and marks them with XXs if there are any errors.
CUR_PERIOD DATE;
BEGIN
CUR_PERIOD := GET_CUR_PERIOD;
Insert into RATE_ROUTE (
CVBI_KEY
, CV_KEY
, VS_KEY
, BILLING_ACCOUNT_ID
, BAN
, CKT
, VENDOR_ID
, SRVC_TYP
, NEW_IND
, ALOC
, ZLOC
, MASTER
, OCN
, ST_CD
, PERIOD
, MDFY_DT )
(
Select
C.CVBI_KEY
, C.CONDENSED_EC_CIRCUIT || C.VENDOR_ID
, decode( c.send_lca, 'YES', C.VENDOR_ID || 'XX' , C.VENDOR_ID || SUBSTR(C.ZLOC, 5, 2) )
, CR.BILLING_ACCOUNT_ID
, CR.BAN
, C.CONDENSED_EC_CIRCUIT
, C.VENDOR_ID
, C.CIRCUIT_TYPE
, CT1.ACTIVITY_CD
, decode( c.send_lca , 'YES', 'XXXXXXXX', c.aloc )
, decode( c.send_lca , 'YES', 'XXXXXXXX', c.zloc )
, decode( c.send_lca , 'YES', 'XXXXXXXX-XXXXXXXX', NVL(AZ.MASTER_ROUTE_NAME, AZ.REVERSED ))
, decode( c.send_lca , 'YES', 'XXX',
(decode( c.vendor_id, 372, 'BST'
, 375, 'VER'
, 143, 'AME'
, 1032, 'ALT'
, 1713, 'SWB'
, 2696, 'FMT'
, 32, 'RHT'
, 17, 'SPR'
, 1712, 'CBT'
, 471, 'CTE'
, 374, 'SPC'
, 2353, 'NOS'
, 1112, 'XSP'
, 18, 'IFN'
, 543, 'TTC'
, 3792, 'CTC'
, 1912, 'SMT'
, 3433, 'CNT'
, 390, 'SCT'
, 148, 'HGT'
, 3572, 'BLT'
, 1853, 'PMN'
, 40, 'TWC'
, 371, 'ATT'
, 513, 'MCI'
, 712, 'HTC'
, 13, 'DUN'
, 29, 'PTC'
, 1212, 'FRC'
, 30, 'QWE'
, 1893, 'TEL'
, 410, 'CIT'
, 332, 'COC'
, 689, 'ALM'
, 1532, 'UNT'
, 678, 'SKY'
, 'XXX' )
))
, decode( c.send_lca, 'YES', 'XX', SUBSTR(C.ZLOC,5,2) )
, CUR_PERIOD
, (SELECT TO_CHAR(SYSDATE) FROM DUAL)
FROM
rpt_ds1_cnt_cat c
, cogs_resource cr
, cogs_t1activity ct1
, rpt_ds1_aloc_zloc_reverse_vw az
where (C.CVBI_KEY = CR.CVBI_KEY (+)
and CR.PERIOD = CUR_PERIOD)
AND (C.CVBI_KEY = CT1.CVBI_KEY (+)
and CT1.PERIOD = CUR_PERIOD)
and (az.master_route_name=c.aloc||'-'||c.zloc OR az.reversed=c.aloc||'-'||c.zloc)
)
; END; -- INS_RATE_ROUTE_RECORDS_PROC