Parameter limit on Callable statement - Oracle jdbc driver (oracle.jdbc.OracleDriver) - jdbc

I am using IBM message broker, v8.0.0.2. I am trying to call a stored procedure with 45 parameters, in and out. I use the Oracle jdbc driver (oracle.jdbc.OracleDriver). Turns out that I get an 'Invalid column index' SqlException, whenever I try to set the 45th IN or OUT parameter, which is weird. Is there such a limit?

Give Us the Code you've created and the Exception from the Exception list, by the way ,test the stored procedure using SQL Developer or any editor you are using then.. create procedure using ESQL and Call Database Stored Procedure.
CREATE PROCEDURE YourProcedureName(IN PARAM1 TYPE, IN PARAM2 TYPE,...,
OUT PARAM44 TYPE, INOUT PARAM45 TYPE)
LANGUAGE DATABASE DYNAMIC RESULT SETS 1 EXTERNAL NAME "ProcedureNameInDB";
In Main Function
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
--CopyMessageHeaders();
--CopyEntireMessage();
-- DECLARE HERE PARAMETERS FOR THE PROCEUDRE
-- In This Block Declare the 45 parameters for passing them in ESQL Procedure.
-- Then ESQL will pass them to Oracle Stored Procedure.
-- END DECLARE PARAMETERS FOR THE PROCEUDRE
-- Environment.DBRowSetResult: Storing Stored Procedure Output in Environment variable.
CALL YourProcedureName(param1, param2, .... param44,param45, Environment.DBRowSetResult);
END;

Related

IBM ACE - Calling Oracle Procedure returning a rowtype (via ESQL compute node)

I'm trying to call procedure stored in plsql. Here is what I've tried so far.
In Oracle:
create or replace PROCEDURE dbSwapParms
( in_param IN VARCHAR2,
out_param OUT varchar2,
inout_param IN OUT customer%ROWTYPE)
AS
BEGIN
select *
into inout_param
from SYS_ENDPOINTS where customer_name=in_param; -- assuming this query returns single row
END;
In Compute node:
-- Definition of procedure
CREATE PROCEDURE swapParms (
IN parm1 CHARACTER,
OUT parm2 CHARACTER
)
LANGUAGE DATABASE
DYNAMIC RESULT SETS 1
EXTERNAL NAME dbSwapParms;
-- Invoking the procedures
CALL swapParms( inputParm, outputParm, OutputRoot.JSON.Data.test[]); -- found this in ibm documentation returning result set
Here is the error:
BIP2230E: Error detected whilst processing a message in node 'gen.CB_testBar.postHelloWorld (Implementation).Compute4'.
BIP2488E: ('.postHelloWorld_Compute4.Main', '19.4') Error detected whilst executing the SQL statement ''CALL swapParms(inputParm, outputParm, OutputRoot.JSON.Data.test[]);''.
BIP2934E: Error detected whilst executing the function or procedure ''swapParms''.
BIP2321E: Database error: ODBC return code '-1' using ODBC driver manager ''odbc32.dll''.
BIP2322E: Database error: SQL State ''HY000''; Native Error Code '0'; Error Text ''[IBM][ODBC Oracle Wire Protocol driver]SQL type not supported: 0''.
I'm not sure if I've represented the oracle procedure correctly.
I made it work by using plsql function instead of procedure. The function returns ref cursor as a result set. Then, applied the ibm documentation of invoking procedure returning resultset.

How to pass datatable as input to procedure in IIB?

