How to retrieve OUT parameter from MYSQL stored procedure to stream in Pentaho Data Integration (Kettle)?

五迷三道 提交于 2019-12-04 15:00:46

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

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>

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!