user2428207
user2428207

Reputation: 825

Execute statement in right order

When executing this statement as script (f5)

DECLARE
  COUNT_INDEXES INTEGER;
BEGIN
  SELECT COUNT(*)
  INTO COUNT_INDEXES
  FROM USER_INDEXES
  WHERE INDEX_NAME = 'NAME1' ;

  IF COUNT_INDEXES > 0 THEN
    EXECUTE IMMEDIATE 'DROP INDEX NAME1';
  END IF;
END;

DECLARE
  COUNT_INDEXES INTEGER;
BEGIN
  SELECT COUNT(*)
  INTO COUNT_INDEXES
  FROM USER_INDEXES
  WHERE INDEX_NAME = 'NAME2' ;

  IF COUNT_INDEXES > 0 THEN
    EXECUTE IMMEDIATE 'DROP INDEX NAME2';
  END IF;
END;

I get an error message. But when I select the first one, execute it, then the second one and execute, it works flawlessly.

Is there a way to make this work when pressing f5?

Upvotes: 1

Views: 42

Answers (1)

David Aldridge
David Aldridge

Reputation: 52356

For future ref, please mention the actual error message and the program you are using.

I suspect that you are missing a forward slash "/" between the two statements though.

Upvotes: 2

Related Questions