in SQL Server I can create a procedure to receive a datatable as input instead of of primitive type, this way I can pass a list of values, like the example below.
--Create Type
CREATE TYPE dbo.NamesList
AS TABLE
(
fullName VARCHAR(50)
);
--Create Procedure
CREATE PROCEDURE dbo.DoSomethingWithNames
#List AS dbo.NamesList READONLY
AS
BEGIN
SET NOCOUNT ON;
SELECT fullName FROM #List;
END
--Example of SQL Call
--Set variable values
DECLARE #NL NamesList;
INSERT #NL VALUES ('Bill'),('Michael'),('Paul'),('William'),('Kate')
--Call procedure
Exec DoSomethingWithNames #NL
On IBM IIB I can call stored procedures with a code like this:
CREATE PROCEDURE GetFiles (IN idFile INTEGER)
LANGUAGE DATABASE
DYNAMIC RESULT SETS 1
EXTERNAL NAME "dbo.SP_S_FILE";
But I have no idea if it's possible to pass a datatable instead of primitive value and how to it. Any ideas?
Thanks
Have you looked at the PASTHRU statement? I haven't tried doing what you're asking before, but the documentation sounds promising (assuming the limitations don't prevent you from using it).
PASSTHRU can still be used to call stored procedures if:
Only input parameters can be used.
Only single result sets are supported.
If you don't meet these criteria, use the CALL statement because PASSTHRU
imposes limitations (you cannot use output parameters, for example).

Call SQL Server stored procedure using IBM Integration Bus ESQL

I am new to IIB, trying to call SQL server stored procedure using ESQL. Could anyone share working example to call stored procedure which returns single value.
There are 2 ways you can call a stored procedure in ESQL:
Define a procedure with the external keyword
https://www-01.ibm.com/support/knowledgecenter/SSMKHH_9.0.0/com.ibm.etools.mft.doc/ac17040_.htm
Or use the PASSTHRU statement and call the stored procedure by putting the SQL command to call it into the parameter of the statement
https://www-01.ibm.com/support/knowledgecenter/SSMKHH_9.0.0/com.ibm.etools.mft.doc/ak05100_.htm?lang=en

Call Oracle stored procedure with no arguments

I'm trying to call an Oracle stored procedure that accepts no input parameters. However, when running the procedure, I get an error back that states
PLS-00306: wrong number or types of arguments in call to 'MY_PROC'
To call the proc, I'm just entering the following text into TOra:
BEGIN
SCHEMA.MY_PROC();
END;
I've also tried (same error though)
EXEC SCHEMA.MY_PROC();
I'm familiar with MSSQL and I'm able to execute SP with no problem using SQL server, but I can't figure out how to do the same with Oracle. I can't view the actual code for the stored procedure, but from the limited documentation I have, it appears it accepts no input parameters and the return value is a ref cursor. I have a feeling that I need to pass in a ref cursor somehow, but everything I've tried in that regard has not worked.
I just want to view the results of the SP as if I had done a SELECT statement, that is, with the records populating the data grid in the results panel in the TOra interface.
It sounds like the procedure does have an OUT parameter (in Oracle, procedures do not return anything but can have OUT and IN OUT parameters, functions return something). So you would have to pass in a variable for that OUT parameter. Something like
DECLARE
l_results SYS_REFCURSOR;
BEGIN
schema.my_proc( l_results );
END;
should successfully call the procedure. But then you want your GUI to display the results from that cursor. That, unfortunately, gets a little more complicated because now you're talking about a GUI-specific issue.
I don't use TOra, so I don't know what you need to do in TOra to get the cursor to display. In SQL*Plus (or SQL Developer, Oracle's free GUI), you could do something like
create or replace procedure my_proc( p_rc OUT SYS_REFCURSOR )
as
begin
open p_rc
for select 1 col1
from dual;
end;
/
variable rc refcursor;
exec my_proc( :rc );
print rc;
This creates a stored procedure with an OUT parameter that is a cursor, declares a host variable that can be passed in, and then prints the results.

Execute Oracle Stored Proc

I have an oracle stored proc with signiture: (part of package: Contractor)
PROCEDURE usp_sel_contractors(g_contractors OUT sel_contractor);
I am trying to execute it like:
execute Contractor.usp_sel_contractors;
I'm used to MSSqlServer. This seems like it should be strait forward.
I keep getting error:
Invalid Sql Statement
Thanks!
Assuming sel_contractor is a ref cursor type, you could do this in SQL Plus:
var rc refcursor
exec usp_sel_contractors(:rc)
print rc
I'm not sure why you'd be getting that specific error message, but the obvious problem is that the procedure has a parameter and you're not passing one. Since it's an OUT parameter you would need to pass a variable of the appropriate type which will be populated by the procedure.
For example:
DECLARE
my_contractors sel_contractor;
BEGIN
usp_sel_contractors( my_contractors );
// Do something with the contents of my_contractors here
END;
/

Resources