Hi all
According to the documentation Tags should be imported as a single string formated like: "@:<total number of items in the list>:<char count>:<char
text>". (e.g. @:3:15:Status\Deployed:22:Environment\Production:20:Class\Windows Server)
In our CMDB Status, Environment and Class are three different fields. Status and Environment might be NULL, Class not.
- How do you create the string in SQL?
- Is there an easy way to import Tags? Maybe without the numbers?
- Do you suggest something other than Tags for Status, Class and Environment?
Regards
-Luca.
So far I did receive an SQL-statement from a colleague. The SQL-statement does work but it looks rather complicated to adapt to new fields or values.
SELECT CASE
WHEN L1 IS NULL THEN
CASE WHEN L2 IS NULL THEN
'@:1'!!':'!! L3!!':CLASS\'!!STRIP(SYS_CLASS_NAME_DV)
ELSE '@:2'!!':'!! L2!!':ENVIRONMENT\'!!STRIP(U_ENVIRONMENT)
!!':'!! L3!!':CLASS\'!!STRIP(SYS_CLASS_NAME_DV)
END
WHEN L2 IS NULL THEN
'@:2'!!':'!! L1!!':STATUS\'!!STRIP(U_SERVER_STATUS_DV)
!!':'!! L3!!':CLASS\'!!STRIP(SYS_CLASS_NAME_DV)
ELSE '@:3'!!':'!! L1!!':STATUS\'!!STRIP(U_SERVER_STATUS_DV)
!!':'!! L2!!':ENVIRONMENT\'!!STRIP(U_ENVIRONMENT)
!!':'!! L3!!':CLASS\'!!STRIP(SYS_CLASS_NAME_DV)
END
FROM ( SELECT LENGTH(U_SERVER_STATUS_DV)+7 AS L1 ,
LENGTH(U_ENVIRONMENT)+12 AS L2,
LENGTH(SYS_CLASS_NAME_DV)+6 AS L3,
U_SERVER_STATUS_DV ,
U_ENVIRONMENT ,
SYS_CLASS_NAME_DV
FROM SNOW.S_CMDB_CI_SERVER
WHERE CURRENT TIMESTAMP BETWEEN VAL_FROM AND VAL_TILL)