How to do bulk insert using Stored Procedure In Spring DAO? - oracle

Stored Procedure is used to insert rows into Oracle Table. Using Spring DAO, in Data Access Layer. How to do batch insert using Stored Procedure call... Flexiable enough to change SP, if need...

There are a number of ways to do that:
You can change your stored procedure to have array params, then inside your stored procedure you iterate over the arrays and execute the inserts
You batch it on the Java side, and send them all in once. There are 3 ways to do that
Spring : BatchSQLUpdate
Spring : JDBCTemplate.batchUpdate
Java : PreparedStatement.addBatch
These are all to call an SQL statement in a batch, but you can call a stored procedure as well as an sql with the following syntax
:
?=call procedurename(?, ?, ?)

Related

Why stored procedure stage in DataStage not working properly?

I need to use the stored procedure stage.
Currently I'm making just for an example for how to use it right.
CREATE OR REPLACE PROCEDURE "STG"."TRUNC_TEST"
AS
BEGIN
execute immediate 'truncate table TESTSP';
END;
That's my example of simple stored procedure.
My job design probably seen like this
Oracle Connector 1=>Transformer=>Oracle Connector 2=>Stored Procedure Stage
Oracle Connector 1 do Select, Oracle Connector 2 do Insert to TESTSP
My settings in the stored procedure stage
General : I've already put all the credential , with Transaction ISO as None
Syntax
Procedure Name : TRUNC_TEST
Procedure Type : Transform (i've also tried to change it to Target)
Database Procedure Type : Stored Procedure
Generate procedure call (checked)
Parameters
Empty
Error Codes
Empty
NLS Map
Project Default UTF-8
Advanced
Execution mode :Default(Sequential)
Combinability : Default
Configuration file : default
In the Input tabs
General
Execute Procedure for each row (checked)
Transaction size : 0
Partitioning
Collector type Auto
Columns
Just brought all the columns from Oracle connector 2
Advanced
Default
The job showing green line and success, but the SP isn't working. It should've been truncate the TESTSP table, but when I do a select *, the data is still there.
Maybe my stored procedure is wrong since I'm still learning how to make it? Or maybe there is something wrong with my 'Settings' in the stored procedure stage?
Every time you are running your job, you are just creating or replacing the SP definition.
You will have to call the SP in order to execute it.
That is the reason you are able to execute it outside.
I suggest you to create a generic SP in your database which will accept table name as parameter.
Once this is created, use SP stage to invoke the SP with column you want to truncate.
You can also use after SQL option in oracle connector to avoid extra SP stage.

How to get Oracle Stored Procedure result set metadata in JPA/Hibernate?

I have few Oracle Stored Procedure returning SYS_REFCURSOR.
The result set from each SP is different i.e, each stored procedure returns different number of fields and types.
The Java application is using JPA/Hibernate to get the result using StoredProcedureQuery getResultList() API. This is returning an object array (Object[]).
Is there any way to get the meta data for the resultset?
I'm looking for something similar to JDBC ResultSetMetaData but for JPA2/Hibernate.

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

xPages calling a stored procedure

Is there a way to call a stored proc from xPages with parameters ?
I am using #JDBCExecuteQuery("oracle",sql,params)
How am I suppose to call the stored procedure ?
What would you put in your SQL line ?
AFAIK you cannot use a stored procedure with the #JDBC functions. Instead you can create a Java class/managed bean to call a stored procedure via JDBC. I have an example here how to use JDBC with the Extlib RDBMS features here: https://github.com/zeromancer1972/XPages-JDBC/blob/master/Code/Java/org/openntf/jdbc/DataConnector.java
The rules to issue a stored procedure are documented here: https://docs.oracle.com/javase/tutorial/jdbc/basics/storedprocedures.html

Execution of Oracle Procedure prior to Source Qualifier that must use the same Oracle session

I have a security procedure that has to be called just before a select from source table. Without this procedure no rows are returned.
The problem is that I have checked several ways to call this procedure just before Source Qualifier:
Pre-sql into the Source Qualifier As a Stored procedure
Pre-load source
Put several sql sentences in the sql query propertie in Source Qualifier (added 2014-11-08)
Always seems that Powercenter opens a new oracle connection, where security procedure takes no effect.
What could be the correct way to put both process together and use the same Oracle session?
Note added 2014-11-08:
I have tried also to put 2 sentences in the SQL Query of the Source Qualifier:
call procedure('param');
SELECT field1, field2, field.... from VI_ETL...;
and I get error ORA-24333 Zero Interaction Count, perharps because first item is not a SELECT statement that returns rows?
Try using SQL Query on Source Qualifier to invoke a series of statements - the security Stored Procedure being the first one.

Resources