Converting DB2 stored procedure to Oracle?
I need a little help with a problem I ran across this week. I have an existing DB2 Stored procedure that calls a COBOL program. (See the procedure below). Now, I need to convert this DB2 to an Oracle Stored Procedure. I need the procedure to call the same COBOL program that this DB2 procedure does. Is it possible in Oracle? Do I need to write a Java wrapper class instead? Please help!!
CREATE PROCEDURE CO_CASEINFORMATION (
IN PARM1 CHAR(006) FOR SBCS DATA CCSID EBCDIC ,
IN PARM2 CHAR(018) FOR SBCS DATA CCSID EBCDIC ,
IN PARM3 CHAR(004) FOR SBCS DATA CCSID EBCDIC ,
IN PARM4 CHAR(008) FOR SBCS DATA CCSID EBCDIC ,
IN PARM5 CHAR(026) FOR SBCS DATA CCSID EBCDIC
LANGUAGE COBOL
EXTERNAL NAME COSP183
COLLID CACSDEV9
PARAMETER STYLE GENERAL
NOT DETERMINISTIC
MODIFIES SQL DATA
WLM ENVIRONMENT CACSDEV9
STAY RESIDENT YES
RESULT SETS 01
;
Although I've never done that with COBOL, the documentation says it is possible to call an external COBOL procedure from within Oracle, without a Java wrapper class.
The way to do it is to rebuild your COBOL program with the Pro*COBOL pre-compiler.
Read the Pro*COBOL Programmer's Guide for more details.
Similar Messages
-
Please help convert MSSQL Stored Procedure to Oracle PL/SQL
Hi there to all,
this be my first post to these forums. I have already posted this question on a microsoft msdn forum, until someone advised that I ask my question here - dunno why I didnt think of that! ?:|
Im working with an Oracle 10g Database from an ASP.NET 2.0 application, and want to know if it Oracle supports OPENXML (rhetorical question I fear!). The reason I ask is because I want to create an Oracle Stored Procedure that will accept an XML string as an input parameter, prepare it, select from it, and then insert it into an Oracle table.
I have done this successfully in SQL server using the following as an example:
CREATE PROCEDURE [dbo].[Employee_INSERT]
bq. @INSERTRECORD XML
AS
BEGIN
bq. DECLARE @XDOC INT; \\ EXEC sp_xml_preparedocument @XDOC OUTPUT, @INSERTRECORD; \\ INSERT INTO [dbo].[REC_Employees] (
bq. bq. [EMPTITLE], \\ [EMPFNAME], \\ [EMPLNAME], \\ [EMPDEPTID], \\ [EMPBEGINDATE], \\ [EMPACTIVE], \\ [EMPDATEADDED]
bq. )
bq. SELECT
bq. bq. [EMPTITLE] = Title, \\ [EMPFNAME] = Firstname, \\ [EMPLNAME] = LastName, \\ [EMPDEPTID] = DepartmentID, \\ [EMPBEGINDATE] = StartDate, \\ [EMPACTIVE] = IsActive, \\ [EMPDATEADDED] = GETUTCDATE()
bq. FROM
bq. bq. OPENXML(@XDOC, '/EMPREC/Table', 2) \\ WITH (
bq. bq. Title VARCHAR(10), \\ FirstName VARCHAR(50), \\ LastName VARCHAR(50), \\ DepartmentID INT, \\ StartDate DATETIME, \\ IsActive BIT
bq. bq. );
bq. EXEC sp_xml_removedocument @XDOC;
END
I would sincerely appreciate any help in this regard!
PS - Please excuse the formatting!
Much Thanks!
regards
shalanAssuming your table is named DESTINATION
Name Null? Type
TITLE VARCHAR2(10)
FIRSTNAME VARCHAR2(50)
LASTNAME VARCHAR2(50)
DEPARTMENT NUMBER
STARTDATE DATE
ISACTIVE NUMBERYou can use a procedure like:
create or replace
procedure test (p_xml in xmltype)
is
begin
insert into destination
select title
, firstname
, lastname
, department
, to_date (startdate, 'yyyy-dd-mm hh24:mi:ss') startdate
, isactive
from (xmltable ('/EMPREC/Table' passing p_xml
columns title varchar2(5) path 'Title'
, firstname varchar2(10) path 'FirstName'
, lastname varchar2(10) path 'LastName'
, department number path 'Department'
, startdate varchar2(20) path 'StartDate'
, isactive number path 'IsActive'
) temp
end test;to create records in the table
Removed a unnecessary SELECT FROM DUAL...
Edited by: Alex Nuijten on Jan 19, 2009 2:24 PM -
Calling DB2 Stored Proc from Oracle DB
Hi,
I am having two different database running (One is oracle on solaris while the other one is db2 on os/390 mainframe) i want to pass the data realtime. Is there any way I can call a DB2 stored procedure from oracle directly. If anyboy can help in this will be really helpful.
thanks,
Kishorodi version we have is ODI_11.1.1.6.0, it is not migrated and 'Always Execute' option is checked already.
tried using variables in capital format but did not worked,
begin
schema_name.proc_name(#LV_TABLE_NAME,#LV_SCHEMA_NAME,#LV_START_DATE,#LV_END_DATE);
end;
odi is giving error if it finds any bug in stored proc but after fixing its completing successfully without errors in operator but i am not able to see the result.
Please advise. -
DB2 Stored Procedure from Java-JDBC
Hi All,
I am using DB2 stored procedure which have been written in COBOL. I have two types of stored procedures. First types of stored procedure takes IN parameter and returns OUT parameter. These stored procedures are working fine. The second type of stored procedure takes IN parameter and returns a CURSOR. According to Database team (who wrote these stored procedure) claims that they can see data in a cursor when they test these stored procedure directly in the database. However, when I run these stored procedures from Java code it returns NULL ResultSet. Here is the code:
public SearchResult getAllBenefitHEDType(SearchParameter searchParam) throws DAOException {
log.debug(" getAllBenefitHEDType method - entering ");
HashMap searchParametersMap = searchParam.getHashMap();
SearchResult searchResult = new SearchResult();
String type = (String) searchParametersMap.get(UDFConstant.LOOKUP_SEARCH_TYPE);
HashMap resultParametersMap = new HashMap();
ArrayList resultSetDTO = new ArrayList();
try {
conn = this.getConnection();
conn.setAutoCommit(false);
System.out.println("getAllBenefitHEDType Step 1");
CallableStatement cs = conn.prepareCall("{call TEST.APS003(?)}"); // Stored Procedure with one IN parameter.
cs.setString(1,type);
boolean retVal = cs.execute(); // this should return true if ResultSet is available.. in my case it is returning false.
// I tried with getting the Object
ResultSet rs = (ResultSet) cs.getObject(1); // this should give me a valid result set ... in my case I am getting null
if (rs!=null) {
System.out.println("getAllBenefitHEDType Step 4A Result Set Not Null");
} else {
System.out.println("getAllBenefitHEDType Step 4A Result Set Is Null");
// I tried getting the resultset
ResultSet rs1 = cs.getResultSet(); // this should give me a valid result set ... in my case I am getting null
if (rs1!=null) {
System.out.println("getAllBenefitHEDType Step 4D Result Set Not Null");
} else {
System.out.println("getAllBenefitHEDType Step 4D Result Set Is Null");
while (rs.next()) {
System.out.println("getAllBenefitHEDType Step 5");
LookupDTO lookupDTO = new LookupDTO();
// the following code populate the Lookup DTOs from ResultSet.A few comments...
1) Creating tables, particularly tables whose names seem to imply that they are temporary tables, on the fly in a stored procedure is a bad idea. That is not the way to work with Oracle, though it is a common practice in other databases like SQL Server. There is undoubtedly a better way to do this in Oracle if you can explain what you're trying to accomplish from a business standpoint.
2) If you are going to use dynamic SQL, you almost always want to use bind variables, not literals. One of the quickest ways to kill an Oracle database's performance is to not use bind variables.
3) As has already been mentioned, assuming FH_INICIO is a DATE column, you need to put an explicit TO_DATE around your strings in order to convert them to dates. Otherwise, Oracle's implicit cast depends on the session's NLS_DATE_FORMAT, which is likely to be different in different client applications and from different client machines.
Justin -
How to verify stored procedures in Oracle 10g.
I would like to locate default stored procedure in Oracle 10g database.
And Suggest which stored procedure can be converted in to JAVA code ??If the Java part of the question refers to looking for potential to speed up your stored procedures:
You should consider native compilation which transfers your code to shared libraries which are bound to the DB kernel.
In this case however consider, that this does not make any sense/improvement for pure data access statements but only for procedures consisting of complex algorithmic processing.
For details refer to
[How native compilation works|http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/tuning.htm#sthref2280]
and
[Setting Up and Testing PL/SQL Native Compilation|http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/tuning.htm#sthref2309] -
Dear Friends,
I have a lot of c-stored procedures for DB2,
now,I want to use these c-stored procedures in Oracle directly without any changes.
I'm not sure whether this method is right.
Please help me.
GuangI think, that the best way inclusion of business logic into ORACLE database as a TABLE-constraints, triggers and stored procedures for guaranteeing data integrity.
But if you have really a LOT of c-stored procedures and you need provide quick startup with ORACLE, than you can use your c-procedures as "external calls" with ORACLE.
Unfortunately I don't know DB2 c-stored procedures specifics and can't give finally recommendations for you.
Sincerely, Urry -
Intergration with DB2 stored procedure
I am using Database adapter to integrate with DB2(version 8) to call a stored procedure,however i receive a message "The adapter configurationwizard doesnot support DB2 stored procedures."
I am using Jdeveloper 11g.Is there any work around or any other standard method for this.
Thanks in advance...Hi,
All explanation on Oracle note 1270851.1
Arik -
Hi,
Following is my question.
From Forte, How to call to a DB2 stored procedure which acceptsparameters?.
If anybody knows the answer please mail me to [email protected]
Thank U in Advance
RamYou might want to look into the documentation for the Oracle Transparent Gateway product for DB2. That should let you link to DB2 data from your Oracle database & stored procedures.
Justin Cave -
Need sample source code for calling stored procedure in Oracle
Hi.
I try to call stored procedure in oracle using JCA JDBC.
Anybody have sample source code for that ?
Regards, Arnold.Thank you very much for a very quick reply. It worked, but I have an extended problem for which I would like to have a solution. Thank you very much in advance for your help. The problem is described below.
I have the Procedure defined as below in the SFCS1 package body
Procedure Company_Selection(O_Cursor IN OUT T_Cursor)
BEGIN
Open O_Cursor FOR
SELECT CompanyId, CompanyName
FROM Company
WHERE CompanyProvince IN ('AL','AK');
END Company_Selection;
In the Oracle Forms, I have a datablock based on the above stored procedure. When I execute the form and from the menu if I click on Execute Query the data block gets filled up with data (The datablock is configured to display 10 items as a tabular form).
At this point in time, I want to automate the process of displaying the data, hence I created a button and from there I want to call this stored procedure. So, in the button trigger I have the following statements
DECLARE
A SFCS1.T_Cursor;
BEGIN
SFCS1.Company_Selection(A);
go_Block ('Block36');
The cursor goes to the corresponding block, but does not display any data. Can you tell me how to get the data displayed. In the future versions, I'm planning to put variables in the WHERE clause. -
How to use a stored procedure in oracle reports
How to use a stored procedure in oracle reports
Dear,
In report triggers you can write your procedure/functions or call it like
function AfterPForm return boolean is
begin
myprocedure(:mydate);
return (TRUE);
end;
Thanks
Jamil -
SQLException while calling a Stored Procedure in Oracle
Hi all,
I am getting this error while calling a Stored Procedure in Oracle...
java.sql.SQLException: ORA-00600: internal error code, arguments: [12259], [], [
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:207)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:540)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1273)
at oracle.jdbc.ttc7.TTC7Protocol.fetch(TTC7Protocol.java:780)
at oracle.jdbc.driver.OracleResultSet.next(OracleResultSet.java:135)
at StoredProcedureDemo.main(StoredProcedureDemo.java:36)
The Program is ...
import java.sql.*;
public class StoredProcedureDemo {
public static void main(String[] args) throws Exception {
Connection con = null;
ResultSet rs = null;
Statement st = null;
CallableStatement cs = null;
int i;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
con = DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:SHYAM","scott","tiger");
System.out.println("Got Connection ");
st = con.createStatement();
String createProcedure = "create or replace PROCEDURE Get_emp_names (Dept_num IN NUMBER) IS"
+" Emp_name VARCHAR2(10);"
+" CURSOR c1 (Depno NUMBER) IS"
+" SELECT Ename FROM emp WHERE deptno = Depno;"
+" BEGIN"
+" OPEN c1(Dept_num);"
+" LOOP"
+" FETCH c1 INTO Emp_name;"
+" EXIT WHEN C1%NOTFOUND;"
+" END LOOP;"
+" CLOSE c1;"
+" END;";
System.out.println("Stored Procedure is \n"+createProcedure);
i = st.executeUpdate(createProcedure);
System.out.println("After creating the Stored Procedure "+i);
cs = con.prepareCall("{call Get_emp_names(?)}");
System.out.println("After calling the Stored Procedure ");
cs.setInt(1,20);
System.out.println("Before executing the Stored Procedure ");
rs = cs.executeQuery();
System.out.println("The Enames of the given Dept are ....");
while(rs.next()) {
System.out.println("In The while loop ");
System.out.println(rs.getString(1));
catch (Exception e) {
e.printStackTrace();
Stored Procedure is ...
create or replace PROCEDURE Get_emp_names (Dept_num IN NUMBER) IS
Emp_name VARCHAR2(10);
CURSOR c1 (Depno NUMBER) IS
SELECT Ename FROM emp WHERE deptno = Depno;
BEGIN
OPEN c1(Dept_num);
LOOP
FETCH c1 INTO Emp_name;
EXIT WHEN C1%NOTFOUND;
END LOOP;
CLOSE c1;
END;
Stored procedure is working properly on sql*plus(Oracle 8.1.5)) editor. But it is not working from a standalone java application. Can anyone please give me a solution.
thanks and regards
Shyam KrishnaThe first solution is to not do that in java in the first place.
DDL should be in script files which are applied to oracle outside of java.
Other than I believe there are some existing stored procedures in Oracle that take DDL strings and process them. Your user has to have permission of course. You can track them down via the documentation. -
To call db2 stored procedure having parameters in java application
Hi,
I've created db2 stored procedure which is running perfectly on db2 server after giving a CALL to it. But when I tried to call this same stored procedure in java application, its reflecting with following error......
com.ibm.db2.jcc.b.SqlException: [jcc][10100][10910][3.50.152] java.sql.CallableStatement.executeQuery() was called but no result set was returned.
Use java.sql.CallableStatement.executeUpdate() for non-queries. ERRORCODE=-4476, SQLSTATE=null
at com.ibm.db2.jcc.b.wc.a(wc.java:55)
at com.ibm.db2.jcc.b.wc.a(wc.java:102)
at com.ibm.db2.jcc.b.tk.b(tk.java:575)
at com.ibm.db2.jcc.b.vk.yb(vk.java:136)
at com.ibm.db2.jcc.b.vk.executeQuery(vk.java:114)
at SPApplication.main(SPApplication.java:31)
Here is the code.......
import java.sql.*; public class SPApplication { public static Connection con; public static CallableStatement proc_stmt; public static ResultSet rs; /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub try { Class.forName("DB2 DRIVER CLASS"); System.out.println("Class loaded....."); con = DriverManager.getConnection("jdbc:db2://localhost:PORTNO/" + " DatabaseName", "username", "password"); System.out.println("Connection established....."); proc_stmt = con.prepareCall("call procedure_name(?)"); //IN Parameter proc_stmt.setInt(1, 5); System.out.println("Called procedure....."); rs = proc_stmt.executeQuery(); /******** THIS IS LINE NO. 31 *********/ while (rs.next()) { // Fetching rows one by one over here } proc_stmt.close(); rs.close(); con.close(); } catch (ClassNotFoundException cnfe) { cnfe.printStackTrace(); } catch (SQLException sqle) { sqle.printStackTrace(); } finally { /* try { proc_stmt.close(); rs.close(); con.close(); } catch (SQLException sqle) { sqle.printStackTrace(); } */ } } }
Please correct me, if I am wrong at any point in my application..
I would really appreciate for resolving my problem.
Thanks,
Manasi N.Hi jschell ,
Firstly, I tried out with execute() and getMoreResults() to check if the statement is returning result set. - Its returning "null" only.
Secondly, I tried with following one by one :
1. Find a new jdbc driver
2. Write a different stored procedure.I am using DB2 Express edition - DB2 v9.7.0.0
I have the required jar files - i)db2jcc.jar ii) db2jcc_license_cu.jar
From these I found the available jdbc drivers as -
i) com.ibm.db2.jcc.DB2Driver
ii) COM.ibm.db2os390.sqlj.jdbc.DB2SQLJDriver
iii) com.ibm.db2.jcc.uw.DB2StoredProcDriver
I tried out my code by using each of these drivers, but still returning result set as null.
Moreover, I changed my stored procedure which has cursor returning result set. In this case also, result set is null.
Code snippet for this SP is -
30 Class.forName("com.ibm.db2.jcc.uw.DB2StoredProcDriver");
31 System.out.println("Class loaded....");
32 con = DriverManager.getConnection
33 ("jdbc:db2://localhost:portno/dbName", "user", "password");
34 System.out.println("Connection established....");
35
36 proc_stmt = con.prepareCall("call javaSP()");
37
38 System.out.println("Called stored procedure....");
39
40 proc_stmt.execute();
41 //proc_stmt.executeUpdate();
42 //rs = proc_stmt.getResultSet();
43
44 System.out.println("Query executed....");
45
46 if ((proc_stmt.getMoreResults() == false) &&
47 (proc_stmt.getUpdateCount() == -1)) {
48 System.out.println("No more result sets");
49 }o/p is (for every mentioned above jdbc driver) :-
Class loaded....
Connection established....
Called stored procedure....
Query executed....
No more result sets..
The o/p is always "No more result sets"
What else can be tried out to retrieve the result set from stored procedure from Java application? And the most important, these same stored procedures are returning result sets on db2 server after calling them.
Thank you,
Manasi.N
Edited by: Manasi.N on Apr 14, 2010 12:27 AM
Edited by: Manasi.N on Apr 14, 2010 12:28 AM -
Calling Stored Procedure from Oracle DataBase using Sender JDBC (JDBC-JMS)
Hi All,
We have requirement to move the data from Database to Queue (Interface Flow: JDBC -> JMS).
Database is Oracle.
*Based on Event, data will be triggered into two tables: XX & YY. This event occurs twice daily.
Take one field: 'aa' in XX and compare it with the field: 'pp' in YY.
If both are equal, then
if the field: 'qq' in YY table equals to "Add" then take the data from the view table: 'Add_View'.
else if the field: 'qq' in YY table equals to "Modify" then take the data from the view table: 'Modify_View'.
Finally, We need to archive the selected data from the respective view table.*
From each table, data will come differently, means with different field names.
I thought of call Stored Procedure from Sender JDBC Adapter for the above requirement.
But I heard that, we cannot call stored procedure in Oracle through Sender JDBC as it returns Cursor instead of ResultSet.
Is there any way other than Stored Procedure?
How to handle Data Types as data is coming from two different tables?
Can we create one data type for two tables?
Is BPM required for this to collect data from two different tables?
Can somebody guide me on how to handle this?
Waiting eagerly for help which will be rewarded.
Thanks and Regards,
Jyothirmayi.Hi Gopal,
Thank you for your reply.
>Is there any way other than Stored Procedure?
Can you try configuring sender adapter to poll the data in intervals. You can configure Automatic TIme planning (ATP) in the sender jdbc channel.
I need to select the data from different tables based on some conditions. Let me simplify that.
Suppose Table1 contains 'n' no of rows. For each row, I need to test two conditions where only one condition will be satisfied. If 1st condition is satisfied, then data needs to be taken from Table2 else data needs to be taken from Table3.
How can we meet this by configuring sender adapter with ATP?
================================================================================================
>How to handle Data Types as data is coming from two different tables?
If you use join query in the select statement field of the channel then whatever you need select fields will be returned. This might be fields of two tables. your datatype fields are combination of two diff table.
we need to take data only from one table at a time. It is not join of two tables.
================================================================================================
Thanks,
Jyothirmayi. -
Calling stored procedure in Oracle forms
I have a stored procedure in Oracle which is declared as follows in the package
SFCS1.Company_Selection(O_Cursor IN OUT T_Cursor, cls IN Varchar2);
Where T_Cursor is defined as a Ref Cursor
From the Oracle forms I'm using the following code
SFCS1.Company_Selection(A,my_cls);
go_block('Block50');
Execute_Query;
I get the error message "FRM40505:Oracle Error: Unable to Perform Query". If I hardcode the value of my_cls in the query it runs properly. Any solutions will be really helpful
Further to this, I want to put the single quotes around a value (for eg. 'A') from a variable. For instance I'm getting a value from my_cls and for the output I want to surround it with the single quotes, can somebody tell me how to do it.
Thanks in advanceThis is a bit of a roundabout way to do it? Try setting up the block data source as procedure and set the values in the property palette of the data block.
e.g.
Query Data Source Type = Procedure
Query Data Source Name = SFCS1.Company_Selection
Query Data Source Columns = (Whatever columns/items you have in your datablock)
Query Data Source Arguments = Argument names are your ref cursor and your variable.
Check out basing data blocks on Ref Cursors.
HTHs
L :-) -
How to write a PL/SQL stored procedure in Oracle to call Webservice
Can any one pelase send me a code on how to write a PL/SQL stored procedure in Oracle database to call the Webservice ?
Thanks,
RajeshWere you able to solve this problem
Maybe you are looking for
-
Hi can any body please tell me how to open the .exe files in mac and why it is not supported with unarchiever app , also i am not able to run and dvd's in my mac its not accepting any cd's or dvd'd why? do i need to do some pre defined settings to
-
Hello. Recently, I Add a New Server Node on Java Central Instance. And Java Program Upload on Portal, then following error occured. Error in the listener class com.sap.ip.portal.admin.portalanywhere.QueryHandler during the process of handleTopic Orig
-
Is there anyway for me to extend the duration of trailer in iPad.
im using imovie in ipad2, i want to extend the duration of the trailer, is there anyway i can do like mac book air.
-
Mail - Looking for a spotlight plugin that is not installed...
I'm migrating a large mail database from another mail server to Lion Server Mail and it is going fine, but I am seeing lots of errors like this: Cannot find function pointer OfficeImporterPluginFactory for factory BFA4E323-1889-11D9-82C8-000A959816BE
-
Activation of M records failure in DSO in process chain during weekend
Hi Experts, We have got same issue again but this time after a month's time. Once again it happened during weekend and this is error message which is same as it was in the past : - Error occurred while deciding partition number PSA update failed Proc