删除索引,然后在创建返回索引后插入语句,在过程中不起作用

时间:2018-01-30 03:47:44

标签: oracle stored-procedures plsql

create or replace PROCEDURE INSSEL_TBL_TEST AS
BEGIN
DECLARE
  TBL varchar2(50):= 'ESSCSHSTMTBPTEST2';
  tblNm varchar2(50);

CURSOR tableIndexList IS 
(select ES_INDEX_NM,ES_TBL_NM,ES_CRT_INDEX_STMT,ES_DROP_INDEX_STMT FROM ESSP.ESSINDEXCONF WHERE ES_TBL_NM = TBL);

BEGIN
  FOR drpInd in tableIndexList LOOP
    EXECUTE IMMEDIATE 'drpInd.ES_DROP_INDEX_STMT';
    COMMIT;
  END LOOP;

  execute immediate ('insert into ESSPREP.' ||UPPER(TBL)|| ' select * from ESSP.' ||UPPER(TBL)|| '@ESSPREPLINKESSP');

  FOR drpInd in tableIndexList Loop
    execute immediate 'drpInd.ES_CRT_INDEX_STMT';
    COMMIT;
  END LOOP;
END;
END;

上面是我在insert语句之前删除索引的过程,之后创建了index.But它不起作用,任何人都可以帮忙吗?

2 个答案:

答案 0 :(得分:1)

<?xml version="1.0" encoding="UTF-8"?>
<plannerBenchmark>
    <benchmarkDirectory>local/data/opnext</benchmarkDirectory>
    <parallelBenchmarkCount>AUTO</parallelBenchmarkCount>

    <inheritedSolverBenchmark>
        <problemBenchmarks>
            <xStreamAnnotatedClass>org.optaplanner.examples.opnext.domain.Solution</xStreamAnnotatedClass>

            <inputSolutionFile>data/opnext/solved/96time-60action.xml</inputSolutionFile>
            <inputSolutionFile>data/opnext/solved/96time-240action.xml</inputSolutionFile>
            <inputSolutionFile>data/opnext/solved/96time-400action.xml</inputSolutionFile>
            <inputSolutionFile>data/opnext/solved/2880time-40action.xml</inputSolutionFile>
            <inputSolutionFile>data/opnext/solved/2880time-240action.xml</inputSolutionFile>
            <inputSolutionFile>data/opnext/solved/2880time-480action.xml</inputSolutionFile>

            <problemStatisticType>BEST_SCORE</problemStatisticType>
            <problemStatisticType>STEP_SCORE</problemStatisticType>
            <problemStatisticType>SCORE_CALCULATION_SPEED</problemStatisticType>
            <problemStatisticType>BEST_SOLUTION_MUTATION</problemStatisticType>
            <problemStatisticType>MOVE_COUNT_PER_STEP</problemStatisticType>
            <problemStatisticType>MEMORY_USE</problemStatisticType>

            <singleStatisticType>CONSTRAINT_MATCH_TOTAL_BEST_SCORE</singleStatisticType>
            <singleStatisticType>CONSTRAINT_MATCH_TOTAL_STEP_SCORE</singleStatisticType>
            <singleStatisticType>PICKED_MOVE_TYPE_BEST_SCORE_DIFF</singleStatisticType>
            <singleStatisticType>PICKED_MOVE_TYPE_STEP_SCORE_DIFF</singleStatisticType>
        </problemBenchmarks>

        <solver>
            <solutionClass>org.optaplanner.examples.opnext.domain.Solution</solutionClass>
            <entityClass>org.optaplanner.examples.opnext.domain.Action</entityClass>
            <scoreDirectorFactory>
                <scoreDrl>org/optaplanner/examples/opnext/solver/iskoTaskAssigningScoreRules.drl</scoreDrl>
            </scoreDirectorFactory>
            <termination>
                <minutesSpentLimit>15</minutesSpentLimit>
            </termination>
            <constructionHeuristic>
                <constructionHeuristicType>FIRST_FIT_DECREASING</constructionHeuristicType>
            </constructionHeuristic>
            <localSearch>
                <unionMoveSelector>
                    <changeMoveSelector/>
                    <swapMoveSelector>
                        <filterClass>org.optaplanner.examples.opnext.solver.move.DifferentActionSwapMoveFilter</filterClass>
                    </swapMoveSelector>
                </unionMoveSelector>

                <acceptor>
                    <lateAcceptanceSize>600</lateAcceptanceSize>
                </acceptor>
                <forager>
                    <acceptedCountLimit>4</acceptedCountLimit>
                </forager>
            </localSearch>
        </solver>
    </inheritedSolverBenchmark>


    <solverBenchmark>
        <name>First Fit</name>
        <solver>
            <constructionHeuristic>
                <constructionHeuristicType>FIRST_FIT</constructionHeuristicType>
            </constructionHeuristic>
        </solver>
    </solverBenchmark>
    <solverBenchmark>
        <name>First Fit Decreasing</name>
        <solver>
            <constructionHeuristic>
                <constructionHeuristicType>FIRST_FIT_DECREASING</constructionHeuristicType>
            </constructionHeuristic>
        </solver>
    </solverBenchmark>

    <solverBenchmark>
        <name>Tabu Search</name>
        <solver>
            <constructionHeuristic>
                <constructionHeuristicType>FIRST_FIT_DECREASING</constructionHeuristicType>
            </constructionHeuristic>
            <localSearch>
                <unionMoveSelector>
                    <changeMoveSelector/>
                    <swapMoveSelector/>
                    <pillarChangeMoveSelector/>
                    <pillarSwapMoveSelector/>
                </unionMoveSelector>
                <acceptor>
                    <entityTabuSize>7</entityTabuSize>
                </acceptor>
                <forager>
                    <acceptedCountLimit>1000</acceptedCountLimit>
                </forager>
            </localSearch>
        </solver>
    </solverBenchmark>
    <solverBenchmark>
        <name>Simulated Annealing</name>
        <solver>
            <constructionHeuristic>
                <constructionHeuristicType>FIRST_FIT_DECREASING</constructionHeuristicType>
            </constructionHeuristic>
            <localSearch>
                <unionMoveSelector>
                    <changeMoveSelector/>
                    <swapMoveSelector/>
                    <pillarChangeMoveSelector/>
                    <pillarSwapMoveSelector/>
                </unionMoveSelector>
                <acceptor>
                    <simulatedAnnealingStartingTemperature>0hard/400soft</simulatedAnnealingStartingTemperature>
                </acceptor>
                <forager>
                    <acceptedCountLimit>4</acceptedCountLimit>
                </forager>
            </localSearch>
        </solver>
    </solverBenchmark>
    <solverBenchmark>
        <name>Late Acceptance</name>
        <solver>
            <constructionHeuristic>
                <constructionHeuristicType>FIRST_FIT_DECREASING</constructionHeuristicType>
            </constructionHeuristic>
            <localSearch>
                <unionMoveSelector>
                    <changeMoveSelector/>
                    <swapMoveSelector/>
                    <pillarChangeMoveSelector/>
                    <pillarSwapMoveSelector/>
                </unionMoveSelector>
                <acceptor>
                    <lateAcceptanceSize>400</lateAcceptanceSize>
                </acceptor>
                <forager>
                    <acceptedCountLimit>4</acceptedCountLimit>
                </forager>
            </localSearch>
        </solver>
    </solverBenchmark>
