Error on sending data to SQL

Hello,

I was sending data to sql via tag change script below. It was working but somehow it stopped sending data to sql I check the script there is no error on the diagnostics. Script below;

What do you think the reason could be ?If there was an error on the script It should have told me on the diagnostics right? Somethng related to SQL side? Could there be an error on the script but I am not getting the error message?

T = system.tag.read("[.]ShiftEndSignal").value 

if T == 1   : 

	
	Shift=system.tag.read("[~]System/FoamingShift").value
	LineID=4
	CabinID=2
	ProjectReferance=system.tag.read("[.]ProjectReferance").value
	Week=system.tag.read("[TSW_Production]System/Week").value
	RobotStatus=1
	OperatorID=system.tag.read("[.]FoamingOperator.FoamingOpID").value
	Operator2ID=system.tag.read("[.]DeburringOperator.DeburringOpID").value
	ProjectName=system.tag.read("[.]ProjectName").value
	MoldNumber=system.tag.read("[.]../../CabinProcessParameters/Cabin2ProcessParameters/MoldNumber").value
	OverflowWeight=system.tag.read("[.]OverflowQuantity").value
	SWWeight=system.tag.read("[.]ProductWeight").value
	ArmatureWeight=system.tag.read("[.]ArmatureWeight").value
	TotalProduction=system.tag.read("[.]ProductionQuantity").value
	NokProduction=system.tag.read("[.]ScrapQuantity").value
	TargetProduction=system.tag.read("[.]ProductionTarget").value
	Efficiency=system.tag.read("[.]Efficiency").value
	TotalDowntime=system.tag.read("[.]Downtime").value
	PaintPeeling=system.tag.read("[.]../../LineScrapDowntime /ScrapDowntimeCabin2/BoyaKalkmasi").value
	MRA=system.tag.read("[.]../../LineScrapDowntime /ScrapDowntimeCabin2/KalipAyirici").value
	Porosity=system.tag.read("[.]../../LineScrapDowntime /ScrapDowntimeCabin2/Gozenek").value
	BrokenFoam=system.tag.read("[.]../../LineScrapDowntime /ScrapDowntimeCabin2/ParcaKopmasi").value
	MaterialProblem=system.tag.read("[.]../../LineScrapDowntime /ScrapDowntimeCabin2/Malzeme").value
	Bubble=system.tag.read("[.]../../LineScrapDowntime /ScrapDowntimeCabin2/Baloncuk").value
	VentBlocked=system.tag.read("[.]../../LineScrapDowntime /ScrapDowntimeCabin2/VentilTikali").value
	DeeplyCut=system.tag.read("[.]../../LineScrapDowntime /ScrapDowntimeCabin2/DerindenKesme").value
	Deformation=system.tag.read("[.]../../LineScrapDowntime /ScrapDowntimeCabin2/Deformasyon").value
	BurrlineOpen=system.tag.read("[.]../../LineScrapDowntime /ScrapDowntimeCabin2/CapakHattiBosluk").value
	SealLeak=system.tag.read("[.]../../LineScrapDowntime /ScrapDowntimeCabin2/ContaKacagi").value
	MixingHead=system.tag.read("[.]../../LineScrapDowntime /ScrapDowntimeCabin2/KarisimKafasi").value
	Quality=system.tag.read("[.]../../LineScrapDowntime /ScrapDowntimeCabin2/Kalite").value
	IE=system.tag.read("[.]../../LineScrapDowntime /ScrapDowntimeCabin2/IE").value
	SystemSensor=system.tag.read("[.]../../LineScrapDowntime /ScrapDowntimeCabin2/SistemSensor").value
	MoldChangeover=system.tag.read("[.]../../LineScrapDowntime /ScrapDowntimeCabin2/KalipDegisimi").value
	MoldCleaning=system.tag.read("[.]../../LineScrapDowntime /ScrapDowntimeCabin2/KalipTemizligi").value
	SealBurrAlignment=system.tag.read("[.]../../LineScrapDowntime /ScrapDowntimeCabin2/ContaAyari").value
	PaintGun=system.tag.read("[.]../../LineScrapDowntime /ScrapDowntimeCabin2/BoyaTabancasi").value
	ClampProblems=system.tag.read("[.]../../LineScrapDowntime /ScrapDowntimeCabin2/IskeletSorunu").value
	PaintPreparation=system.tag.read("[.]../../LineScrapDowntime /ScrapDowntimeCabin2/BoyaHazirlama").value
	Chiller=system.tag.read("[.]../../LineScrapDowntime /ScrapDowntimeCabin2/Chiller").value
	MRAGun=system.tag.read("[.]../../LineScrapDowntime /ScrapDowntimeCabin2/KalipAyiriciTabancasi").value
	MoldHeater=system.tag.read("[.]../../LineScrapDowntime /ScrapDowntimeCabin2/KalipIsitici").value
	PlannedDowntime=system.tag.read("[.]../../LineScrapDowntime /ScrapDowntimeCabin2/PlanliDurus").value
	PumpGroup=system.tag.read("[.]../../LineScrapDowntime /ScrapDowntimeCabin2/PompaGrubu").value
	RobotDowntime=system.tag.read("[.]../../LineScrapDowntime /ScrapDowntimeCabin2/RobotDurusu").value
	ValveGroup=system.tag.read("[.]../../LineScrapDowntime /ScrapDowntimeCabin2/ValfGrubu").value
	OEE=system.tag.read("[.]OEE").value
	TPU=system.tag.read("[.]TPU").value
	WorkTime=system.tag.read("[.]WorkTime").value
	ReferanceBOMStatus=system.tag.read("[.]../../CabinProcessParameters/Cabin2ProcessParameters/BOMReferanceStatus").value
	SafetySensorStatus=system.tag.read("[.]../../CabinProcessParameters/Cabin2ProcessParameters/SafetySensorStatus").value
	ScrapLocationStatus=system.tag.read("[.]../../CabinProcessParameters/Cabin2ProcessParameters/ScrapLocationStatus").value
	TraceabilityFormsStatus=system.tag.read("[.]../../CabinProcessParameters/Cabin2ProcessParameters/TraceabilityFormStatus").value
	MoldCleaningStatus=system.tag.read("[.]../../CabinProcessParameters/Cabin2ProcessParameters/MoldCleaningStatus").value
	MoldLogosStatus=system.tag.read("[.]../../CabinProcessParameters/Cabin2ProcessParameters/LogoStatus").value
	VisualStatusUnwantedPU=system.tag.read("[.]../../CabinProcessParameters/Cabin2ProcessParameters/VisualSurfaceStatus").value
	VisualStatusDeepCuts=system.tag.read("[.]../../CabinProcessParameters/Cabin2ProcessParameters/DeepCutStatus").value
	VisualStatusSwitchAssemblyForms=system.tag.read("[.]../../CabinProcessParameters/Cabin2ProcessParameters/SwitchAssyFormStatus").value
	VisualStatusSurfaceQuality=system.tag.read("[.]../../CabinProcessParameters/Cabin2ProcessParameters/VisualSurfaceStatus").value
	Hardness=system.tag.read("[.]../../CabinProcessParameters/Cabin2ProcessParameters/Hardness").value
	Weight=system.tag.read("[.]../../CabinProcessParameters/Cabin2ProcessParameters/Weight").value
	SWLength=system.tag.read("[.]../../CabinProcessParameters/Cabin2ProcessParameters/Length").value
	SWDimension=system.tag.read("[.]../../CabinProcessParameters/Cabin2ProcessParameters/Dimension").value
	SWWidth=system.tag.read("[.]../../CabinProcessParameters/Cabin2ProcessParameters/Width").value
	SWThickness=system.tag.read("[.]../../CabinProcessParameters/Cabin2ProcessParameters/Thickness").value
	Gloss=system.tag.read("[.]../../CabinProcessParameters/Cabin2ProcessParameters/Gloss").value
	Color=system.tag.read("[.]../../CabinProcessParameters/Cabin2ProcessParameters/ColorStatus").value
	GrainStatus=system.tag.read("[.]../../CabinProcessParameters/Cabin2ProcessParameters/GrainStatus").value
	PolyolTankLevel=system.tag.read("[.]../../LineMachineParameters/PolyolLine/PolyolTankLevel").value
	InjectionTime=system.tag.read("[.]../../CabinProcessParameters/Cabin2ProcessParameters/InjectionTime").value
	InjectionFlow=system.tag.read("[.]../../CabinProcessParameters/Cabin2ProcessParameters/InjectionFlow").value
	CuringTime=system.tag.read("[.]../../CabinProcessParameters/Cabin2ProcessParameters/CuringTime").value
	MixingRatio=system.tag.read("[.]../../CabinProcessParameters/Cabin2ProcessParameters/InjectionRatio").value
	VentStatus=system.tag.read("[.]../../CabinProcessParameters/Cabin2ProcessParameters/MoldVentStatus").value
	MoldTemperature=system.tag.read("[.]../../CabinProcessParameters/Cabin2ProcessParameters/MoldTemperature").value
	MoldStatus=system.tag.read("[.]../../CabinProcessParameters/Cabin2ProcessParameters/MoldPinsStatus").value
	PolyolTankTemperature=system.tag.read("[.]../../LineMachineParameters/PolyolLine/PolyolTankTemperature").value
	IsoTankTemperature=system.tag.read("[.]../../LineMachineParameters/IsoLine/IsoTankTemperature").value
	PolyolTankPressure=system.tag.read("[.]../../LineMachineParameters/PolyolLine/PolyolTankPressure").value
	IsoTankPressure=system.tag.read("[.]../../LineMachineParameters/IsoLine/IsoTankPressure").value
	MRAFlow=system.tag.read("[.]../../CabinProcessParameters/Cabin2ProcessParameters/ManuelMRAQuantity").value
	MRAGunStatus=system.tag.read("[.]../../CabinProcessParameters/Cabin2ProcessParameters/MRAGunStatus").value
	MRAAtomPressure=system.tag.read("[.]../../CabinProcessParameters/Cabin2ProcessParameters/AtomFanPressure").value
	PaintTankPressure=system.tag.read("[.]../../CabinProcessParameters/Cabin2ProcessParameters/PaintTankPressure").value
	PaintGunStatus=system.tag.read("[.]../../CabinProcessParameters/Cabin2ProcessParameters/PaintGunStatus").value
	PaintGunAtomPressure=system.tag.read("[.]../../CabinProcessParameters/Cabin2ProcessParameters/AtomFanPressure").value
	PaintFlow=system.tag.read("[.]../../CabinProcessParameters/Cabin2ProcessParameters/ManuelPaintQuantity").value
	PolyolAgitator=system.tag.read("[.]../../LineMachineParameters/PolyolLine/PolyolAgitatorStatus").value
	PolyolHighPressure=system.tag.read("[.]../../CabinProcessParameters/Cabin2ProcessParameters/PolyolInjectionPressure").value
	IsoHighPressure=system.tag.read("[.]../../CabinProcessParameters/Cabin2ProcessParameters/IsoInjectionPressure").value
	MRAAgitator=system.tag.read("[.]../../LineMachineParameters/PolyolLine/MRAAgitatorSW1_4").value
	AirNucleation=20
	Clock=system.tag.read("[~]System/Clock").value
	QualityID=system.tag.read("[.]../../CabinProcessParameters/Cabin2ProcessParameters/QualityCheckID").value
	P3Reason=system.tag.read("[.]../../CabinProcessParameters/Cabin2ProcessParameters/P3Reason").value		
			
	
		
	
	SQLParam1= {}
	SQLParam1['Week'] = Week
	SQLParam1['Shift'] = Shift
	SQLParam1['LineID'] = LineID
	SQLParam1['CabinID'] = CabinID
	SQLParam1['ProjectName'] = ProjectName
	SQLParam1['ReferanceBOMStatus'] = ReferanceBOMStatus
	SQLParam1['SafetySensorStatus'] = SafetySensorStatus
	SQLParam1['ScrapLocationStatus'] = ScrapLocationStatus
	SQLParam1['TraceabilityFormsStatus'] = TraceabilityFormsStatus
	SQLParam1['MoldCleaningStatus'] = MoldCleaningStatus
	SQLParam1['MoldLogosStatus'] = MoldLogosStatus
	SQLParam1['VisualStatusUnwantedPU'] = VisualStatusUnwantedPU
	SQLParam1['VisualStatusDeepCuts'] = VisualStatusDeepCuts
	SQLParam1['VisualStatusSwitchAssemblyForms'] = VisualStatusSwitchAssemblyForms
	SQLParam1['VisualStatusSurfaceQuality'] = VisualStatusSurfaceQuality
	SQLParam1['Hardness'] = Hardness
	SQLParam1['Weight'] = Weight
	SQLParam1['SWLength'] = SWLength
	SQLParam1['SWDimension'] = SWDimension
	SQLParam1['SWWidth'] = SWWidth
	SQLParam1['SWThickness'] = SWThickness
	SQLParam1['Gloss'] = Gloss
	SQLParam1['Color'] = Color
	SQLParam1['GrainStatus'] = GrainStatus
	SQLParam1['OperatorID'] = Operator2ID
	SQLParam1['ProjectReferance'] = ProjectReferance
	SQLParam1['Clock'] = Clock
	SQLParam1['QualityID'] = QualityID
	SQLParam1['P3Reason'] = P3Reason 
	system.db.runNamedQuery('Enjeksiyon_SW4_Scada',"Foaming_P3",SQLParam1)
	
	
	SQLParam = {}
	SQLParam['Week'] = Week
	SQLParam['Shift'] = Shift
	SQLParam['LineID'] = LineID
	SQLParam['CabinID'] = CabinID
	SQLParam['RobotStatus'] = RobotStatus
	SQLParam['OperatorID'] = OperatorID
	SQLParam['Operator2ID'] = Operator2ID
	SQLParam['ProjectName'] = ProjectName
	SQLParam['MoldNumber'] = MoldNumber
	SQLParam['OverflowWeight'] = OverflowWeight
	SQLParam['SWWeight'] = SWWeight
	SQLParam['ArmatureWeight'] = ArmatureWeight
	SQLParam['TotalProduction'] = TotalProduction
	SQLParam['NokProduction'] = NokProduction
	SQLParam['TargetProduction'] = TargetProduction
	SQLParam['Efficiency'] = Efficiency
	SQLParam['TotalDowntime'] = TotalDowntime
	SQLParam['PaintPeeling'] = PaintPeeling
	SQLParam['MRA'] = MRA
	SQLParam['Porosity'] = Porosity
	SQLParam['BrokenFoam'] = BrokenFoam
	SQLParam['MaterialProblem'] = MaterialProblem
	SQLParam['Bubble'] = Bubble
	SQLParam['VentBlocked'] = VentBlocked
	SQLParam['DeeplyCut'] = DeeplyCut
	SQLParam['Deformation'] = Deformation
	SQLParam['BurrlineOpen'] = BurrlineOpen
	SQLParam['SealLeak'] = SealLeak
	SQLParam['MixingHead'] = MixingHead
	SQLParam['Quality'] = Quality
	SQLParam['IE'] = IE
	SQLParam['SystemSensor'] = SystemSensor
	SQLParam['MoldChangeover'] = MoldChangeover
	SQLParam['MoldCleaning'] = MoldCleaning
	SQLParam['SealBurrAlignment'] = SealBurrAlignment
	SQLParam['PaintGun'] = PaintGun
	SQLParam['ClampProblems'] = ClampProblems
	SQLParam['PaintPreparation'] = PaintPreparation
	SQLParam['Chiller'] = Chiller
	SQLParam['MRAGun'] = MRAGun
	SQLParam['MoldHeater'] = MoldHeater
	SQLParam['PlannedDowntime'] = PlannedDowntime
	SQLParam['PumpGroup'] = PumpGroup
	SQLParam['RobotDowntime'] = RobotDowntime
	SQLParam['ValveGroup'] = ValveGroup
	SQLParam['OEE'] = OEE
	SQLParam['TPU'] = TPU
	SQLParam['WorkTime'] = WorkTime
	SQLParam['ProjectReferance'] = ProjectReferance
	SQLParam['Clock'] = Clock
	system.db.runNamedQuery('Enjeksiyon_SW4_Scada',"Foaming_UTF",SQLParam)
	
	
	SQLParam2 = {}
	SQLParam2['Shift'] = Shift
	SQLParam2['LineID'] = LineID
	SQLParam2['CabinID'] = CabinID
	SQLParam2['ProjectName'] = ProjectName
	SQLParam2['MoldNumber'] = MoldNumber
	SQLParam2['PolyolAgitator'] = PolyolAgitator
	SQLParam2['PolyolTankLevel'] = PolyolTankLevel
	SQLParam2['InjectionTime'] = InjectionTime
	SQLParam2['InjectionFlow'] = InjectionFlow
	SQLParam2['CuringTime'] = CuringTime
	SQLParam2['MixingRatio'] = MixingRatio
	SQLParam2['VentStatus'] = VentStatus
	SQLParam2['MoldTemperature'] = MoldTemperature
	SQLParam2['MoldStatus'] = MoldStatus
	SQLParam2['PolyolHighPressure'] = PolyolHighPressure
	SQLParam2['IsoHighPressure'] = IsoHighPressure
	SQLParam2['PolyolTankTemperature'] = PolyolTankTemperature
	SQLParam2['IsoTankTemperature'] = IsoTankTemperature
	SQLParam2['PolyolTankPressure'] = PolyolTankPressure
	SQLParam2['IsoTankPressure'] = IsoTankPressure
	SQLParam2['MRAFlow'] = MRAFlow
	SQLParam2['MRAGunStatus'] = MRAGunStatus
	SQLParam2['MRAAgitator'] = MRAAgitator
	SQLParam2['MRAAtomPressure'] = MRAAtomPressure
	SQLParam2['PaintTankPressure'] = PaintTankPressure
	SQLParam2['PaintGunStatus'] = PaintGunStatus
	SQLParam2['PaintGunAtomPressure'] = PaintGunAtomPressure
	SQLParam2['AirNucleation'] = AirNucleation
	SQLParam2['PaintFlow'] = PaintFlow
	SQLParam2['RobotStatus'] = RobotStatus
	SQLParam2['Week'] = Week
	SQLParam2['ProjectReferance'] = ProjectReferance
	SQLParam2['Clock'] = Clock
	system.db.runNamedQuery('Enjeksiyon_SW4_Scada',"Foaming_PPKF",SQLParam2)

