Subject Re: [firebird-support] How to drop a view only if it exists?
Author unordained
---------- Original Message -----------
From: "kokok_kokok" <kokok_kokok@...>
> Using FB 2.5, how can I drop a view only if it exists?
> There is something like DROP VIEW IF EXISTS..?
------- End of Original Message -------

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