In Oracle, the stored procedure of table DROP and table CREATE is determined.

Source: Internet
Author: User
CREATEORREPLACEPROCEDUREPD_GENERATE_HELP_LAST_TABLESIS -- generate a local data table for the view of vw_last_xxx generated from sqlserver

Create or replace procedure PD_GENERATE_HELP_LAST_TABLES IS -- generate a local data table for the view of vw_last_xxx generated from sqlserver

Homepage → Database Technology

Background:

Read News

In Oracle, the stored procedure of table DROP and table CREATE is determined.

[Date:] Source: Linux community Author: Linux [Font:]

Create or replace procedure PD_GENERATE_HELP_LAST_TABLES IS
-- Generate a local data table for the view vw_last_xxx generated from sqlserver
TabNocount NUMBER;
V_ SQL VARCHAR2 (200 );

BEGIN
-- Judge the table dat_help_last_scqy1)
SELECT count (*) INTO tabNocount FROM user_tables WHERE table_name = 'dat _ HELP_LAST_SCQY1 ';
IF tabNocount> 0 THEN
Dbms_output.put_line ('drop table dat_help_last_scqy1 ');
V_ SQL: = 'drop TABLE DAT_HELP_LAST_SCQY1 ';
Execute immediate v_ SQL;
End if;
Dbms_output.put_line ('create table dat_help_last_scqy1 ');
V_ SQL: = 'create TABLE DAT_HELP_LAST_SCQY1 AS SELECT * FROM VW_LAST_SCQY1 ';
Execute immediate v_ SQL;
-- Judge the table dat_help_last_scqy2 (monthly report of refined oil production)

SELECT count (*) INTO tabNocount FROM user_tables WHERE table_name = 'dat _ HELP_LAST_SCQY2 ';
IF tabNocount> 0 THEN
Dbms_output.put_line ('drop table dat_help_last_scqy2 ');
V_ SQL: = 'drop TABLE DAT_HELP_LAST_SCQY2 ';
Execute immediate v_ SQL;
End if;
Dbms_output.put_line ('create talbe dat_help_last_scqy2 ');
V_ SQL: = 'create TABLE DAT_HELP_LAST_SCQY2 AS SELECT * FROM VW_LAST_SCQY2 ';
Execute immediate v_ SQL;
-- Judge the table dat_help_last_shsndybb (Energy scheduling Monthly Report)
SELECT count (*) INTO tabNocount FROM user_tables WHERE table_name = 'dat _ HELP_LAST_SHSNDYBB ';
IF tabNocount> 0 THEN
Dbms_output.put_line ('drop table dat_help_last_shsndybb ');
V_ SQL: = 'drop TABLE DAT_HELP_LAST_SHSNDYBB ';
Execute immediate v_ SQL;
End if;
Dbms_output.put_line ('create table dat_help_last_shsndybb ');
V_ SQL: = 'create TABLE dat_help_last_shsndybb AS SELECT * FROM vw_last_shsndybb ';
Execute immediate v_ SQL;
END PD_GENERATE_HELP_LAST_TABLES;

Test

Begin
-- Call the procedure
Pd_generate_help_last_tables;
End;

If ORA-01031: insufficient Permissions
ORA-06512: In "SYSTEM. CCCCCC", line 6
ORA-06512: In line 1

The following authorization statement is executed:

Grant create table to distribute DC;
Grant resource to your DC;
Grant create procedure to your DC;

  • 0
  • How Does Oracle determine whether a temporary table exists?

    Oracle client connection bug

    Oracle tutorial

    Image Information

    View All comments in this article (0)

    Comments

    Latest Information

    Popular this week

    Introduction to Linux community-advertisement service-website map-help Info-contact us
    The articles published on this site (LinuxIDC) do not mean that they agree with the statement or description. They only provide more information and do not constitute any suggestions.


    Copyright©2006-2011 Linux community All rights reserved Zhejiang ICP backup No. 06018118

    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.