3

I am unable to get the OUT parameter of a MySQL procedure call in the output stream with the procedure call step of Pentaho Kettle.

I'm having big trouble retrieving OUT parameter from MYSQL stored procedure to stream. I think it's maybe a kind of bug becouse it only occurs with Integer out parameter, it works with String out parameter. The exception I get is:

Invalid value for getLong() - '

I think the parameters are correctly set as you can see in the ktr.

You can replicate the bug in this way:

Schema

create schema if not exists test;
use test;
DROP PROCEDURE IF EXISTS procedure_test;
delimiter $$
CREATE PROCEDURE procedure_test(IN in_param INT UNSIGNED, OUT out_param INT UNSIGNED)
 BEGIN
  SET out_param := in_param;
 END
$$

KTR You can download here .ktr file with the steps. You just have to setup the connection to MySQL test schema to try it.

Other data

  • MySQL connector: 5.1.30
  • MySQL version: 5.5
  • Kettle version: 5.0.1-stable
  • OS: Ubuntu 12.04

Any help from the community will be highly appreciated.

Thanks in advance!

4
  • 1
    I have similar trouble with SQL Server OUT parameters. Had to work around the procedure in the end. If there is a solution to this, I haven't seen it. May 5, 2014 at 16:11
  • I could reproduce the error using an INT parameter for OUT. However, both NUMBER and VARCHAR did work! May 5, 2014 at 21:45
  • Hi Marcus, thank you for the feedback!! I have tried again, and I cannot make it work with NUMBER. It do work with VARCHAR. Are you sure you can make it work? Try with input number 99 for example. Can you please send me the ktr? May 8, 2014 at 16:29
  • I'll send you the ktr if you send me mail. See my profile. May 9, 2014 at 21:54

2 Answers 2

1

The bug does not seem to occur if number (and decimal at DB level) is used as the output parameter type. So this may be used as a work around.

With a DB procedure using this statement (as returned by phpMyAdmin):

CREATE DEFINER = `root`@`localhost` 
     PROCEDURE `procedure_test` ( IN `in_param` INT ZEROFILL, 
                                  OUT `out_param` DECIMAL( 10 ) ) 
     NOT DETERMINISTIC NO SQL SQL SECURITY DEFINER 
     BEGIN 
        SET out_param =2 * in_param;
     END

I was able to run this transformation

enter image description here

reading this input

IN_VALUE
1
2
3
99

yielding this output

<?xml version="1.0" encoding="UTF-8"?>
<Rows>
  <Row><OUT_VALUE> 2,0</OUT_VALUE> </Row>
  <Row><OUT_VALUE> 4,0</OUT_VALUE> </Row>
  <Row><OUT_VALUE> 6,0</OUT_VALUE> </Row>
  <Row><OUT_VALUE> 198,0</OUT_VALUE> </Row>
</Rows>
4
  • Hello Marcus, thank you for the great answer and work around. However I cannot change the procedure definition. The output value must be INT UNSIGNED :-( May 12, 2014 at 17:40
  • Could you use a wrapper? May 12, 2014 at 19:12
  • I mark your answer as the accepted answer becouse it solves the problem to output the data in the stream. However I use the approach I explain in my answer. Thanks again for your interest. May 13, 2014 at 11:08
  • I've got this same issue trying to get an inout paramater value failing. Does anyone know how to convert the decimal back to integer? I'm hitting an issue later in the stream where it's trying to insert the decimal value into an integer field and failing on conversion.
    – Richard G
    Sep 9, 2015 at 4:09
0

I have solved the problem using SQL script step with an SQL like this:

CALL procedure_test(?, @output_value);
INSERT INTO output_value_for(in, out) VALUES (?, @output_value);

SQL script step don't allow output value to stream, however it was a better solution for my problem. After procedure execution, I inserted in MySQL database output value of the procedure becouse I need to persist that relation.

However, I think Marcus answer is better approach for the posed problem. If you have this problem, you should take it into account as work around.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.