Last active
May 10, 2016 14:30
Star
You must be signed in to star a gist
Firebird index creation.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- when recreating indexes, use `with autonomous transaction`: | |
-- http://stackoverflow.com/questions/12117206/how-do-i-make-a-repeatable-index-script/12121998#12121998 | |
/* NOTE: | |
If you screw up the `execute statement` part, then the error line/column is relative to the opening quote | |
of that statement (it has column zero and line one). | |
If you screw up the `execute block` part, then the error line/column is relative to the word execute | |
(it has column 1 and line 1). | |
*/ | |
set term !! ; | |
execute block as | |
begin | |
if ( | |
not exists ( | |
select 1 | |
from RDB$INDICES indices | |
where 1=1 | |
and upper(indices.RDB$INDEX_NAME) = upper('channels_endpoint_index') | |
) | |
) | |
then | |
execute statement 'create index channels_endpoint_index on channels (endpoint)'; | |
end | |
!! | |
set term ; !! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment