IF (EXISTS(Select * from sys.systable where LCase(table_name) = LCase('v_Tasks')))
THEN Drop view v_Tasks
END IF

GO

create view DBA.v_Tasks
  as select TaskID=Tasks.id,
    Active=Tasks.active,
    SourceID=Source.id,
    SourceName=Source.name,
    SourceDesc=Source.description,
    SourceStatus=(select Statuses.name from DBA.Statuses where Statuses.id = Tasks.source_status),
    SourceConnStatus=(select Statuses.name from DBA.Statuses where Statuses.id = Tasks.source_conn_status),
    SourceHandleID=SHandle.id,
    SorceHandle=SHandle.name,
    SourceDriver=SHandle.Driver,
    DestID=Dest.id,
    DestName=Dest.name,
    DestDesc=Dest.description,
    DestStatus=(select Statuses.name from DBA.Statuses where Statuses.id = Tasks.dest_status),
    DestConnStatus=(select Statuses.name from DBA.Statuses where Statuses.id = Tasks.dest_conn_status),
    DestHandleID=DHandle.id,
    DestHandle=DHandle.name,
    DestDriver=DHandle.Driver,
    Interval=Tasks.interval,
    NextRun=Tasks.next_run from
    DBA.Tasks,
    DBA.Objects as Source,
    DBA.Objects as Dest,
    DBA.Handles as SHandle,
    DBA.Handles as DHandle where
    Source.id = Tasks.source_id and
    Dest.id = Tasks.dest_id and
    SHandle.id = Source.handle_id and
    DHandle.id = Dest.handle_id order by
    Active desc,NextRun asc
-- [v.1 20.Feb.2008] - Yanko, created
-- [v.2 April.2008] - gnikolov, added columns: SourceStatus, SourceConnStatus, DestStatus, DestConnStatus

GO

IF (EXISTS(Select * from sys.systable where LCase(table_name) = LCase('v_Registry')))
THEN Drop view v_Registry
END IF

GO

create view
  dba.v_Registry
  as select Registers.Name as Register,Registry.Value,Registry.Owner,
    Registers.Description,Registers.IsUnique,Registers.N from
    DBA.Registers,DBA.Registry where
    Registers.N = Registry.Register
-- [v.1 04.Mar.2008] - Kopirano ot Riscont
