bluebunny72 icon

UET Create Script

bluebunny72 | PRO | 02/03/17 03:19:09 PM UTC | 0 ⭐ | 480 👁️ | Never ⏰ | []
SQL |

4.28 KB

|

None

|

0 👍

/

0 👎

--**********Check if UET field already exists
IF NOT EXISTS(SELECT TOP 1 1 FROM [dbo].[user_fld] WHERE [fld_name] = 'Uf_ILC_Timesheet')
 
    --Create the UET field
    INSERT INTO [dbo].[user_fld] ([fld_name],[fld_data_type],[fld_initial],[fld_decimals],[fld_desc],[fld_UDT],[fld_prec])
    VALUES ('Uf_ILC_Timesheet','tinyint','0',NULL,'Boolean flag indicating if entry came via timesheet','ILC_BooleanType',NULL)
ELSE
    --Update the UET field
    UPDATE [dbo].[user_fld] SET [fld_data_type] = 'tinyint', [fld_initial] = '0', [fld_decimals] = NULL, [fld_desc] = 'Boolean flag indicating if entry came via timesheet'
    ,[fld_UDT] = 'ILC_BooleanType', [fld_prec] = NULL WHERE [fld_name] = 'Uf_ILC_Timesheet'
 
 
 
 
--**********UET Classes
 
--Check if UET Class already exists
IF NOT EXISTS(SELECT TOP 1 1 FROM [dbo].[user_class] WHERE [class_name] = 'ILC_JobTran')
 
    --Create the UET class
    INSERT INTO [dbo].[user_class] ([class_name],[class_label],[class_desc])
    VALUES ('ILC_JobTran','ILC_JobTran',NULL)
 
ELSE
    PRINT('UET Class already exists')
 
--Check if UET Class already exists
IF NOT EXISTS(SELECT TOP 1 1 FROM [dbo].[user_class] WHERE [class_name] = 'ILC_Projlabr')
 
    --Create the UET class
    INSERT INTO [dbo].[user_class] ([class_name],[class_label],[class_desc])
    VALUES ('ILC_Projlabr','Projlabr','Projlabr')
 
ELSE
    PRINT('UET Class already exists')
 
--Check if UET Class already exists
IF NOT EXISTS(SELECT TOP 1 1 FROM [dbo].[user_class] WHERE [class_name] = 'ILC_Projtran')
 
    --Create the UET class
    INSERT INTO [dbo].[user_class] ([class_name],[class_label],[class_desc])
    VALUES ('ILC_Projtran','ILC_Projtran',NULL)
 
ELSE
    PRINT('UET Class already exists')
 
 
 
 
--**********UET Class Field Relationship
 
--Check if UET Class Field relationship already exists
IF NOT EXISTS(SELECT TOP 1 1 FROM [dbo].[user_class_fld] WHERE [class_name] = 'ILC_JobTran' AND [fld_name] = 'Uf_ILC_Timesheet')
 
    --Create the UET Class Field relationship
    INSERT INTO [dbo].[user_class_fld] ([class_name],[fld_name])
    VALUES ('ILC_JobTran','Uf_ILC_Timesheet')
 
ELSE
    PRINT('UET Class-Field relationship already exists')
 
--Check if UET Class Field relationship already exists
IF NOT EXISTS(SELECT TOP 1 1 FROM [dbo].[user_class_fld] WHERE [class_name] = 'ILC_Projlabr' AND [fld_name] = 'Uf_ILC_Timesheet')
 
    --Create the UET Class Field relationship
    INSERT INTO [dbo].[user_class_fld] ([class_name],[fld_name])
    VALUES ('ILC_Projlabr','Uf_ILC_Timesheet')
 
ELSE
    PRINT('UET Class-Field relationship already exists')
 
--Check if UET Class Field relationship already exists
IF NOT EXISTS(SELECT TOP 1 1 FROM [dbo].[user_class_fld] WHERE [class_name] = 'ILC_Projtran' AND [fld_name] = 'Uf_ILC_Timesheet')
 
    --Create the UET Class Field relationship
    INSERT INTO [dbo].[user_class_fld] ([class_name],[fld_name])
    VALUES ('ILC_Projtran','Uf_ILC_Timesheet')
 
ELSE
    PRINT('UET Class-Field relationship already exists')
 
 
 
 
--**********UET Table Class Relationship
 
--Check if UET Table Class relationship already exists
IF NOT EXISTS(SELECT TOP 1 1 FROM [dbo].[table_class] WHERE [TABLE_NAME] = 'jobtran' AND [class_name] = 'ILC_JobTran')
 
    --Create the UET Table Class relationship
    INSERT INTO [dbo].[table_class] ([TABLE_NAME],[class_name],[table_rule],[extend_all_recs],[active])
    VALUES ('jobtran','ILC_JobTran',NULL,0,1)
 
ELSE
    PRINT('UET Table-Class relationship already exists')
 
--Check if UET Table Class relationship already exists
IF NOT EXISTS(SELECT TOP 1 1 FROM [dbo].[table_class] WHERE [TABLE_NAME] = 'projlabr' AND [class_name] = 'ILC_Projlabr')
 
    --Create the UET Table Class relationship
    INSERT INTO [dbo].[table_class] ([TABLE_NAME],[class_name],[table_rule],[extend_all_recs],[active])
    VALUES ('projlabr','ILC_Projlabr',NULL,0,1)
 
ELSE
    PRINT('UET Table-Class relationship already exists')
 
--Check if UET Table Class relationship already exists
IF NOT EXISTS(SELECT TOP 1 1 FROM [dbo].[table_class] WHERE [TABLE_NAME] = 'Projtran' AND [class_name] = 'ILC_Projtran')
 
    --Create the UET Table Class relationship
    INSERT INTO [dbo].[table_class] ([TABLE_NAME],[class_name],[table_rule],[extend_all_recs],[active])
    VALUES ('Projtran','ILC_Projtran',NULL,0,1)
 
ELSE
    PRINT('UET Table-Class relationship already exists')
 
 
 
PRINT('Do NOT forget to Impact Schema via SyteLine form')

Comments