# Parsing field sql\_bind into sql\_text

**URL:** <https://discuss.elastic.co/t/parsing-field-sql-bind-into-sql-text/97447>\
**Category:** Logstash\
**Created:** [August 17, 2017, 3:14pm UTC](https://discuss.elastic.co/t/parsing-field-sql-bind-into-sql-text/97447 "2017-08-17T15:14:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![GambitK](https://avatars.discourse-cdn.com/v4/letter/g/47e85d/32.png) [@GambitK](https://discuss.elastic.co/u/GambitK)\
**Post date:** [August 17, 2017, 3:14pm UTC](https://discuss.elastic.co/t/parsing-field-sql-bind-into-sql-text/97447/1 "2017-08-17T15:14:43Z")

</div>

I'm consuming oracle logs using logstash, i want to reconstruct the original sql statement that oracle(using variable binding) writes into two fields sql\_bind and sql\_text.

sql\_text contains the sql sent to the database and sql\_bind contains the parameters used in the query at run time.

Example:

```
sql_text=select * from hr.emp where empid = :empid and status = :status
sql_bind=#1(3):100 #2(2)99

```

This translates into:

`select * from hr.emp where empid = 100 and status = 99`

The thing is you don't know how many variables come at a given time. Is there any way for me to achieve what I need of reconstructing the original sql query?

Also, how could I parse the sql\_bind field into one field for each variable given that the variable is the value after the ":".

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [August 20, 2017, 6:38pm UTC](https://discuss.elastic.co/t/parsing-field-sql-bind-into-sql-text/97447/2 "2017-08-20T18:38:10Z")

</div>

I think you'll have to use a ruby filter for this, but the needed Ruby code shouldn't be very hard to write.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 17, 2017, 6:38pm UTC](https://discuss.elastic.co/t/parsing-field-sql-bind-into-sql-text/97447/3 "2017-09-17T18:38:22Z")

</div>

Closed on September 17, 2017, 6:38pm UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
