Skip to main content
Question

SQL Executor run a procedure

  • November 20, 2018
  • 4 replies
  • 231 views

ciarab
Contributor
Forum|alt.badge.img+9

 

Hi,

 

I have a procedure I want to call from an oracle database

-- In Oracle SQL this would be executed as follows (variables for address_heading and address id must be declared):

 

execute clar.clar.get_address_model_building(38660795,

 

address_headings,

 

address);

 

Im using the sql executor but cant seem to get it to run successfully. It should return a value like this

BN 1T 1L C*

 

DAVIS COURT, MAIN STREET, HEADFORD, CO. GALWAY

 

I have tried various iterations but just keep getting did not succeed; error was `ORA-00900: invalid SQL statement'

 

Any advice on what I need to pass in to run the procedure and return a result?

 

Thanks

4 replies

erik_jan
Contributor
Forum|alt.badge.img+17
  • Contributor
  • November 20, 2018

Hi Ciara,

I have had the same issue.

The SQLExecutor can not handle Oracle PL/SQL out parameters to populate an attribute.

I have solved this by creating a Stored Function instead of a stored Procedure.

The Stored Function can be called inside a SQL statement and the resulting value can be used as an attribute.

Hope this helps.

Erik


ciarab
Contributor
Forum|alt.badge.img+9
  • Author
  • Contributor
  • November 20, 2018

@erik_jan Thanks so much for your quick response. I was going through multiple methods that usually work for me but getting nowhere. That sounds like a good solution for me

 

Ciara


  • February 22, 2019
erik_jan wrote:

Hi Ciara,

I have had the same issue.

The SQLExecutor can not handle Oracle PL/SQL out parameters to populate an attribute.

I have solved this by creating a Stored Function instead of a stored Procedure.

The Stored Function can be called inside a SQL statement and the resulting value can be used as an attribute.

Hope this helps.

Erik

can you please some piece of a code as an example? I having the same issue and not getting anywhere.


gauripearl wrote:

can you please some piece of a code as an example? I having the same issue and not getting anywhere.

Here is a test I set up for you Gauripearl:

 

 

ORACLE Setup:

 

CREATE TABLE test_table_for_function(

id NUMBER PRIMARY KEY NOT NULL

,txt_column VARCHAR2(20)

,num_column NUMBER

);

INSERT INTO test_table_for_function(id, txt_column, num_column)

VALUES (1, 'test text value 1', 123456);

INSERT INTO test_table_for_function(id, txt_column, num_column)

VALUES (2, 'test text value 2', 123457);

INSERT INTO test_table_for_function(id, txt_column, num_column)

VALUES (3, 'test text value 3', 123458);

Create a Function:

 

CREATE OR REPLACE FUNCTION fn_get_val(p_id IN NUMBER)

RETURN NUMBER IS

v_num_value NUMBER;

BEGIN

SELECT num_column

INTO v_num_value

FROM test_table_for_function a

WHERE a.id = p_id;

RETURN (v_num_value);

END;

 

 

In your SQL Executor:

 

 

FME_SQL_DELIMITER ;

select fn_get_val(1) return_value

from dual;

 

 

This will return your function result which I have aliased to an attribute called RETURN_VALUE

Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings