# Error Query no rows

**URL:** <https://forum.inductiveautomation.com/t/error-query-no-rows/82770>\
**Category:** Ignition\
**Created:** [December 6, 2023, 11:14am UTC](https://forum.inductiveautomation.com/t/error-query-no-rows/82770 "2023-12-06T11:14:07Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stef\_Velers](https://avatars.discourse-cdn.com/v4/letter/s/bc8723/32.png) [@Stef\_Velers](https://forum.inductiveautomation.com/u/Stef_Velers)\
**Post date:** [December 6, 2023, 11:14am UTC](https://forum.inductiveautomation.com/t/error-query-no-rows/82770/1 "2023-12-06T11:14:07Z")

</div>

Hello,  
short question, is there a way to disable this error popup?

Exception: Query returned no rows.  
For query: "EXEC ProductDefinition.GetMaterialName 0"

I'm okay with that it is not returning any rows at this value but it is a bit frustrating that this error pops up every time you save or change something.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [December 6, 2023, 11:22am UTC](https://forum.inductiveautomation.com/t/error-query-no-rows/82770/2 "2023-12-06T11:22:30Z")

</div>

1. Vision or Perspective?
2. Is this a named query?
3. Is it a binding on a component?
4. Where and when does the error pop up? In Designer? In runtime / browser?
5. Is it run from a script? If so please post the code and format it using the \</\> button.

---

<div class="post-metadata">

**Author:** ![Stef\_Velers](https://avatars.discourse-cdn.com/v4/letter/s/bc8723/32.png) [@Stef\_Velers](https://forum.inductiveautomation.com/u/Stef_Velers)\
**Post date:** [December 6, 2023, 11:32am UTC](https://forum.inductiveautomation.com/t/error-query-no-rows/82770/3 "2023-12-06T11:32:59Z")

</div>

1. Vision
2. SQL query
3. Custom parameter Binding
4. in the designer only when I change something or update the project
5. It is a script run in the SQL Query of the property binding of a text field with the following code:  
`EXEC ProductDefinition.GetMaterialName {Root Container.Text Field 1.code}`

This is the popup up:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/8/c8c9da4d95bfc8056ef954a6af0daea904ad053e.png)

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [December 6, 2023, 11:50am UTC](https://forum.inductiveautomation.com/t/error-query-no-rows/82770/4 "2023-12-06T11:50:09Z")

</div>

I don't know the answer, but what happens if you do,

```auto
try:
  EXEC ProductDefinition.GetMaterialName {Root Container.Text Field 1.code}
except:
  None

```

Or, if the problem is because `{Root Container.Text Field 1.code}` is empty then,

```auto
if {Root Container.Text Field 1.code}:
  EXEC ProductDefinition.GetMaterialName {Root Container.Text Field 1.code}

```

---

<div class="post-metadata">

**Author:** ![Stef\_Velers](https://avatars.discourse-cdn.com/v4/letter/s/bc8723/32.png) [@Stef\_Velers](https://forum.inductiveautomation.com/u/Stef_Velers)\
**Post date:** [December 6, 2023, 12:18pm UTC](https://forum.inductiveautomation.com/t/error-query-no-rows/82770/5 "2023-12-06T12:18:25Z")

</div>

Okay, but maybe we can figure this out together if you agree.  
Both solutions didn't work but with the if statement I got this error:

```auto
Exception: Error running query:
SQLQuery(query=if (0):
  EXEC ProductDefinition.GetMaterialName 0, database=OptiMes_roosendaal)@0ms
On: 4_1_0_lijn4_Productielijn.Root Container.Text Field 1.ProductName
	caused by GatewayException: Incorrect syntax near ':'.
	caused by SQLServerException: Incorrect syntax near ':'.

Ignition v8.1.33 (b2023101913)
Java: Azul Systems, Inc. 17.0.8

```

It sees the parameter instantly as a number so maybe the problem lies there. Cause I think you mean that when the parameter is a number and not just 0 then it has to do the stored procedure?

for the first error, it has something to do with "except"

```auto
Exception: Error running query:
SQLQuery(query=try:
  EXEC ProductDefinition.GetMaterialName 0
except:
  None, database=OptiMes_roosendaal)@0ms
On: 4_1_0_lijn4_Productielijn.Root Container.Text Field 1.ProductName
	caused by GatewayException: Incorrect syntax near the keyword 'except'.
	caused by SQLServerException: Incorrect syntax near the keyword 'except'.

```

---

<div class="post-metadata">

**Author:** ![Stef\_Velers](https://avatars.discourse-cdn.com/v4/letter/s/bc8723/32.png) [@Stef\_Velers](https://forum.inductiveautomation.com/u/Stef_Velers)\
**Post date:** [December 6, 2023, 12:22pm UTC](https://forum.inductiveautomation.com/t/error-query-no-rows/82770/6 "2023-12-06T12:22:07Z")

</div>

Thanks for your first answer. I appreciate the time and effort you guys put into people. But if you think it is not something you think you can solve then it's fine. I can try it myself or it is what it is.

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [December 6, 2023, 12:24pm UTC](https://forum.inductiveautomation.com/t/error-query-no-rows/82770/7 "2023-12-06T12:24:37Z")

</div>

Are you trying to do try/excpet in a sql query binding? Don't do that that won't work. That is why you are getting `caused by GatewayException: Incorrect syntax near the keyword 'except'.`

The original error from before the try and except -

```auto
	caused by GatewayException: Incorrect syntax near ':'.
	caused by SQLServerException: Incorrect syntax near ':'.

```

Can you run `EXEC ProductDefinition.GetMaterialName 0` in your DB workbench or the Database Query Browser? Seems like the issue may lie inside the stored procedure itself.

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [December 6, 2023, 12:33pm UTC](https://forum.inductiveautomation.com/t/error-query-no-rows/82770/8 "2023-12-06T12:33:28Z")

</div>

Show us exactly what you're doing, because so far your description is pretty vague:

> [@Stef\_Velers](#):
>
> It is a script run in the SQL Query of the property binding of a text field with the following code:  
> `EXEC ProductDefinition.GetMaterialName {Root Container.Text Field 1.code}`

That doesn't make much sense. Is it a property binding ? Is it a SQL binding ? Is it a script binding ?

There are several ways of handling lack of data, but to figure out the best/right one, we'll need to know what expects data, where it should come from, and what should happen if there is none.

> [@bkarabinchak.psi](#):
>
> The original error from before the try and except

I think he tried to use a python `if` statement in the query itself, which is why he got that error.

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [December 6, 2023, 12:35pm UTC](https://forum.inductiveautomation.com/t/error-query-no-rows/82770/9 "2023-12-06T12:35:02Z")

</div>

He did say `It is a script run in the SQL Query of the property binding of a text field with the following code` so I assumed it was a SQL Query binding.

It's still not exactly clear to me though.

---

<div class="post-metadata">

**Author:** ![Stef\_Velers](https://avatars.discourse-cdn.com/v4/letter/s/bc8723/32.png) [@Stef\_Velers](https://forum.inductiveautomation.com/u/Stef_Velers)\
**Post date:** [December 6, 2023, 12:39pm UTC](https://forum.inductiveautomation.com/t/error-query-no-rows/82770/10 "2023-12-06T12:39:37Z")

</div>

This is what I made:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/6/e6aaffbf50353a01e89b2acfd7e1e3fe3fd9f111.png)  
But when the parameter passes 0 I get the following error:

```auto
Exception: Query returned no rows.
For query: "EXEC ProductDefinition.GetMaterialName 0
"
On Component: 4_1_0_lijn4_Productielijn.Root Container.Text Field 1.ProductName

```

It is not a problem to me that it is not returning anything when the value is 0 because that is exactly what I want. But I don't want this error to show up every time I update my project in the designer. So is there a solution to disable this error or at least that it is not giving me this error.

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [December 6, 2023, 12:44pm UTC](https://forum.inductiveautomation.com/t/error-query-no-rows/82770/11 "2023-12-06T12:44:03Z")

</div>

Ah ok. You can enable the "Fallback Value" there and put something in there - that is what will be returned in the event of no rows returned.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/5/35666017235df0d7db791a77c9ca5510c3f01b60.png)

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [December 6, 2023, 1:05pm UTC](https://forum.inductiveautomation.com/t/error-query-no-rows/82770/12 "2023-12-06T13:05:05Z")

</div>

Bindings are expected to return a value. If a query might not return a value, you are expected to define the fallback value to return instead.

You have to return **something** to deliver to the bound property.

---

<div class="post-metadata">

**Author:** ![Stef\_Velers](https://avatars.discourse-cdn.com/v4/letter/s/bc8723/32.png) [@Stef\_Velers](https://forum.inductiveautomation.com/u/Stef_Velers)\
**Post date:** [December 6, 2023, 1:22pm UTC](https://forum.inductiveautomation.com/t/error-query-no-rows/82770/13 "2023-12-06T13:22:18Z")

</div>

Thanks that worked!
