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