<%@ Language=VBScript %> PC-Machine Relationships

PC-Machine Relationships

PCs with relationships to shop floor machines

<% Dim strSQL, rs strSQL = "SELECT DISTINCT " & _ "pc.machineid AS pc_id, " & _ "pc.machinenumber AS hostname, " & _ "c.address AS ip, " & _ "eq.machineid AS machine_id, " & _ "eq.machinenumber AS machine_number, " & _ "v.vendor AS vendor, " & _ "m.modelnumber AS model " & _ "FROM machinerelationships mr " & _ "JOIN machines eq ON mr.machineid = eq.machineid " & _ "JOIN machines pc ON mr.related_machineid = pc.machineid " & _ "LEFT JOIN communications c ON pc.machineid = c.machineid AND c.isprimary = 1 AND c.comstypeid = 1 " & _ "LEFT JOIN models m ON eq.modelnumberid = m.modelnumberid " & _ "LEFT JOIN vendors v ON m.vendorid = v.vendorid " & _ "WHERE mr.isactive = 1 " & _ "AND pc.pctypeid IS NOT NULL " & _ "AND eq.machinenumber IS NOT NULL AND eq.machinenumber != '' " & _ "AND eq.machinenumber REGEXP '^[0-9]{4}$' " & _ "AND eq.machinenumber NOT IN ('0612', '0613', '0614', '0615') " & _ "AND (v.vendor IS NULL OR v.vendor != 'WJDT') " & _ "AND (m.modelnumber IS NULL OR m.modelnumber != 'TBD') " & _ "UNION " & _ "SELECT DISTINCT " & _ "pc.machineid AS pc_id, " & _ "pc.machinenumber AS hostname, " & _ "c.address AS ip, " & _ "dp.machineid AS machine_id, " & _ "dp.machinenumber AS machine_number, " & _ "v.vendor AS vendor, " & _ "m.modelnumber AS model " & _ "FROM machinerelationships dual_rel " & _ "JOIN relationshiptypes drt ON dual_rel.relationshiptypeid = drt.relationshiptypeid AND drt.relationshiptype = 'Dualpath' " & _ "JOIN machines dp ON dual_rel.related_machineid = dp.machineid " & _ "JOIN machinerelationships mr ON mr.machineid = dual_rel.machineid AND mr.isactive = 1 " & _ "JOIN relationshiptypes rt ON mr.relationshiptypeid = rt.relationshiptypeid AND rt.relationshiptype IN ('Controls', 'Controlled By') " & _ "JOIN machines pc ON mr.related_machineid = pc.machineid AND pc.pctypeid IS NOT NULL " & _ "LEFT JOIN communications c ON pc.machineid = c.machineid AND c.isprimary = 1 AND c.comstypeid = 1 " & _ "LEFT JOIN models m ON dp.modelnumberid = m.modelnumberid " & _ "LEFT JOIN vendors v ON m.vendorid = v.vendorid " & _ "WHERE dual_rel.isactive = 1 " & _ "AND dp.machinenumber IS NOT NULL AND dp.machinenumber != '' " & _ "AND dp.machinenumber REGEXP '^[0-9]{4}$' " & _ "AND dp.machinenumber NOT IN ('0612', '0613', '0614', '0615') " & _ "AND (v.vendor IS NULL OR v.vendor != 'WJDT') " & _ "AND (m.modelnumber IS NULL OR m.modelnumber != 'TBD') " & _ "ORDER BY machine_number" Set rs = objConn.Execute(strSQL) Dim rowCount rowCount = 0 Do While Not rs.EOF rowCount = rowCount + 1 %> <% rs.MoveNext Loop rs.Close Set rs = Nothing %>
Machine # Vendor Model PC Hostname PC IP
<%= Server.HTMLEncode(rs("machine_number") & "") %> <%= Server.HTMLEncode(rs("vendor") & "") %> <%= Server.HTMLEncode(rs("model") & "") %> <%= Server.HTMLEncode(rs("hostname") & "") %> <%= Server.HTMLEncode(rs("ip") & "") %>

<%= rowCount %> records found