Saturday, December 6, 2008

Just a quick note about how to debug and compile Pentaho PDI
  1. Get the source from svn e.g. to get the branch 3.1.0 use the following command
    svn co svn:// Kettle3.1.0
  2. Make sure you have ant, I have 1.7.x installed and in the path
  3. Load the project as an existing Java project in Eclipse, modify source at your will
  4. Look at the build.xml file at the top level directory where you checked out the source
    e.g. Kettle3.1.0
  5. Run the default target or if you changed source file in one of the sub packages such as core or ui etc., there are separate targets to build just those lib

Friday, December 5, 2008

Pentaho PDI - Running multiple SQL statements

As you may already know, you can use Exec SQL step to execute multiple SQL statements either once during the entire transformation run or once per row.


I was bitten by this issue and ended up wasting couple of hours trying to debug the cause. The reason... Error is really amgious, if you have multiple "syntactically correct" SQL statements separated by commas and try to execute it with default settings on the Connector/J and MySQL as DB you get
"You have an error in your SQL statement, Check the syntax..." error.
Checked my SQL statements several times and individually in SQL Query browser to make sure they were correct.

There are a couple of things you should note
1. In the debug log you will see an old log saying executing DDL statement when it actually can execute both DDL and DML statements. So you will need to ignore that log
2. Not all the drivers/databases allow running multiple comma separated SQL statements due to SQL Injection attach. Check the driver/db to make sure it allows execution of multiple SQL statements separated by commas in one shot.

For MySQL and Connector/J by default does not allow this, so to enable it you will have to add an option in your Database Connections dialog -> Options tab and add the parameter allowMultiQueries with the value of true.

3. Also make sure that you surround ?'s in your SQL statements with single quotes if you are passing in string values. If you are like me, you tend to think of the statement as your typical prepared statement in JDBC and using JDBC api to set the values so you dont need to worry about wrapping strings with quotes.

Hope that helps.