· 9 years ago · Feb 03, 2017, 04:20 PM
1--**********Check if UET field already exists
2IF NOT EXISTS(SELECT TOP 1 1 FROM [dbo].[user_fld] WHERE [fld_name] = 'Uf_ILC_InfoCard')
3
4 --Create the UET field
5 INSERT INTO [dbo].[user_fld] ([fld_name],[fld_data_type],[fld_initial],[fld_decimals],[fld_desc],[fld_UDT],[fld_prec])
6 VALUES ('Uf_ILC_InfoCard','nvarchar',NULL,NULL,'Master Control InfroCard field','ILC_InfoCardNumberType',30)
7ELSE
8 --Update the UET field
9 UPDATE [dbo].[user_fld] SET [fld_data_type] = 'nvarchar', [fld_initial] = NULL, [fld_decimals] = NULL, [fld_desc] = 'Master Control InfroCard field'
10 ,[fld_UDT] = 'ILC_InfoCardNumberType', [fld_prec] = 30 WHERE [fld_name] = 'Uf_ILC_InfoCard'
11
12
13
14
15--**********UET Classes
16
17--Check if UET Class already exists
18IF NOT EXISTS(SELECT TOP 1 1 FROM [dbo].[user_class] WHERE [class_name] = 'ILC_Item')
19
20 --Create the UET class
21 INSERT INTO [dbo].[user_class] ([class_name],[class_label],[class_desc])
22 VALUES ('ILC_Item','ILC_Item','Contains all UETs for item.')
23
24ELSE
25 PRINT('UET Class already exists')
26
27
28
29
30--**********UET Class Field Relationship
31
32--Check if UET Class Field relationship already exists
33IF NOT EXISTS(SELECT TOP 1 1 FROM [dbo].[user_class_fld] WHERE [class_name] = 'ILC_Item' AND [fld_name] = 'Uf_ILC_InfoCard')
34
35 --Create the UET Class Field relationship
36 INSERT INTO [dbo].[user_class_fld] ([class_name],[fld_name])
37 VALUES ('ILC_Item','Uf_ILC_InfoCard')
38
39ELSE
40 PRINT('UET Class-Field relationship already exists')
41
42
43
44
45--**********UET Table Class Relationship
46
47--Check if UET Table Class relationship already exists
48IF NOT EXISTS(SELECT TOP 1 1 FROM [dbo].[table_class] WHERE [table_name] = 'ILC_Item' AND [class_name] = 'ILC_Item')
49
50 --Create the UET Table Class relationship
51 INSERT INTO [dbo].[table_class] ([table_name],[class_name],[table_rule],[extend_all_recs],[active])
52 VALUES ('ILC_Item','ILC_Item',NULL,0,1)
53
54ELSE
55 PRINT('UET Table-Class relationship already exists')
56
57--Check if UET Table Class relationship already exists
58IF NOT EXISTS(SELECT TOP 1 1 FROM [dbo].[table_class] WHERE [table_name] = 'item' AND [class_name] = 'ILC_Item')
59
60 --Create the UET Table Class relationship
61 INSERT INTO [dbo].[table_class] ([table_name],[class_name],[table_rule],[extend_all_recs],[active])
62 VALUES ('item','ILC_Item',NULL,0,1)
63
64ELSE
65 PRINT('UET Table-Class relationship already exists')
66
67--Check if UET Table Class relationship already exists
68IF NOT EXISTS(SELECT TOP 1 1 FROM [dbo].[table_class] WHERE [table_name] = 'item_all' AND [class_name] = 'ILC_Item')
69
70 --Create the UET Table Class relationship
71 INSERT INTO [dbo].[table_class] ([table_name],[class_name],[table_rule],[extend_all_recs],[active])
72 VALUES ('item_all','ILC_Item',NULL,0,1)
73
74ELSE
75 PRINT('UET Table-Class relationship already exists')
76
77
78
79PRINT('Do NOT forget to Impact Schema via SyteLine form')