How can I call a DB2 stored procedure with OUT parameters from SQuirreL SQL?

49,985

Solution 1

It seems that SQuirrel currently is not capable of doing that on AS/400 DB2.

Using the open source "SQL Workbench/J" (http://www.sql-workbench.net/) I was able to call a procedure:

wbcall SOMESPROC(12345, ?);

It has its own command for calling a procedure "wbcall". Use ? for out parameters.

Note: While installing SQL Workbench/J make sure to download the right DB2 driver from IBM and also add the licence file while adding the driver inside SQL Workbench/J.

Solution 2

In Squirrel you can use something like this. You'll want to make sure the type of the declared variable matches the type of your out parameter in the stored procedure.

BEGIN
    DECLARE outParam INT;
    STORED_PROC_NAME(outParam);
END

If you also need to provide input for the procedure you could do this.

BEGIN
    DECLARE outParam INT;
    STORED_PROC_NAME('input', outParam);
END

You also need to change the statement separator to something other than ;. Otherwise it will break up the statement and try to send each piece individually.

Solution 3

In the pro version of DbVisualizer, with the "Process Parameter Markers in SQL" under the SQL Commander menu option enabled, it will allow the "?" param

call SOMESPROC(12345, ?);
Share:
49,985
KC Baltz
Author by

KC Baltz

As a Software Architect, I'm a problem solver who uses programming and communication as my primary tools. I pride myself not only on my ability to understand technical systems, but also to communicate with others at their level, be they a junior programmer, software architect, senior management, or a business stakeholder. As for programming, I enjoy Java and have used it for web sites, web services, rich clients, and batch processing. I love new problems and learning new technologies.

Updated on September 14, 2020

Comments

  • KC Baltz
    KC Baltz over 3 years

    I really like SQuirreL SQL as a SQL query tool, but I've never been able to get it to call stored procedures in our AS/400 DB2 database. I always get the error "The number of parameter values set or registered does not match the number of parameters." I've double-checked the number of params and had no luck. This is the syntax I've tried for a procedure that takes one IN and one OUT:

    call SOMESPROC(12345, ?);