Subject | Re: [firebird-support] How to drop a view only if it exists? |
---|---|
Author | unordained |
Post date | 2012-04-11T20:58:13Z |
---------- Original Message -----------
From: "kokok_kokok" <kokok_kokok@...>
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
From: "kokok_kokok" <kokok_kokok@...>
> Using FB 2.5, how can I drop a view only if it exists?------- End of Original Message -------
> There is something like DROP VIEW IF EXISTS..?
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