Error in IF and SQL query

Hi, I try to learn the script in Ignition and I have this code and I need to compare the values ​​from the query SQl “duplicity”. this way the code returns an error to me.

parms = {
	"carovyKod" : self.getSibling("NumericEntryField_9").props.value
	}
	id = system.db.runNamedQuery("Technic","technics/Revize/duplicita",parms);
	#id = system.dataset.toPyDataSet(id);
	self.getSibling("Label_11").props.text = id;
	#id.getValueAt(0,0);        
	if id is None:
		self.getSibling("Label_11").props.text = "test";
		rz = {
			"ch1": self.getSibling("check_el_box").props.selected,
			"ch2": self.getSibling("check_ruc_nar").props.selected,
			"ch3": self.getSibling("check_prod_privod").props.selected,
			"ch4": self.getSibling("check_od_privod").props.selected,
			"nazevSpotrebice": self.getSibling("TextField").props.text,
			"inventarniCislo": self.getSibling("NumericEntryField").props.value,
			"vyrobce": self.getSibling("TextField_1").props.text,
			"rokVyroby": self.getSibling("NumericEntryField_0").props.value,
			"vyrobniCislo": self.getSibling("TextField_2").props.text,
			"majitel": self.getSibling("TextField_3").props.text,
			"skpinaPouyivani": self.getSibling("Dropdown").props.value,
			"typOznac": self.getSibling("TextField_4").props.text,
			"Un": self.getSibling("NumericEntryField_1").props.value,
			"In" : self.getSibling("NumericEntryField_2").props.value,
			"Pn" : self.getSibling("NumericEntryField_3").props.value,
			"TridaOchrany" : self.getSibling("Dropdown_0").props.value,
			"datumKontroly" : self.getSibling("DateTimeInput").props.value,
			"TypKontroly" : self.getSibling("Dropdown_1").props.value,
			"poznamka" : self.getSibling("TextField_5").props.text,
			"vyhodnoceni" : self.getSibling("Dropdown_2").props.value,
			"sestava" : self.getSibling("Dropdown_3").props.value,
			"delkaPrivodu" : self.getSibling("NumericEntryField_4").props.value,
			"OdporVodice" : self.getSibling("NumericEntryField_5").props.value,
			"IzolkacniOdpor" : self.getSibling("NumericEntryField_6").props.value,
			"metoda" : self.getSibling("Dropdown_4").props.value,
			"I" : self.getSibling("NumericEntryField_7").props.value,
			"bezMaleNapeti" : self.getSibling("NumericEntryField_8").props.value,
			"zkouskaChodu" : self.getSibling("Dropdown_5").props.value,
			"celkoveHodnoceni" : self.getSibling("Dropdown_6").props.value,
			"terminDalsikontroly" : self.getSibling("DateTimeInput_0").props.value,
			"provedl" : self.getSibling("TextField_6").props.text,
			"cisloProtokolu" : self.getSibling("NumericEntryField_9").props.value,
			"OznaceniTypu" : self.getSibling("TextField_4").props.text
		}
		system.db.runNamedQuery("Technic","technics/Revize/revizeAdd",rz);   
	else:	
		if id.getValueAt(0,0) > 1:
			system.perspective.openPopup("info",'RZ/popup/info')
		

So can you help me please?

And here is my SQL code for duplicity :slight_smile:

The error says the length of your dataset is zero. ‘id’ should always return a dataset, and never a None object. So, it goes the else portion of the script and errors because row 0 doesn’t exist.

Instead, try if id.rowCount == 0:

3 Likes

Perfect thank you very much :smiley:

1 Like