</plannerBenchmark>

错了。您尝试使用光标中的值,但事实上您正在使用字符串文字。要修复此错误,请删除引号:

EXECUTE IMMEDIATE 'drpInd.ES_DROP_INDEX_STMT';

另外,正如@XING所说,提交在这里是多余的。

答案 1 :(得分:-1)

您的syntax不正确。见下文:

create or replace PROCEDURE INSSEL_TBL_TEST 
AS

  TBL varchar2(50):= 'ESSCSHSTMTBPTEST2';
  tblNm varchar2(50);

CURSOR tableIndexList IS 
(select ES_INDEX_NM,ES_TBL_NM,ES_CRT_INDEX_STMT,ES_DROP_INDEX_STMT FROM ESSP.ESSINDEXCONF WHERE ES_TBL_NM = TBL);

BEGIN

  FOR drpInd in tableIndexList LOOP
    EXECUTE IMMEDIATE drpInd.ES_DROP_INDEX_STMT;
    --COMMIT;-- DROP is a DDL hence no need for COMMIT
  END LOOP;

  execute immediate 'insert into ESSPREP.' ||UPPER(TBL)|| ' select * from ESSP.' ||UPPER(TBL)|| '@ESSPREPLINKESSP';

  FOR drpInd in tableIndexList Loop
    execute immediate drpInd.ES_CRT_INDEX_STMT;
  END LOOP;
END;