# Jdbc\_static dealing with parameters from not existing fields

**URL:** <https://discuss.elastic.co/t/jdbc-static-dealing-with-parameters-from-not-existing-fields/377628>\
**Category:** Logstash\
**Tags:** jdbc\
**Created:** [April 29, 2025, 3:15pm UTC](https://discuss.elastic.co/t/jdbc-static-dealing-with-parameters-from-not-existing-fields/377628 "2025-04-29T15:15:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Francesco\_Esposito](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/francesco_esposito/32/141865_2.png) [@Francesco\_Esposito](https://discuss.elastic.co/u/Francesco_Esposito)\
**Post date:** [April 29, 2025, 3:15pm UTC](https://discuss.elastic.co/t/jdbc-static-dealing-with-parameters-from-not-existing-fields/377628/1 "2025-04-29T15:15:53Z")

</div>

I'm trying to use the jdbc\_static filter in my logstash pipeline, but I am getting the following error:

```auto
[2025-04-29T10:36:48,983][WARN][logstash.filters.jdbc.lookup][test][udplogstash] Parameter field not found in event {:lookup_id=>"loadingdata", :invalid_parameters=>["[account]", "[chaincode]"]}

```

My lookups is

```auto
		local_lookups => [
			{
				id => "loadingdata"
				query => "select ServiceName, ProcessorPartner from localstore where RNID = :RNID and ChainCode = :CHAINCODE"
				parameters => { 
								RNID => "[account]"
								CHAINCODE => "[chaincode]" 
							}
				target => "attributes"
				default_hash => {
					ServiceName => nil
					ProcessorPartner => nil
				}
			}
		]

```

I know that account and chaincode could not be in the event but I supposed that the query would treat missing fields as null.

Plus, my account and chaincode come in as strings, even if they contain and integer, and I need to cast them to integer.

How would you modify my lookup to pass this problem?

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [April 29, 2025, 5:46pm UTC](https://discuss.elastic.co/t/jdbc-static-dealing-with-parameters-from-not-existing-fields/377628/2 "2025-04-29T17:46:03Z")

</div>

> [@Francesco\_Esposito](#):
>
> I know that account and chaincode could not be in the event but I supposed that the query would treat missing fields as null.

If the parameter fields do not exist then it logs a warning and does not do the lookup. (See [here](https://github.com/logstash-plugins/logstash-integration-jdbc/blob/b943c373efb3902b8651994a6d9276ba5f8e3434/lib/logstash/filters/jdbc/lookup.rb#L32) and [here](https://github.com/logstash-plugins/logstash-integration-jdbc/blob/b943c373efb3902b8651994a6d9276ba5f8e3434/lib/logstash/filters/jdbc/lookup.rb#L156).)

If this is the only lookup then you could wrap the jdbc\_static filter in a test to see of the fields exist:

```
if [account] and [chaincode] { jdbc_static {...} }

```

If you want to suppress all warnings from the filter you could [configure](https://discuss.elastic.co/t/ruby-dumps-tons-of-runtime-errors-after-upgrade-to-8-16-2/374774/7) log4j to do that.

You can use [mutate+convert](https://www.elastic.co/docs/reference/logstash/plugins/plugins-filters-mutate#plugins-filters-mutate-convert) to modify the fields to be integers.

---

<div class="post-metadata">

**Author:** ![Francesco\_Esposito](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/francesco_esposito/32/141865_2.png) [@Francesco\_Esposito](https://discuss.elastic.co/u/Francesco_Esposito)\
**Post date:** [May 12, 2025, 9:32pm UTC](https://discuss.elastic.co/t/jdbc-static-dealing-with-parameters-from-not-existing-fields/377628/3 "2025-05-12T21:32:46Z")

</div>

@Badger if I want to execute multiple lookups on the same table, **conditioned if a field exists** , how would I do? Can I have the "if" inside jdbc\_static?

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [May 12, 2025, 10:09pm UTC](https://discuss.elastic.co/t/jdbc-static-dealing-with-parameters-from-not-existing-fields/377628/4 "2025-05-12T22:09:37Z")

</div>

You cannot have a conditional inside the filter, you have to use conditionals to select which filters to run.
