kokok wrote:

Using FB 2.5, how can I drop a view only if it exists? There is something like DROP VIEW IF EXISTS..?

unordained answers:

AFAIK, no such syntax. But if you're just looking for something you can generate & throw in an upgrade script, the following ugliness might suffice:

execute block as
 declare view_name varchar(40);
begin
 view_name = 'bob';
 if (exists(select * from RDB$VIEW_RELATIONS where lower(trim(rdb$view_relations.RDB$VIEW_NAME)) = lower(trim(:view_name)))) then
  execute statement 'drop view ' || :view_name;
end

-- or

execute block as
 declare view_name varchar(40);
begin
 view_name = 'bob';
 begin
  execute statement 'drop view ' || :view_name;
 when any do begin end
 end
end

Like this post? Share on: TwitterFacebookEmail


Related Articles


Author

Firebird Community

Published

Category

Gems from Firebird Support list

Tags