[Advance Query] Execute a IBM DB2 stored procedure
Forge component by Paulo Fagundes Jr.
Published on 20 Dec 2019
Application Type
Traditional Web
Service Studio Version
11.9.1 (Build 33435)
Platform Version
11.10.1 (Build 23852)

I have an extension which connects to a DB2 database. When connecting entities everything is fine. But i try to add a stored procedure as entity, i cannot find it in the list.

Anyone ever worked with this before?

Rank: #2151

Hello Kesaven, 

Store procedures are database-dependent programs that are seperate from database tables. You cannot create a stored procedure "in" an Entity (which represents a table in the database). That said, stored procedures aren't supported by the OutSystems Platform.

Rank: #3429

Hi Kesavan,

You can just execute storeproc, don't need to add it as entity, it will run any Stored Proc in the current connected database like Db2.

Here are the steps:

Step 1: Create extended SQL: 

make sure you do this in the first line to refer to a table name to get the logical database otherwise it starts looking for SP in the OutSystem SQL database

/* %LogicalDatabase%=GetLogicalDatabase({tablename}) */

Step 2: 

then set the Db2 environment like this, this is a Stored Proc in Db2.

CALL SETENVLIBL({Environmentname})

 If this works, your calls to any Stored Prod in Db2 should also works.