|
Re: Can't Create Index With An If Statement [message #360156 is a reply to message #360155] |
Wed, 19 November 2008 19:30 |
Bill B
Messages: 1971 Registered: December 2004
|
Senior Member |
|
|
DECLARE
c_Count NUMBER;
BEGIN
SELECT COUNT(*) INTO c_Count
FROM DBA_INDEXES
WHERE TABLE_NAME = 'SOME_TABLE_NAME'
AND INDEX_NAME = 'SOME_INDEX_NAME'
AND OWNER = 'SOME_OWNER'
AND TABLE_OWNER = 'SOME_OWNER';
IF c_Count = 0 THEN
execute immediate 'CREATE INDEX SOME_OWNER.SOME_INDEX ON SOME_OWNER.SOME_TABLE (SOME_KEY)';
END IF;
END;
|
|
|
|
|