Friday 15 August 2014

table - Drop if exists in netezza -



table - Drop if exists in netezza -

i need command delete table if exists in netezza, that:

drop table if exists xxx;

i have searched , tried many didn't work, can help me here?

thanks help here.

there nil built-in, can create stored proc uses catalog views check if table exists before attempting drop it:

create or replace procedure maybe_drop(varchar(128)) returns boolean language nzplsql begin_proc declare oname alias $1; o record; begin select otype o ( select 'table' otype _v_table tablename = upper(oname) union select 'view' otype _v_view viewname = upper(oname) ) x; if found execute immediate 'drop '||o.otype||' '||oname; end if; end; end_proc;

table if-statement exists netezza

No comments:

Post a Comment