If you have the SQL Bridge Module, I would definitely put this in a transaction group.

If you keep it as a tag change script, you need to wrap up all your tag reads into one call. Make a list of other tag paths to read, then pass that list to a single read call

tagsToRead = ["[~]System/FoamingShift","[.]ProjectReferance",...]
tagData = system.tag.readBlocking(tagsToRead)
shift = tagData[0].value
ProjectReferance = tagData[1].value

I would really make this a transaction group though.

1 Like

If there was an error during the running of your system.db.runNameQuery or your system.tag.read calls, you would get an error in your server logs.

Are you sure that this

T = system.tag.read("[.]ShiftEndSignal").value 

if T == 1   : 

is switching back and forth from 0 and 1? Perhaps the scripts not running when you’re expecting it should, hence the lack of data in the database and the lack of server log errors (which you would see if you had an error in your code)

Try putting some logger logic in there

logger = system.util.getLogger("my logger")
T = system.tag.read("[.]ShiftEndSignal").value 
logger.info("About to run")
if T == 1   : 
    logger.info("Running")

To see if things are getting appropriately triggered.

Hello I am manually triggering the tag to 1 and I still see no error on diagnostic in the tag. How the logger works do I just add this as it is tot the script? Where will I see the logger result? Will I bind the logger to another memory tag? Sorry I am quite new in ignition;:slight_smile:
BR

You would just add the lines I put into the script directly, no need for another tag. I am assuming this is a Global Gateway tag since this is a perspective question and perspective doesn’t have client tags. If so then you should see the results in your server logs aka localhost:8088 (or whatever your gateway address is) → Status → Logs.