Calling 9iLite Stored Procs via ODBC from C/C++
Hi all,
The Oracle 9i Lite documentation seems to offer contradictory advice on calling stored procedures over ODBC using C/C++.
Page 2-11 of Oracle9i Lite "Developer's Guide for Java" (pdf) states "Oracle Lite does not support the SQL CALL statement for invoking stored procedures". Page 2-23 of the same document states "to execute a stored procedure....use the following CALL statement".
Does anyone know what the correct method is? CALL does not work for me, but I don't know if it's a coding error, or whether I need to invoke the SP a different way.
thanks for any help you can give,
Owen.
Since Mr. Tamashunas's question began elsewhere, I'll give some background for others. Mr. Tamashunas has an ASP (using ADO) using the following code:
Oracle Package / Proc:
CREATE OR REPLACE PACKAGE BODY UserInfo
AS
PROCEDURE sp_getUsers (
p_errcode out NUMBER,
p_errdesc out VARCHAR2,
iCurs in out tCurs)
IS
BEGIN
p_errcode := 0;
OPEN iCurs for Select * from naowner.users;
EXCEPTION
When others then
p_errcode := SQLCODE;
p_errdesc := SQLERRM;
end sp_getUsers;
END; -- package body
ASP code:
strConn = Session("dbConnStr")
cnnOracle.Open strConn
'Creates a command object.
Set cmdPackage = Server.CreateObject("ADODB.Command")
Set cmdPackage.ActiveConnection = cnnOracle
cmdPackage.CommandType = adCmdStoredProc
cmdPackage.CommandText = "UserInfo.sp_getUsers"
'cmdStoredProc.CommandText = "{call UserInfo.sp_addUser(?,?,?,?)}"
cmdStoredProc.Parameters.Append
cmdStoredProc.CreateParameter("errcode",adInteger,adParamOutput)
cmdStoredProc.Parameters.Append
cmdStoredProc.CreateParameter("errdesc",adVarChar,adParamOutput,1000)
cmdStoredProc.Execute
---------- or -----------------
Session("dbConnStr") = "DSN=novoarch;UID=naowner;PWD=nadba"
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open Session("dbConnStr")
set rs = objConn.execute("{call LogUtils.sp_getloginfo(:p_errcode, :p_errdesc,
:iCurs)}")
SQLBindParameter is an ODBC API call that allows you to bind parameters to procedure calls, rather than providing the parameters explicitly, i.e.
{call foo( 1, 2, 'abc' )}
vs
{call foo( ?, ?, ? )}
ADO is a higher-level interface to ODBC (or OLEDB). In ADO, you accomplish the same thing with the CreateParameter & Parameter.Append functions in your code.
Justin Cave
ODBC Development
Similar Messages
-
Problem Obtaining multiple results from MySql Stored Proc via JDBC
I've spent alot of time on this and I'd be really grateful for anyones help please!
I have written a java class to execute a MySQL stored procedure that does an UPDATE and then a SELECT. I want to handle the resultset from the SELECT AND get a count of the number of rows updated by the UPDATE. Even though several rows get updated by the stored proc, getUpdateCount() returns zero.
It's like following the UPDATE with a SELECT causes the updatecount info to be lost. I tried it in reverse: SELECT first and UPDATE last and it works properly. I can get the resultset and the updatecount.
My Stored Procedure:
delimiter $$ CREATE PROCEDURE multiRS( IN drugId int, IN drugPrice decimal(8,2) ) BEGIN UPDATE drugs SET DRUG_PRICE = drugPrice WHERE DRUG_ID > drugId; SELECT DRUG_ID, DRUG_NAME, DRUG_PRICE FROM Drugs where DRUG_ID > 7 ORDER BY DRUG_ID ASC; END $$
In my program (below) callablestatement.execute() returns TRUE even though the first thing I do in my stored proc is an UPDATE not a SELECT. Is this at odds with the JDBC 2 API? Shouldn't it return false since the first "result" returned is NOT a resultset but an updatecount? Does JDBC return any resultsets first by default, even if INSERTS, UPDATES happened in the stored proc before the SELECTs??
Excerpt of my Java Class:
// Create CallableStatement CallableStatement cs = con.prepareCall("CALL multiRS(?,?)"); // Register input parameters ........ // Execute the Stored Proc boolean getResultSetNow = cs.execute(); int updateCount = -1; System.out.println("getResultSetNow: " +getResultSetNow); while (true) { if (getResultSetNow) { ResultSet rs = cs.getResultSet(); while (rs.next()) { // fully process result set before calling getMoreResults() again! System.out.println(rs.getInt("DRUG_ID") +", "+rs.getString("DRUG_NAME") +", "+rs.getBigDecimal("DRUG_PRICE")); } rs.close(); } else { updateCount = cs.getUpdateCount(); if (updateCount != -1) { // it's a valid update count System.out.println("Reporting an update count of " +updateCount); } } if ((!getResultSetNow) && (updateCount == -1)) break; // done with loop, finished all the returns getResultSetNow = cs.getMoreResults(); }
The output of running the program at command line:
getResultSetNow: true 28, Apple, 127.00 35, Orange, 127.00 36, Bananna, 127.00 37, Berry, 127.00 Reporting an update count of 0
During my testing I have noticed:
1. According to the Java documentation execute() returns true if the first result is a ResultSet object; false if the first result is an update count or there is no result. In my java class callablestatement.execute() will return TRUE if in the stored proc the UPDATE is done first and then the SELECT last or vica versa.
2. My java class (above) is coded to loop through all results returned from the stored proc in succession. Running this class shows that any resultsets are returned first and then update counts last regardless of the order in which they appear in the stored proc. Maybe there is nothing unusual here, it may be that Java is designed to return any Resultsets first by default even if they didn't happen first in the stored procedure?
3. In my stored procedure, if the UPDATE happens last then callablestatement.getUpdateCount() will return the correct number of updated rows.
4. If the UPDATE is followed by a SELECT (see above) then callablestatement.getUpdateCount() will return ZERO even though rows were updated.
5. I tested it with the stored proc doing SELECT - UPDATE - SELECT and again getUpdateCount() returns ZERO.
6. I tested it with the stored proc doing SELECT - UPDATE - SELECT - UPDATE and this time getUpdateCount() returns the number rows updated by the last UPDATE and not the first.
My Setup:
Mac OS X 10.3.9
Java 1.4.2
mysql database 5.0.19
mysql-connector 5.1.10 (connector/J)
Maybe I have exposed a bug in JDBC?
Thanks for your help.plica10 wrote:
Jschell thank you for your response.
I certainly don't mean to be rude but I often get taken that way. I like to state facts as I see them. I'd love to be proved wrong because then I would understand why my code doesn't work!
Doesn't matter to me if you are rude or not. Rudeness actually makes it more entertaining for me so that is a plus. Nothing I have seen suggests rudeness.
In response to your post:
When a MySql stored procedure has multiple sql statements such as SELECT and UPDATE these statements each produce what the Java API documentation refers to as 'results'. A Java class can cycle through these 'results' using callableStatement dot getMoreResults(), getResultSet() and getUpdateCount() to retrieve the resultset object produced by Select queries and updateCount produced by Inserts, Deletes and Updates.
As I read your question it seems to me that you have already proven that it does not in fact do that?
You don't have to read this but in case you think I'm mistaken, there is more detail in the following website under the heading 'Using the Method execute':
http://docsrv.sco.com/JDK_guide/jdbc/getstart/statement.doc.html#1000107
Sounds reasonable. But does not your example code prove that this is not what happens for the database and driver that you are using?
Myself I dont trust update counts at all since, in my experience some databases do not return them. And per other reports sometimes they don't return the correct value either.
So there are two possibilities - your code is wrong or the driver/database does not do it. For me I would also question whether in the future the driver/database would continue to behave the same if you did find some special way to write your SQL so it does do it. And of course you would also need to insure that every proc that needed this would be written in this special way. Hopefully not too many of those.
So this functionality is built into java but is not in common use amongst programmers. My java class did successfully execute a stored proc which Selected from and then finally Updated a table. My code displayed the contents of the Select query and told me how many rows were affected by the update.
It isn't "built into java". It isn't built into jdbc either. If it works at all then the driver and by proxy the database are responsible for it. I suspect that you would be hard pressed to find anything in the JDBC spec that requires what that particular link claims. I believe it is difficult to find anything that suggests that update counts in any form are required.
So you are left with hoping that a particular driver does do it.
I suppose it is rare that you would want to do things this way. Returning rowcounts in OUT parameters would be easier but I want my code to be modular enough to cover the situation where a statement may return more than one ResultSet object, more than one update count, or a combination of ResultSet objects and update counts. The sql may need to be generated dynamically, its statements may be unknown at compile time. For instance a user might have a form that allows them to build their own queries...
Any time I see statements like that it usually makes me a bit uncomfortable. If I am creating data layers I either use an existing framework or I generate the code. For the latter there is no generalization of the usage. Every single operation is laid out in its own code.
And I have in fact created generalized frameworks in the past before. I won't do it again. Benefits of the other idioms during maintenance are too obvious. -
S'one tell me how to call Oracle Stored Proc from Java
Hi,
I have a problem in calling the Stored proc using callable statement.It looks like we are doing the same thing or no..
Pl..let me know if you can correct me..Am enclosing the stored proc and java Code...
CREATE OR REPLACE PROCEDURE StoreFTPAddress (FTP in FTPTYPE) is
BEGIN
INSERT INTO DES.FTPSERVICE(
FTPID,
COMPANYID,
SERVERNAME,
DIRECTORY,
USERNAME,
PASSWORD,
INSTRUCTIONS)
VALUES( FTPID.NEXTVAL,
FTP.COMPANYID,
FTP.SERVERNAME,
FTP.DIRECTORY,
FTP.USERNAME,
FTP.PASSWORD,
FTP.INSTRUCTIONS);
END;
JAVA CODE :;
public String retrieveFormatExtension(String formatName)
OracleResultSet rs_form = null;
try
conn = ConnectionDataObjectImpl.getConnection();
Statement stmt = conn.createStatement();
String sql_retrieve = "{call retrieveFormatExtension} " ;
CallableStatement cst = conn.prepareCall(
"{call retrieveFormatExtension(?,?)}");
cst.setString(1," FName ");
cst.registerOutParameter(1, OracleTypes.VARCHAR); // OUT Parameter
cst.executeQuery();
rs_form = (OracleResultSet) cst.getObject(1);
cst.close();
catch (SQLException ex)
System.out.println("SQLException : " + ex.getMessage());
return null;
Regards
Deepauk
[email protected]
nullSyntactically it looks fine. Only thing is u r calling the proc with wrong name. Your procedure takes only one parameter and i.e
IN type. I think u need to correct ur preparecall statement.
<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Ayappa:
Hi,
I have a problem in calling the Stored proc using callable statement.It looks like we are doing the same thing or no..
Pl..let me know if you can correct me..Am enclosing the stored proc and java Code...
CREATE OR REPLACE PROCEDURE StoreFTPAddress (FTP in FTPTYPE) is
BEGIN
INSERT INTO DES.FTPSERVICE(
FTPID,
COMPANYID,
SERVERNAME,
DIRECTORY,
USERNAME,
PASSWORD,
INSTRUCTIONS)
VALUES( FTPID.NEXTVAL,
FTP.COMPANYID,
FTP.SERVERNAME,
FTP.DIRECTORY,
FTP.USERNAME,
FTP.PASSWORD,
FTP.INSTRUCTIONS);
END;
JAVA CODE :;
public String retrieveFormatExtension(String formatName)
OracleResultSet rs_form = null;
try
conn = ConnectionDataObjectImpl.getConnection();
Statement stmt = conn.createStatement();
String sql_retrieve = "{call retrieveFormatExtension} " ;
CallableStatement cst = conn.prepareCall(
"{call retrieveFormatExtension(?,?)}");
cst.setString(1," FName ");
cst.registerOutParameter(1, OracleTypes.VARCHAR); // OUT Parameter
cst.executeQuery();
rs_form = (OracleResultSet) cst.getObject(1);
cst.close();
catch (SQLException ex)
System.out.println("SQLException : " + ex.getMessage());
return null;
Regards
Deepauk
[email protected]
<HR></BLOCKQUOTE>
null -
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. -
Calling stored proc via services
I would be grateful if you could help me in resolving a technical issue in CMS(stellent).
We have a requirement that we need to call a stored procedure through services .The stored proc takes an input argument and returns a result set and has a defination that starts like
create or replace
PACKAGE BODY GETPROJECTPCKG IS
PROCEDURE PROC_RPU (rpu_list_count IN number, temp_project_cursor OUT project_ref_cursor) IS.
I've defined a service call like
<tr>
<td>GET_RPU_INFO</td>
<td>DocService
33
RECENTPROJECTUPDATE
null
null<br>
null</td>
<td>5:QgetRpuNames:temp_project_cursor::null</td>
</tr>
And below is how I've called the procedure
<tr>
<td>QgetRpuNames</td>
<td>{call GETPROJECTPCKG.PROC_RPU(?)}</td>
<td>rpu_list_count int</td>
</tr>
i tried calling procedure as below also ..
<tr>
<td>QgetRpuNames</td>
<td>{call GETPROJECTPCKG.PROC_RPU(?,?)}</td>
<td>rpu_list_count int
temp_project_cursor out:resultset</td>
</tr>
As per my understanding the temp_project_cursor which is the resultset that would be returned from procedure should be available on the template specified.
But while executing the service I am getting an error :
Unable to create result set for query 'QgetRpuNames({call GETPROJECTPCKG.PROC_RPU(10)})'. ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'PROC_RPU'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored)
Can you please assist.Hey
if this is still an issue please refert "Call Stored Procedure from Oracle Fusion ECM (Stellent) " at http://www.corecontentonly.com/index.php/downloads/. Jason has shared a component that you can make use of.
cheers,
sapan -
Trying to call a stored proc from a form ?
Hi im trying to call a stored procedure that create a web page
any where from within a form. (the SP It uses the htp package).
It does not seem to work.
lets say in the PL/SQL block before the footer i pu
<schema>.my_procedure;
i get a not decleared <schema>.my_procedure error.
Could someone help !
Also is there a way to call stored proc directly from the url
I tried httP://hostname/pls/portal30/<schema>.my_procedure
unsuccessful.
thanksFor it to work, you should grant EXECUTE on your Procedure to
PUBLIC.
Have you done that?
If yes then there is a problem. -
Is there a way to call a stored proc from the web in Oracle 10g?
I've found an article about Native Oracle XML DB Web Services in 11g, but it appears to be a new feature. Is there any way of accomplishing something similar in 10g? I would like to be able to process XML documents that contain the name and parameters of the stored proc/function to execute.
Link to 11g article:
http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28369/xdb_web_services.htmI agree with you. I was looking into mod_plsql, but it turns out that their development standards include not using Oracle HTTP server. The whole reason why they want to be able to execute a stored proc based on what is specified in an XML doc is that they want to avoid having to change their middle-tier configurations anytime a new stored proc or a change in stored proc parameters is made. I'm not familiar with what all is involved with .NET and the middle-tier, but supposedly this way, they can specify any stored procedure name and its parameters in an XML file. The XML is then suppose to be passed on to an Oracle stored procedure which will parse the XML and dynamically execute the stored procedure that was specified in the XML.
Here is an example of the XML:
'<Root>
<PackageName>TEST_PKG</PackageName>
<ProcedureName>TEST_PROC</ProcedureName>
<Parameters>
<Parameter>
<Name>EmpID</Name>
<Value>12345</Value>
</Parameter>
<Parameter>
<Name>Org</Name>
<Value>ABC</Value>
</Parameter>
</Parameters>
</Root>I basically need to parse out the pkg/proc names:
SELECT t.COLUMN_VALUE.extract('//PackageName/text()').getstringval() PkgName,
t.COLUMN_VALUE.extract('//ProcedureName/text()').getstringval() ProcName
INTO v_pkg_name, v_proc_name
FROM TABLE(xmlsequence(XMLTYPE(v_XML_input) .extract('/Root'))) t;...and then execute the procedure:
EXECUTE IMMEDIATE 'BEGIN '||v_pkg_name||'.'||v_proc_name||'(:a, :b, :c); END;'
using in v_in_param1, v_in_param2, out v_XML_output;The problem is that this approach is very complicated since there can be any number of IN/OUT parameters and of various datatypes. I would have to create all kinds of possible bind variables! -
Calling a storeed proc from jap
How do we call a stored procedure from a jsp?
And to do the call (either from the JSP, which I also don't recommend, or from somewhere else) use CallableStatement. Read the API documentation for more information on how to use it.
Alin. -
Best place in VOimpl java code to call a stored proc to populate results
Hello all,
Using JDev 11g, ADF BC and Trinidad.
I am building an application that is primarily used for searching large amounts of data. We already have stored procedures on the database that perform the searches and dump the results into a holding table (together with a "search id"). I have easilly built a prototype of this application: my view object is simply "select a, b, c from results where search_id = :bv" - I have a service method in the AM that runs the stored procedure, obtains the search ID, binds it to the :bv in the VO and executes the VO's query - it's all working really nicely. Range paging is effective, the VO itself performs well, and I am able to control how long the stored proc runs via setting a timeout value.
Now, I'd like to generalize this. My thinking is this:
1). I'll add a custom property to my VO that is the SQL statement needed to call the stored procedure.
2). I'll add some bind variables to the VO to represent all the query parameters that can be passed to the stored proc. I'll also use custom properties to indicate these are "fake" bvs, and not in the SQL query itself.
3). The VO's SQL will remain simply "select a, b, c from results where search_id = :bv"
4). I will (have already tested) override bindParametersForCollection so that the "fake" bind variables aren't bound into the SQL.
Now, the question: I want to override some method in the VO's java code to call the stored procedure. The stored proc needs to be called before the actual query for the VO is run, and also before the method getQueryHitCount is called (so that the count is correct). What is the method that would be the "best" place to do this? My current thinking is that I would put the call in an over-ridden executeQueryForCollection call. As far as my analysis has gone, it seems to be always called before getQueryHitCount, but I have no way of knowing if this is completely safe.
Any thoughts from the BC experts out there?
Best regards,
JohnJohn,
from your description I understand that you essentially program the VO yourself. So I suggest that you read chapter 35.9 of the 'Fusion Developer’s Guide for Oracle Application Development Framework' (I guess you know where to find it). Since you still call the actual SQL not all of the chapter apply, but you get the idea how it works.
And yes you analyzed the behavior correct. executeQueryForCollection() is allways called bevore getQueryHitCount().
Timo -
How pass ext characters to a stored proc by odbc when enable sqlserver syntax is on??
how pass french characters or extended characters to a stored procedure by odbc
error: ORA-01756: quoted string not properly terminated
une chaine entre apostrophhes ne se termine pas correctement
oracle Retrieving extended characters thru ODBC
PL/SQL procedure parameters
hi, i hope you can help to me.
I have a problem with french and german characters.
i have a little stored procedure than return what i'm passing to him.
see these example: (the second one work fine on plsql)
first exemple:
1) i created a new odbc dsn
2) i'm going into sqlserver migration tab to choose
Enable Exac Syntax.
3) i'm open Winsql (this is a odbc tools)
http://www.indus-soft.com/winsql/
4) i'm write
exec ksp_test 0,'HiLLO ORACLE'
i receive this error:
Error: ORA-01756: quoted string not properly terminated
(State:S1000, Native Code: 6DC)
I trying to changed too the NLS_LANG in the registry
like FRENCH_CANADA.WE8ISO8859P1
French_France.WE8ISO8859P1
but without any success..
i got the same problem with
oracle 9 database with utf8 characters set.
oracle 8.1.7 with iso8859p1 characters set.
i trying all latest odbc driver from oracle website.
second exemple:
SQL> variable mytest refcursor;
SQL> exec ksp_test (0,'HiLLO ORACLE',:MYTEST);
PL/SQL procedure successfully completed.
SQL> PRINT MYTEST;
Your Database Value
HiLLO ORACLE
CREATE OR REPLACE PACKAGE KSP_PLSQLRSETPKG
AS
TYPE RCT1 IS REF CURSOR;
END;
CREATE OR REPLACE PROCEDURE KSP_TEST (
PATCH INT DEFAULT 0,
PONC VARCHAR2,
RC1 IN OUT KSP_PLSQLRSETPkg.RCT1
AS
BEGIN
OPEN RC1 FOR
SELECT PONC "Your Database Value" FROM DUAL;
FROM DUAL;
RETURN ;
END;
i'm trying also different nls setting but no good result.
AMERICAN_AMERICA.US7ASCII
AMERICAN_AMERICA.WE8MSWIN1252
FRENCH_CANADA.WE8DEC
FRENCH_CANADA.UTF8
FRENCH_CANADA.WE8MSWIN1252
FRENCH_FRANCE.WE8DEC
FRENCH_FRANCE.UTF8
FRENCH_FRANCE.WE8MSWIN1252
is working well on sqlplus but not by odbc..
also..
i'm declare a variable and
i set
v_variable := 'id'
and the procedure return the good syntax...
i think is a odbc driver problem....
the driver don't want to accept a extended characters set by a parameters coming from the procedure.
can you confirm to me ..this is a major bug for the driver..
my procedure is very basic to make a little test.
did you try my procedure to be sure you have the same problem?
i try with a oracle instance utf8,WE8MSWIN1252 and
i got always the same problem.
if i write insert into test values ('di');
everything is fine...but when i call the procedure...
the procedure don't want to accept any german..french or any extended characters...
our application is working by odbc driver.
i'm pretty sure is a bug in the driver ...the bug is coming only when i select "ENABLE EXEC SYNTAX" IN THE DSN (SQLSERVER MIGRATION SECTION) ... i try with Shema Database and Owner and Empty and i got
always the same problem
exec KSP_TEST 0,'TiEST'
------------------------>>>>>>>NOT WORKING.
BUT IF I WRITE
CALL KSP_TEST (0,'TiEST')
------------------------->>>>IS WORKING
if i select enable exec or i unselect enable exec...
the CALL KSP_TEST...... is always working properly.
BETWEEN THESE SYNTAX THE NLS_LANG IS NEVER CHANGED....
IS WORKING.....THE NLS_LANG IS GOOD.......because i make a little modification in procedure to be sure the INSERT IS inside the database CORRECTLY.
CREATE OR REPLACE PROCEDURE KSP_TEST
PATCH INT,
PONC VARCHAR2
AS
v_test varchar2(100);
BEGIN
v_test := 'test';
INSERT INTO YYY VALUES (PONC);
END;If "just using Crystal Reports XI R2" means using Crystal Report Viewer and do not want to see the prompt, please follow the below steps.
1. Select the report you want to see
2. Select "Process" tab
3. Select Parameters menu under the process tab.
4. You would see two date parameters there.
Select the [Empty] value for each parameter and fill out the value you want.
Hope this would help. -
How query data in pl/sql via ODBC from DB2 on AS400
Hi,
What's the most easy way to do some selects on tables in an external (non-oracle)database via odbc?
I only need selects, no dml-statements like inserts en updates...
Where can I find more information about this subject?
FilipYou need to use Oracle Heterogeneous Services. Firstly you have to obtain and configure DB2 ODBC drivers. I got mine from ibm.com (not free) but I am sure there are some third party vendors out there. I don't know much about DB2 so I can't help you with the configuration (I asked a DB2 DBA to help me with that part).
The rest is just setting up Oracle HS and creating the DB link. The following steps should help but there are much more detailed manuals for Oracle HS on http://tahiti.oracle.com.
Listener Configuration
Add the following entry into the SID_LIST part of the listener. The SID_NAME will be used in the heterogeneous services configuration
(SID_DESC=
(SID_NAME=db2)
(ORACLE_HOME=D:\oracle\ora92)
(PROGRAM=hsodbc)
Restart the listener.
Heterogeneous Service Configuration
Under ORACLE_HOME\HS\admin create the following text file called initDB2.ora (the DB2 part should match the SID_NAME used in the listener configuration).
Put the following line in the text file (the DQ01 is the name of the DB2 ODBC System DSN):
HS_FDS_CONNECT_INFO=DQ01
Client Configuration
The client side refers to an Oracle database that will use the heterogeneous gateway.
TNSNames Entry
Put the following entry in the tnsnames.ora file (the SID part should match the SID_NAME in the listener configuration):
DB2.telkom.co.za =
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=cntrra20-esdt00)(PORT=1521))
(CONNECT_DATA=(SID=db2))
(HS=OK)
Database Link
Create a database link that references the new tnsnames.ora entry:
create public database link db2
connect to oratst identified by oracle using 'db2';
Test the database link. -
Calling a stored proc in a decode statement
I am having a problem calling a store procedure in a SQL statement. I am using Oracle's thin driver.
I have been able to do the following:
select col1,
col2,
SOME_STORED_PROC(var1,var2,col3)
from some_table
where col3 = var3
However, when I try to call a stored procedure with-in a decode statement, the call fails. I have tested the call from a sql prompt and it works fine but it does not work when I execute the query in my Java program.
Here is an example of what I am trying to do:
select col1,
col2,
decode((select col1
from some_other_table
where col2 = var1), 'X',
SOME_STORED_PROC(var1,var2,col3),
SOME_OTHER_STORED_PROC(var2,var4,col5))
from some_table
where col3 = var3
Does anyone know if this type of call is not supported in Oracle's thin driver?
Thanks,
Cory
nullI played around with a [parallel PL/SQL launcher|http://www.williamrobertson.net/feed/2008/08/parallel-plsql-launcher-update.html] a while ago, but I wouldn't call it production-ready.
You could also [submit procedure calls in background|http://www.williamrobertson.net/feed/2005/12/job-control-object.html] using DBMS_ALERT to track completion status. -
Clearing Oracle Parameters to call diferent stored procs
Sub Main
Do While i < 3
make_excel(i)
i = i + 1
Loop
end Sub
Sub make_excel(ByVal array As Integer)
objCmd.Parameters.Add(New OracleParameter("p_cursor", OracleType.Cursor)).Direction = ParameterDirection.Output
end Sub
objCmd.Parameters.Clear()
objCmd.Parameters.Remove("p_cursor")I agree with you. I was looking into mod_plsql, but it turns out that their development standards include not using Oracle HTTP server. The whole reason why they want to be able to execute a stored proc based on what is specified in an XML doc is that they want to avoid having to change their middle-tier configurations anytime a new stored proc or a change in stored proc parameters is made. I'm not familiar with what all is involved with .NET and the middle-tier, but supposedly this way, they can specify any stored procedure name and its parameters in an XML file. The XML is then suppose to be passed on to an Oracle stored procedure which will parse the XML and dynamically execute the stored procedure that was specified in the XML.
Here is an example of the XML:
'<Root>
<PackageName>TEST_PKG</PackageName>
<ProcedureName>TEST_PROC</ProcedureName>
<Parameters>
<Parameter>
<Name>EmpID</Name>
<Value>12345</Value>
</Parameter>
<Parameter>
<Name>Org</Name>
<Value>ABC</Value>
</Parameter>
</Parameters>
</Root>I basically need to parse out the pkg/proc names:
SELECT t.COLUMN_VALUE.extract('//PackageName/text()').getstringval() PkgName,
t.COLUMN_VALUE.extract('//ProcedureName/text()').getstringval() ProcName
INTO v_pkg_name, v_proc_name
FROM TABLE(xmlsequence(XMLTYPE(v_XML_input) .extract('/Root'))) t;...and then execute the procedure:
EXECUTE IMMEDIATE 'BEGIN '||v_pkg_name||'.'||v_proc_name||'(:a, :b, :c); END;'
using in v_in_param1, v_in_param2, out v_XML_output;The problem is that this approach is very complicated since there can be any number of IN/OUT parameters and of various datatypes. I would have to create all kinds of possible bind variables! -
Using Java to call COBOL stored proc on DB2 database
I would appreciate any information you would have on calling a COBOL stored procedure from a Java Servlet. The COBOL stored procedure resides on a DB2 database on our mainframe. I have never had to invoke a stored procedure in my code, especially COBOL, so I need all the help I can get. The servlet will call the stored procedure and then based on the stored procedure's return code I will either display a confirmation screen or an error screen. Please help!
Thanks in advance.I'm trying to call a stored procedure on a DB2 database from a Java Servlet. This is my code:
try{
cstmt = con.prepareCall("{CALL MKTDS80A
cstmt.setShort(1, shFiscalYr);
cstmt.setInt(2, iInvoiceNbr);
cstmt.setString(3, sInvoiceTypeCd);
cstmt.setInt(4, iUserNbr);
cstmt.setString(5, sFormId);
cstmt.setString(6, sSubSysCd);
cstmt.setShort(7, shModNbr);
cstmt.registerOutParameter(8, Types.INTEGER);
cstmt.registerOutParameter(9, Types.INTEGER);
cstmt.registerOutParameter(10, Types.CHAR);
cstmt.registerOutParameter(11, Types.INTEGER);
cstmt.registerOutParameter(12, Types.CHAR);
cstmt.execute();
iParm1 = cstmt.getInt(8);
iParm2 = cstmt.getInt(9);
sParm3 = cstmt.getString(10);
iParm4 = cstmt.getInt(11);
sParm5 = cstmt.getString(12);
if (iParm1 == 0){ bReturnZero = true;
CloseSQLStatement(cstmt);
catch (SQLException ex) {
CloseSQLStatement(cstmt);
bReturnZero = false;
System.out.println("SQL exception occurred: "
+ ex.toString());
return iParm1;
It seems to fail on the execute and I get the following SQL Exception message:
SQL exception occurred in callStoredProcedure method:
COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver][DB2] SQL0440N
No function by the name "MKTDS22B" having compatible arguments was
found in the function path. SQLSTATE=42884
Can anyone tell me what the problem might be? I've checked the parameter datatypes and everything matches up. Does anyone have a clue?
Thanks in advance! -
Calling Oracle Stored proc with record type and table Type
I have a oracle SP which takes record type and table Type which are used for order management.
Is there anay way to populate parameters with these datatypes and call the stored procedure using ODP.NET?
Please help.
Thanks in advanceHi,
ODP supports associative arrays and REF Cursors. There is no support for PLSQL table of records.
Jenny
Maybe you are looking for
-
Profit Center (On Account Payment to Vendor)
Hello All, I am posting payment via F-53 to vendor On Account i.e Without Reference to Invoice. I am getting Profit Center field for Bank Line item but not for vendors line item. I know default profit center would be posted to that line item but my u
-
Regarding authentication in sender soap adapter
how to do basic authentication in case of sender side soap adapter
-
I deleted "Staff" from "Sharing & Permissions"....
I tried searching around but was unable to find an answer. It seemed most other similar problems related to a migrated account from Tiger to Leopard which was not the case for me. Not only that but most of those posts seemed really complicated and ha
-
My gawd this site is the most ridiculously difficult site I've ever seen. Round and round we go and where we stop nobody knows. Will someone please tell me how to make the prompt for Adobe Reader update 11.0.09 go away?? It already shows that num
-
[Solved] netcfg Network Unavailable.
Hi, When trying to connect to a wireless network with netcfg it always fails with 'Network Unavailable'. Everything used to work with network-manager under Gnome. Lsmod says the iwl3945 module is loaded and iwconfig says; wlan0 IEEE 802.11g ESSID:"@