# Calling a function / store procedure from jdbc input pluging

**URL:** <https://discuss.elastic.co/t/calling-a-function-store-procedure-from-jdbc-input-pluging/375562>\
**Category:** Logstash\
**Created:** [March 7, 2025, 1:56pm UTC](https://discuss.elastic.co/t/calling-a-function-store-procedure-from-jdbc-input-pluging/375562 "2025-03-07T13:56:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anabella\_Cristaldi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anabella_cristaldi/32/23612_2.png) [@Anabella\_Cristaldi](https://discuss.elastic.co/u/Anabella_Cristaldi)\
**Post date:** [March 7, 2025, 1:56pm UTC](https://discuss.elastic.co/t/calling-a-function-store-procedure-from-jdbc-input-pluging/375562/1 "2025-03-07T13:56:58Z")

</div>

Hello,  
I'm trying to invoke a function from the jdbc input plugin.  
I've read this

> [@Can we use stored procedure in logstash using jdbc](https://discuss.elastic.co/t/can-we-use-stored-procedure-in-logstash-using-jdbc/193497/2):
>
> Hi, What DB are you using? I know that for Oracle you can call functions in SQL so you could set the following as statement: "select proc() from dual" Best regards Wolfram

But I get the following error

`[2025-03-07T14:43:00,004][WARN][logstash.inputs.jdbc][main][335bb609b009b4900e39c184c3e0c418f819a629827a54ef285b30935a6cbbf6] Exception when executing JDBC query {:exception=>Sequel::DatabaseError, :message=>"Java::JavaSql::SQLException: ORA-29478: Implicit result cannot be returned through this statement.\nORA-06512: at \"SYS.DBMS_SQL\", line 2877\nORA-06512: at \"SYS.DBMS_SQL\", line 2871\nORA-06512: at \"APPTEST.SPGETDATAFN\", line 7\n", :cause=>"#<Java::JavaSql::SQLException: ORA-29478: Implicit result cannot be returned through this statement.\nORA-06512: at \"SYS.DBMS_SQL\", line 2877\nORA-06512: at \"SYS.DBMS_SQL\", line 2871\nORA-06512: at \"APPTEST.SPGETDATAFN\", line 7\n>"}`

My function is defined like this

```auto
create or replace function spGetDatafn
 return sys_refcursor
 is
   rc sys_refcursor;
  begin
   open rc for select * from billing;
         dbms_sql.return_result(rc);
  end;
/

```

and using this function code

```auto
create or replace function spGetDatafn
 return sys_refcursor
 is
   rc sys_refcursor;
  begin
   open rc for select * from billing;
                    return rc;
  end;
/

```

I get the following error

`[2025-03-07T14:59:28,500][WARN][logstash.inputs.jdbc][main][335bb609b009b4900e39c184c3e0c418f819a629827a54ef285b30935a6cbbf6] Exception when executing JDBC query {:exception=>Sequel::DatabaseError, :message=>"Java::OrgLogstash::MissingConverterException: Missing Converter handling for full class name=oracle.jdbc.driver.ForwardOnlyResultSet, simple name=ForwardOnlyResultSet", :cause=>"#<Java::OrgLogstash::MissingConverterException: Missing Converter handling for full class name=oracle.jdbc.driver.ForwardOnlyResultSet, simple name=ForwardOnlyResultSet>"}`  
Has anyone suceeded with this? @ [Wolfram\_Haussig](https://discuss.elastic.co/u/Wolfram_Haussig) @raj.teaser  
Thank you

---

<div class="post-metadata">

**Author:** ![Wolfram\_Haussig](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wolfram_haussig/32/70528_2.png) [@Wolfram\_Haussig](https://discuss.elastic.co/u/Wolfram_Haussig)\
**Post date:** [March 10, 2025, 6:31am UTC](https://discuss.elastic.co/t/calling-a-function-store-procedure-from-jdbc-input-pluging/375562/2 "2025-03-10T06:31:27Z")

</div>

Hello Anna,

The post you mentioned is for functions that return a single value, but you want to return a list of rows. Logstash tries to convert each value into one of the datatypes known to Elastic and it doesn't know how to convert `ForwardOnlyResultSet`.

Do you really need a `sys_refcursor` in your application? If you define it as a [(pipelined) table function](https://oracle-base.com/articles/misc/pipelined-table-functions) you should be able to use `select * from TABLE(spGetDatafn)`.

Best regards  
Wolfram

PS: Please don't @mention people that are not already in the discussion. I am reading and answering here in my spare time so let me please decide myself which posts I want to answer to.

---

<div class="post-metadata">

**Author:** ![Anabella\_Cristaldi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anabella_cristaldi/32/23612_2.png) [@Anabella\_Cristaldi](https://discuss.elastic.co/u/Anabella_Cristaldi)\
**Post date:** [March 16, 2025, 6:55pm UTC](https://discuss.elastic.co/t/calling-a-function-store-procedure-from-jdbc-input-pluging/375562/3 "2025-03-16T18:55:38Z")

</div>

Thank you and my apologies
