Skip to content

Instantly share code, notes, and snippets.

@jpluimers
Last active May 10, 2016 14:30
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save jpluimers/a1de628f721c6b8e9a27367aa65658cf to your computer and use it in GitHub Desktop.
Firebird index creation.
-- 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