Oracle determines whether a table or view exists, if no more methods are created

Source: Internet
Author: User

Determine if the table exists, if it does not exist, and then create:

declare tableexist number;
Begin
Select COUNT (1) into the tableexist from User_tables where Table_name=upper (' onecallprtcp ');
If tableexist = 0 Then
Execute immediate
' CREATE TABLE onecallprtcp (
Onecallprtcpid NCHAR () not NULL,
Gisprocessid NCHAR () not NULL,
Ticketid NCHAR () not NULL,
Ticketnumber VARCHAR2 (255) Not NULL,
The Code VARCHAR2 is not NULL,
Status VARCHAR2 (255) NULL,
CommandText VARCHAR2 (255) Not NULL,
Dtpositiveresponse DATE not NULL,
Useridpositiveresponse CHAR (=) NULL,
ResultCode VARCHAR2 (m) NULL,
Resultstatus VARCHAR2 (255) NULL,
Resulttext VARCHAR2 (255) NULL,
Isprok CHAR (1) Not NULL,
Stagename VARCHAR2 (m) not NULL,
Membercode VARCHAR2 (m) NULL,
Constraint ONECALLPRTCP_PK primary KEY (Onecallprtcpid)) ';
End If;
End

Determine if the view exists, if it does not exist, and then create:

Declare viewexist number;
Begin
Select COUNT (1) into viewexist from user_views where view_name= ' report_appointmentsbylocators ';
If vie Wexist=0 then

Execute immediate
' CREATE VIEW report_appointmentsbylocators
As
SELECT Appointmentid, StartDateTime, EndDateTime, grid, locator,
Meetingaddress, Contactnumber, company, Contacts, Reasonforappointment,
Dtfirstcall, Dtsecondcall,customeranswerfirstcall, Customeranswersecondcall,
Ismeetonsite, Dtlastmodified, Appointmentstatus, Islocatorarriveonsite,
Dtcompletedat,dtlocatorarriveonsite, Rescheduledon, Rescheduledat, isrescheduled, city
from appointment ';
End If;
End

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.