PLS-00103:在遇到以下其中一项时遇到符号“(”:<an identifier =“”> <a double-quoted="" delimited-identifier=""> LONG_

时间:2017-01-11 15:17:47

标签: oracle plsql oracle10g

When I try to run the below query I get the following error:

ERROR at line 6:

ORA-06550: line 6, column 30: PLS-00103: Encountered the symbol "(" when expecting one of the following: LONG_ double ref char time timestamp interval date binary national character nchar

DECLARE
thisdb int;
maxDB int;
execStatement VARCHAR2 (120);
execStatement2 VARCHAR2 (120);
TYPE databaseIDs IS TABLE OF (EXECUTION_ID RAW (32));


BEGIN
INSERT INTO databaseIDs (EXECUTION_ID)
              SELECT distinct jhist.EXECUTION_ID
                FROM sysman.MGMT_JOB_HISTORY jhist, sysman.MGMT_JOB job
                WHERE jhist.job_id=job.job_id and
                 job.job_owner='admin'
                 and jhist.step_status not in (1,5,17)
                 and start_time > (sysdate -1);

INSERT INTO databaseIDs (EXECUTION_ID)
              SELECT distinct log_ID
                FROM all_scheduler_job_log
                WHERE owner = 'admin' 
              AND status <> 'SUCCEEDED'
                AND log_date > (sysdate -1);


maxDB := select max(EXECUTION_ID) from databaseIDs;
thisdb := select min(EXECUTION_ID) from databaseIDs;

WHILE thisdb <= maxDB 
LOOP
maxDB >= thisdb
END LOOP;



BEGIN
                            execStatement := (Select '
INSERT INTO TEST.JOB_FAILURES
              SELECT distinct jhist.EXECUTION_ID,job_owner,job_name,
                           DECODE(step_status,
                 1, ''SCHEDULED'',
                 2, ''RUNNING'',
                 3, ''FAILED INIT'',
                 4, ''FAILED'',
                 5, ''SUCCEEDED'',
                 6, ''SUSPENDED'',
                 7, ''AGENT DOWN'',
                 8, ''STOPPED'',
                 9, ''SUSPENDED/LOCK'',
                 10, ''SUSPENDED/EVENT'',
                 11, ''SUSPENDED/BLACKOUT'',
                 12, ''STOP PENDING'',
                 13, ''SUSPEND PENDING'',
                 14, ''INACTIVE'',
                 15, ''QUEUED'',
                 16, ''FAILED/RETRIED'',
                 17, ''WAITING'',
                 18, ''SKIPPED'', step_status) AS STATUS,
                 cast(end_time AS timestamp) AS RUNDATE
                FROM sysman.MGMT_JOB_HISTORY jhist, sysman.MGMT_JOB job
                WHERE jhist.job_id=job.job_id and
                 job.job_owner='admin'
                 and jhist.step_status not in (1,5,17)
                 and start_time > (sysdate -1)
                           and jhist.EXECUTION_ID = '' + EXECUTION_ID + ''
WHERE NOT EXISTS (        SELECT distinct jhist.EXECUTION_ID
                FROM sysman.MGMT_JOB_HISTORY jhist, sysman.MGMT_JOB job
                WHERE jhist.job_id=job.job_id and
                 job.job_owner='DBadmin'
                 and jhist.step_status not in (1,5,17)
                 and start_time > (sysdate -1)
                           and jhist.EXECUTION_ID = '' + EXECUTION_ID + '';'from databaseIDs  where EXECUTION_ID = thisdb);
                           --print execStatement
                           exec(execStatement)

                           execStatement2 := (Select '
INSERT INTO TEST.JOB_FAILURES
        SELECT distinct owner,job_name,status, cast(log_date AS timestamp) as column1
                FROM all_scheduler_job_log
                WHERE
                 owner = 'admin' and
                 status <> 'SUCCEEDED'
                 and log_date > (sysdate -1)
                           and log_ID  = '' + EXECUTION_ID + ''
WHERE NOT EXISTS (  SELECT distinct log_ID
                FROM all_scheduler_job_log
                WHERE
                 owner = 'admin' and
                 status <> 'SUCCEEDED'
                 and log_date > (sysdate -1)
                           and log_ID = '' + EXECUTION_ID + '';'from databaseIDs  where EXECUTION_ID = thisdb);
                           --print execStatement
                           exec(execStatement2)

        thisdb := (select min(EXECUTION_ID) from databaseIDs  where EXECUTION_ID > thisdb)
END;
/

What am I missing?

1 个答案:

答案 0 :(得分:2)

您正在尝试在Oracle中运行SQL Server或其他一些RDBMS的代码。语法不一样。例如,使用@来为变量名添加前缀不是Oracle PL / SQL语法的一部分。还有其他问题,例如各个命令应以分号结束。