The
Following oralce stored Procedures Act like the drop if exists feature of MySQL.
code is as follows |
copy code |
--" Determines whether a table exists and deletes the table if it exists. Create or Replace procedure proc_dropifexists ( p_table in varchar2 br>) is v_count Number (a); begin sel ECT COUNT (*) into v_count user_tables & nbsp; WHERE table_name = UPPER (p_table); if v_count > 0 then execute immediate ' drop table ' | | p_table | | ' Purge '; End if; End proc_dropifexists; |
The
has a minor problem when calling a stored procedure. Execute the above stored procedure in Plsql, many articles on the web are
with exec proc_dropifexists (' table name ');
or execute PROC_ Dropifexists (' table name ');
to execute. But I always report the ' Ora 00900 ' invalid statement error when executing the above statement, I do not know why.
: call proc_dropifexists (' table name ') and execution succeeded.