Oracle uses stored procedures to implement MySQL drop if exists

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.