Calling stored procedure with JPA - pass a custom object - stored-procedures

I have a procedure on Oracle database:
TYPE r_age IS RECORD (id VARCHAR2(100),
min VARCHAR2(100),
max VARCHAR2(100));
TYPE t_ages IS TABLE OF r_age INDEX BY BINARY_INTEGER;
PROCEDURE synchronize_ages (p_ages IN t_ages,
err_code OUT VARCHAR2,
err_desc OUT VARCHAR2);
I want to call this procedure using JPA but because of a type of p_ages I don't know how to do it. If the IN type would be a NUMBER or VARCHAR2 it would be easy, but in this example the type is more complex and I got stuck. Unfortunately i can't change this procedure. I use JPA 2.1 and hibernate 5.2. Is there any chance to invoke this procedure?

Related

Error while connecting to stored procedure in Tableau

I'm getting this error while trying to connect to a stored procedure as data source:
Unable to complete action
The stored procedure returned no results. The fields don't have column names, or the data in the fields is not a supported data type
But the same stored procedure returns data in database. Any idea on this?
Please try adding the SET NOCOUNT ON code in the beginning of the stored procedure.
Something like
CREATE PROCEDURE [dbo].[ZZZ_THIS_IS_MY_SP]
#p INT
AS
BEGIN
SET NOCOUNT ON
DECLARE #Var1 NVARCHAR(20)
DECLARE #Var2 DATETIME
-- All other instructions...
END

HSQL problem when using TIMESTAMP value as IN parameter in stored procedure

Overview HSQL IN parameter of type TIMESTAMP doesn't work as expected for HSQL stored procedure.
Given the following DDL :
CREATE TABLE TS_STORE (
ID_COL VARCHAR(20) NOT NULL PRIMARY KEY,
TS TIMESTAMP
);
A DML statement such as :
INSERT INTO TS_STORE (ID_COL, TS) VALUES ('key1', '2020-02-19 12:17:53');
will successfully insert a row.
Then when I attempt to create a stored procedure to do the same as:
CREATE PROCEDURE TEST_PROC(IN IN_KEY VARCHAR(20), IN IN_TS TIMESTAMP)
MODIFIES SQL DATA
BEGIN ATOMIC
INSERT INTO TS_STORE(ID_COL, TS)
VALUES (IN_KEY, IN_TS);
END;
and attempt to call it as:
CALL TEST_PROC('key2', '2020-02-19 12:17:53');
Then I get an error: "incompatible data type in conversion".
This is a problem for me, since I am not allowed to change the signature of the the stored procedure to bypass the problem, since in my case HSQL is used as a mock for a production database (DB2) where the equivalent procedure works as expected.
It works if you call the procedure with a TIMESTAMP value, as opposed to the character string.
CALL TEST_PROC('key2', TIMESTAMP'2020-02-19 12:17:53');

Calling SP throws "ABAP objects and DDIC objects must be declared in the METHOD statement"

I created a stored procedure in HANA and tried to call it through AMDP class.
SP as below;
PROCEDURE "SAPABAP1"."ATU.SF::TESTSPCALL" ( )
LANGUAGE SQLSCRIPT
SQL SECURITY INVOKER
READS SQL DATA AS
BEGIN
SELECT 1 FROM DUMMY;
END;
AMDP Class:
CLASS /ATU/SF_CL_DAILY_MOD_RPT IMPLEMENTATION.
METHOD CALL_DAILY_MOD_RPT_SP by database procedure for hdb language sqlscript.
CALL "SAPABAP1"."ATU.SF::TESTSPCALL" ( );
ENDMETHOD.
ENDCLASS.
However, I cannot activate the above class as I am getting below error.
"ATU.SF::TESTSPCALL" is unknown. ABAP objects and DDIC objects must be
declared in the METHOD statement. Local names must start with ":" here
Any idea?
Call the runtime artifact instead:
"_SYS_BIC"."ATU.SF::TESTSPCALL"( );

Azure logic apps error while calling oracle stored procedure with output parameter

My stored procedure parameters look like this
PROCEDURE PR_NAME
(
fromdate IN NVARCHAR2,
todate IN NVARCHAR2,
myCur OUT SYS_REFCURSOR
)
I call the procedure in sql developer client like this
var c refcursor;
execute PR_NAME ('01-01-2019','01-01-2019 10:00',:c);
print c;
I am trying to create API which call the stored procedure in Logic apps by passing fromdate and todate. But I am getting an error as below.
"Database functions with non-scalar parameters aren't supported.\r\n inner exception: Database functions with non-scalar parameters aren't supported.\r\"
Do someone know why??
There is already a workitem for this and can be tracked in Github. Database functions with non-scalar parameters aren't supported.
https://github.com/MicrosoftDocs/azure-docs/issues/24266

How to define an Array of values (or a Column) into a Procedure Argument?

I am working on a Netezza SP and is stuck with a problem.
I have a SP, defined as say:
CREATE OR REPLACE PROCEDURE MY_PROC(VARCHAR(ANY)) RETURNS INTEGER LANGUAGE NZPLSQL
AS
BEGIN_PROC
DECLARE
v_temp ALIAS FOR $1;
/* Other decalarations */
result_ts INTEGER;
BEGIN
result_ts := 0;
/* Procedure Body */
RETURN result_ts;
EXCEPTION WHEN OTHERS THEN
RAISE NOTICE 'Exception Raised: %', SQLERRM;
END;
END_PROC;
If I am running this SP with one value, such as:
SELECT MY_PROC('TEST_INPUT');
But if I am trying to run it with a column value, such as:
SELECT MY_PROC(TEST_COLUMN) FROM TEST_TABLE;
Its giving me error as:
ERROR: Can't use a stored procedure in this context
I know that in the second scenario I am passing an Array (i guess) but this is not what the Procedure has expected.
Now I am trying to have a procedure that can accept these kind of values but could not succeeded so far, LOOPing and all I have taken care but only problem is the Argument which I don't know how to pass.
Any help would be appreciated, let me know if I need to provide any extra info on this.
Asif
Stored procedures in Netezza, as of v7.2, can only be called in the following ways, as documented here.
CALL sproc_name(...);
EXEC sproc_name(...);
SELECT sproc_name(...);
Note that the SELECT form does not allow a FROM clause.
If you want the stored procedure to act on a particular column from a particular table that changes from invocation to invocation, you could pass the names of those as arguments to the stored procedure and have the entirety of the SQL logic encoded within. You could even pass arbitrary code into the stored procedure to build a query internally.
The way you are trying to call it now is more like calling a user defined function, and that simply won't work with stored procedures here.

Resources