Call ref cursor functions in function also returning ref cursor?
In 10g database, I have several functions and procedures, some packaged, that return ref cursors. These work as expected.
Is there a way to call one or more of these in a new function and return another ref cursor?
I know this doesn't work, but I hope it conveys the idea.
function f_get_order_lines
return sys_refcursor -- or defined ref cursor
is
v_ords orders_rcr;
v_lines lines_rcr;
x sys_refcursor;
begin
v_ords := f_get_orders;
for rec in v_ords
loop
v_lines := f_get_lines;
... do other work here...
end loop;
return x;
end;
Pipelined table functions might do the trick for you, depending you your requirements and the transformations you need to make:
http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/tuning.htm#sthref2345
Similar Messages
-
To_date function in procedure which returns a cursor type
Hi All
When i execute the following query ,it runs fine and i get required result also
select *from a where adate>to_date('31-dec-2001')
But When i use the same query in a procedure which returns a cursor i get a error
"non numeric character was found where a numeric value was expected".
Then i changed the query to
select *from a where adate>to_date('31-dec-2001','dd-mon-yyyy') and it worked fine.
As i know default date format is 'dd-mon-yyyy' and no need to give the date format
explicitly in to_date function if the date(string) is in default format.
Can any body tell me the reason behind it?
Thanks
SatyaGiven a comparison between a date and a string Oracle will convert the string to a date. This means that if you have an index on a string column and compare it to a date the index will not be available, but if you have an index ona date column and compare it to a string column the index will be available.
create table t (string varchar2(30), d date);
insert into t values (to_char(sysdate), sysdate);
commit;
create index t_n1 on t(string);
create index t_n2 on t(d);
SQL> set autotrace traceonly
SQL> select /*+ index t_n1 */
2 *
3 from t
4 where string = sysdate;
no rows selected
Execution Plan
0 SELECT STATEMENT Optimizer=CHOOSE
1 0 TABLE ACCESS (FULL) OF 'T'
SQL> select /*+ index t_n2 */
2 *
3 from t
4 where d = to_char(sysdate);
no rows selected
Execution Plan
0 SELECT STATEMENT Optimizer=CHOOSE
1 0 TABLE ACCESS (BY INDEX ROWID) OF 'T'
2 1 INDEX (RANGE SCAN) OF 'T_N2' (NON-UNIQUE)
SQL> -
Stored PL/SQL function that returns REF CURSOR type
Hello everyone,
I've come through the following problem:
1.- I created an PL/SQL stored procedure which returns a REF CURSOR element, definition looks like this:
PACKAGE PKG_LISTADOS AS
TYPE tuplas IS REF CURSOR;
/* Procedimientos exportados por el paquete */
PROCEDURE inicializarModuloListados;
FUNCTION recaudacionUltimoMes(medioPago DEF_MEDIO_PAGO.MEDIO_PAGO%TYPE)
RETURN tuplas;
2.- Now I would like to call the stored procedure and retrieve the PL/SQL cursor as a ResultSet Java Object. The code I wrote is this:
Connection conn;
XmlDocument paramDef;
conn=poolMgr.getConnection str_poolDBConnection);
try
CallableStatement cstmt=conn.prepareCall("{?=call PKG_LISTADOS.recaudacionUltimoMes(?)}");
cstmt.registerOutParameter(1, java.sql.Types.OTHER);
cstmt.setString(2, "MONEDA");
cstmt.executeQuery();
ResultSet rs=(ResultSet)cstmt.getObject(1);
catch(SQLException sqlE)
3.- However, I can't make it OK, all the time I get the following error:
SQL Error(17004), java.sql.SQLException: Non valid column type
May anyone help me with this, thanks in advance:
Miguel-Angel<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by angelrip:
Hello everyone,
I've come through the following problem:
1.- I created an PL/SQL stored procedure which returns a REF CURSOR element, definition looks like this:
PACKAGE PKG_LISTADOS AS
TYPE tuplas IS REF CURSOR;
/* Procedimientos exportados por el paquete */
PROCEDURE inicializarModuloListados;
FUNCTION recaudacionUltimoMes(medioPago DEF_MEDIO_PAGO.MEDIO_PAGO%TYPE)
RETURN tuplas;
2.- Now I would like to call the stored procedure and retrieve the PL/SQL cursor as a ResultSet Java Object. The code I wrote is this:
Connection conn;
XmlDocument paramDef;
conn=poolMgr.getConnection str_poolDBConnection);
try
CallableStatement cstmt=conn.prepareCall("{?=call PKG_LISTADOS.recaudacionUltimoMes(?)}");
cstmt.registerOutParameter(1, java.sql.Types.OTHER);
cstmt.setString(2, "MONEDA");
cstmt.executeQuery();
ResultSet rs=(ResultSet)cstmt.getObject(1);
catch(SQLException sqlE)
3.- However, I can't make it OK, all the time I get the following error:
SQL Error(17004), java.sql.SQLException: Non valid column type
May anyone help me with this, thanks in advance:
Miguel-Angel<HR></BLOCKQUOTE>
Do something like the following:
cstmt = conn.prepareCall("{call customer_proc(?, ?)}");
//Set the first parameter
cstmt.setInt(1, 40);
//Register to get the Cursor parameter back from the procedure
cstmt.registerOutParameter(2, OracleTypes.CURSOR);
cstmt.execute();
ResultSet cursor = ((OracleCallableStatement)cstmt).getCursor(2);
while(cursor.next())
System.out.println("CUSTOMER NAME: " + cursor.getString(1));
System.out.println("CUSTOMER AGE: " + cursor.getInt(2));
cursor.close();
null -
Function calling stored procedure that returns a cursor into a LOV
Hello,
Is it possible in HTML DB to implement a process that has a function that calls a stored procedure that returns a cursor, used to then populate a select list?
Or can I do a function call to a stored procedure in the 'List of values definition' box for the item itself that returns a cursor to populate the item's select list?Hi Vikas,
Actually, I just found another posting that shows how to do what I'm looking for:
Re: Filling a LOV with a cursor
Check it out. I posted another question in response to that discussion...maybe you could answer that? Thanks!
Laura -
Question about cursors in a function and how to return the results
Hi all,
Some tech info:
I'm using Oracle 11G database and APEX 4.0.2.00.06
I use three cursors in a function. My function is called in an APEX standard report, like this by example:
SELECT fnc_exp(tab.arg1, tab,arg2) FROM table_exp tab;
My question is: how can I return the values calculated from my function to a standard APEX report? Before, this function was used like this by Oracle Forms to fetch the cursors in the right table columns:
open c_a;
fetch c_a into :loc.arg1;
close c_a;
open c_b;
fetch c_b into :loc.arg2, :loc.arg3, :loc.arg4, :loc.arg5;
close c_b;
Thanks for your advices!
Maybe my solution is not right, if you have better ideas, please suggest :)
PS: If you need more details, please ask which you need.Hi,
I don't think you can do exactly like that in APEX.
Go for a pipelined function if you want the value be returned from the function. -
Hello all,
I have a function and inside the i used a cursor variable.
My values are coming to cursor variable and I want to return the particular cursor variable through function.
Plz anybody help me for the particular.
-RupeshHello, Rupesh!
Try this example:
CREATE OR REPLACE FUNCTION func_cursor_variable(query VARCHAR2)
RETURN sys_refcursor IS
result sys_refcursor;
BEGIN
OPEN result FOR query;
RETURN(Result);
END func_cursor_variable;
Then launch SQL+ and run this query:
SELECT func_cursor_variable ( 'select sysdate from dual' ) FROM dual; -
Return cursor variable in function
I have three different sql queries already joined to diff tables, like query1 is made by joining 4 diff tables.
query1----select a,b,c,x from t1(set of 4 tables)
query2----select e,f from t2(set of 3 tables) where t1.x=t2.x
query3----select g,h from t3(set of 3 tables) where t1.x=t3.x
I need to return the resultset on a single row something like this_
a,b,c,x,e,f,g,h
I am using the above queries in a function and to return the result set using cursor variable as the return type for the function.
Please suggest a suitable solution design.
Thanks.I have only single column in query1 which is referencing to query2 and query 3. So further joining them is not preferred. There is no escape from joining them. It will probably be the most effective solution.
That said you might consider to restructure/review your whole involved select(s).
Translating Laurents proposition to your nomenclature you could finally end up with something like
CREATE FUNCTION f (p_st your_data_type)
RETURN sys_refcursor
AS
BEGIN
OPEN cur FOR
SELECT *
FROM query1, query2, query3
WHERE st = p_st AND query1.ID = query2.ID AND query1.ID = query3.ID;
RETURN cur;
END; -
Forms Data-Block based on stored procedures - REF CURSOR feature NOT FUNCTIONING
This topic is related to another topic in this forum titled "FORMS HOW TO SET QUERY SOURCE ARGUMENTS??" I posted my message there as well. I am posting as a NEW TOPIC so that it catches the attention of Oracle Support.
I built a data form based on a stored procedure and REF CURSOR IN OUT parameter.
My procedure takes a IN parameter to fill in the criteria for the OPEN <cursor_variable> select ... where ... statement.
In the Value setting of the Query source Arguments , I set the VALUE to ":BLOCK_NAME.ITEM_NAME" at design time to supply the input value to the procedure. this works to the extent of making available the form item value to the stored procedure parameter. I verified this by doing an insert into some debug table , of the incoming parameter value inside my stored procedure.
The cursor gets opened properly into the REF cursor variable. I verified this by fetching a record into a local variable and inserting the value into a debug table again in the stored procedure.
(I took care to close and re-open the REF cursor variable again - so that the front-end can continue to fetch it from the first record. )
***** PROBLEM **************
But the front end forms runtime is giving me a FRM-40301 - query returned no records even though the REF cursor is returned properly opened.
Did anybody else face the same problem ??
Please post what you found.
Thanks,
Shankaran
nullThis topic is discussed at length in another thread "How Set Value For Query DataSource Arguments?"
But I am posting the findings here as well.
THIS TOPIC IS CLOSED.
My Bad. The problem Cause : I did not include all columns in the
cursor rowtype in the Data-block. In the wizard for the data block , I selected ONLY the columns that I needed. But I was doing a Select * from <my_table> in my open cursor <Cursor-Variable> .... The <Cursor Variable>
itself was declared <my_table>%rowtype
FIX : The Data Block structure (columns included as items) should match the cursor record Structure. One may or may not
display all the columns in the LAYOUT though.
But I don't understand why it gives such a misleading message like FRM-40301 Query retrieved no records. Oracle Team fix it.
Hope this helps people who face the same problem.
Thanks, -
MS Access, ODBC and SPs returning ref cursor
I have some functions and procedures in a package returning ref cursors that work fine in my C++ batch applications. I would like for the GUI to be able to call these as well.
Unfortunately, we are using Access as the front end (for now), and we have not been able to get the ref cursors to work. Is this supported? We are using Oracle 8.0.5 on Solaris, and our clients is Access 97 on NT using Intersolv's ODBC driver.
My procedure looks something like:
package jec is
procedure open_sale_cur(
p_client_id number,
sale_curvar out sale_curtype)
is begin
open sale_curtype for select ... ;
end;
end;
And the Access code looks like this:
strSql = "begin jec.open_sale_cur(27, ?); end;"
qdfTemp = conMain.CreateQueryDef("", strSql)
qdfTemp.Parameters(0).Direction = dbParamOutput
qdfTemp.Execute()
This is the error when Execute() is called:
PLS-00306: wrong number or types of arguments in call to 'OPEN_SALE_CUR'
I am not an Access programmer; I am simply passing along this information. Any help would be greatly appreciated.We tried the {call...} syntax originally, but when we use it, we get an Oracle syntax error for the statement
SELECT * FROM {call ...}
Apparently Access prepends "SELECT..." before passing the SQL text to Oracle.
This is also the case for procedures with normal scalars, such as numbers, returned as OUT values. When we use anon PL/SQL syntax and "?" placeholders with such procedures, they work. When we use {call ...} syntax or omit OUT placeholders, they do not.
<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Justin Cave ([email protected]):
I suspect that you want to simply execute the statement
strSql = {call open_sale_cur( 27 )}
The ODBC driver will automatically figure out that there's an output parameter which is a ref cursor and return that as the result set. Note that you may want to download the latest 8.0.5 ODBC driver (8.0.5.10 I believe) if there are any problems.
Justin<HR></BLOCKQUOTE>
null -
BIP 11G - Retrieving a cursor from a function defined in a package
We had previously deployed reports in OBIP 10G....
The reports deployed in OBIP 10G used an XDO file to interact with the database and return data in XML format.
This action used to be defined in the ‘sqlStatement’ tag of the XDO file.
<dataQuery>
<sqlStatement name="Q1"> select PK_AP_GEN_REP.AP_GEN_REP('AP_CH_R101',1) FROM DUAL </sqlStatement>
</dataQuery>
For this it would invoke our package called ‘PK_AP_GEN_REP’ and pass the report specific function name ('AP_CH_R101') to it as an input parameter.
This returned a cursor.
Hereafter the resultant cursor from above would get each column mapped with those mentioned in ‘dataStructure’ tags of XDO file to form an XML file.
Currently we are trying the same in OBIP 11G.
We are creating the dataset with SQL query
The problem is that the SQL statement “select PK_AP_GEN_REP.AP_GEN_REP('AP_CH_R101',1) FROM DUAL” is not effective.
Also if the above query is fired it does not retrieve the column names to define the data structure.
Solutions tried:-
1. Forcefully defining the data-structure in XDM file created for this report. This did not work.
2. Firing a Before “Event Trigger”. This only works if the function is returning a Boolean and not a cursor.
We tried modifying the function to return a Boolean and to populate the report specific table which could be queried to fetch the records.
We defined Oracle DB Default Package = PK_AP_GEN_REP
We defined the trigger as PK_AP_GEN_REP.AP_GEN_REP('AP_CH_R101',1)
Now creating the dataset with SQL query does not return any data.
It is giving the following error:-
"XML document must have a top level element. Error processing resource 'http://iflmud5im00094:9704/xmlpserver/servlet/xdo'."
However the query fires if Oracle DB Default Package is reset to nothing...But in this case the event trigger did not fire.
If there is a wayout involving any of the above 2 steps or any other way please share the solution
Kindly let me know how I may handle this issue of Retrieving a cursor from a function defined in a package in BIP 11g.Further regarding this....
Not sure regarding performance issues of using pipelined functions
Just to share with you that instead of what you suggested I have tried out returning a 'table' type object from a PL/SQL function after CAST ing the required query to this Object.
Stretching the discussion forward, is there a way to cast a ref cursor into a plsql table.
This could absolutely fit my requirement...
Thanks in advance -
Problem with XSU when trying to execute pl/sql package returning ref cursor
Hi,
I'm exploring xsu with 8i database.
I tried running sample program which I took from oracle
documentation. Here is the details of these.
------create package returning ref cursor---
CREATE OR REPLACE package testRef is
Type empRef IS REF CURSOR;
function testRefCur return empRef;
End;
CREATE OR REPLACE package body testRef is
function testRefCur RETURN empREF is
a empREF;
begin
OPEN a FOR select * from emp;
return a;
end;
end;
---------package successfully created-----
Now I use java program to generate xml data from ref cursor
------------java program ----------
import org.w3c.dom.*;
import oracle.xml.parser.v2.*;
import java.sql.*;
import oracle.jdbc.driver.*;
import oracle.xml.sql.query.OracleXMLQuery;
import java.io.*;
public class REFCURt
public static void main(String[] argv)
throws SQLException
String str = null;
Connection conn = getConnection("scott","tiger"); //
create connection
// Create a ResultSet object by calling the PL/SQL function
CallableStatement stmt =
conn.prepareCall("begin ? := testRef.testRefCur();
end;");
stmt.registerOutParameter(1,OracleTypes.CURSOR); // set
the define type
stmt.execute(); // Execute the statement.
ResultSet rset = (ResultSet)stmt.getObject(1); // Get the
ResultSet
OracleXMLQuery qry = new OracleXMLQuery(conn,rset); //
prepare Query class
try
qry.setRaiseNoRowsException(true);
qry.setRaiseException(true);
qry.keepCursorState(true); // set options (keep the
cursor alive..
System.out.println("..before printing...");
while ((str = qry.getXMLString())!= null)
System.out.println(str);
catch(oracle.xml.sql.OracleXMLSQLNoRowsException ex)
System.out.println(" END OF OUTPUT ");
qry.close(); // close the query..!
// qry.close(); // close the query..!
// Note since we supplied the statement and resultset,
closing the
// OracleXMLquery instance will not close these. We would
need to
// explicitly close this ourselves..!
stmt.close();
conn.close();
// Get the connection given the user name and password..!
private static Connection getConnection(String user, String
passwd)
throws SQLException
DriverManager.registerDriver(new
oracle.jdbc.driver.OracleDriver());
Connection conn = DriverManager.getConnection
("jdbc:oracle:thin:@xxxx:1521:yyyy",user,passwd);
return conn;
when I ran the program after successful compilation,I got the
following error
==========
Exception in thread "main" oracle.xml.sql.OracleXMLSQLException:
1
at oracle.xml.sql.core.OracleXMLConvert.getXML(Compiled
Code)
at oracle.xml.sql.query.OracleXMLQuery.getXMLString
(OracleXMLQuery.java:263)
at oracle.xml.sql.query.OracleXMLQuery.getXMLString
(OracleXMLQuery.java:217)
at oracle.xml.sql.query.OracleXMLQuery.getXMLString
(OracleXMLQuery.java:194)
at REFCURt.main(Compiled Code)
============================
Can anybody tell me why I'm getting this error.Am I missing any
settings?
thanksWe are using 8.1.7 Oracle db with latest xdk loaded.
am I missing any settings? -
Calling a procedure that returns a cursor inside a procedure
Hi,
I have two stored procedures. They both return a cursor as output variables. On the other hand I have another stored procedure that calls these procedures and return their results again an output variable. I know that this seems quite odd to be wanting to do something like this but how can I do that?You can make the hack generic. Make it execute any SQL as that schema that creates the ref cursor. E.g.
// as schema BILLY, open a huge security hole and grant access to USER1
SQL> create or replace procedure GetTableData( tableName varchar2, refCur out sys_refcursor ) authid definer is
2 dynamicSQL varchar2(32767);
3 begin
4 dynamicSQL := 'select * from '||tableName;
5 open refCur for dynamicSQL;
6 end;
7 /
Procedure created.
SQL>
SQL>
SQL> grant execute on GetTableData to USER1;
Grant succeeded.As USER1, you can now execute SQL (and even PL/SQL) as BILLY:
SQL> create or replace type TStrings is table of varchar2(4000);
2 /
Type created.
SQL> grant execute on TStrings to BILLY;
Grant succeeded.
SQL> --// execute this as the caller (which will be BILLY.GetTableData)
SQL> create or replace procedure ExecSQL( hackSQL varchar2 ) authid current_user is
2 pragma autonomous_transaction;
3 begin
4 execute immediate hackSQL;
5 commit;
6 end;
7 /
Procedure created.
SQL> --// wrap the above into something that BILLY.GetData can execute as a ref cursor
SQL> --// and return a meaningful message as to how successful the hack was
SQL> create or replace function PipeLineHack( hackSQL varchar2 ) return TStrings authid current_user pipelined is
2 begin
3 ExecSQL( hackSQL );
4 pipe row( 'SQL hack successful' );
5 exception when OTHERS then
6 pipe row( 'SQL hack faled with '||SQLERRM(SQLCODE) );
7 end;
8 /
Function created.
SQL>
SQL> grant execute on PipeLineHack to BILLY;
Grant succeeded.
SQL>
SQL> var c refcursor
SQL> --// expected used of the GetTableData() interface
SQL> --// we select from table BILLY.EMP
SQL> exec BILLY.GetTableData( 'EMP', :c );
PL/SQL procedure successfully completed.
SQL> print c
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7369 SMITH CLERK 7902 1980/12/17 00:00:00 800 0 20
7499 ALLEN SALESMAN 7698 1981/02/20 00:00:00 1600 300 30
7521 WARD SALESMAN 7698 1981/02/22 00:00:00 1250 500 30
7566 JONES MANAGER 7839 1981/04/02 00:00:00 2975 20
7654 MARTIN SALESMAN 7698 1981/09/28 00:00:00 1250 1400 30
7698 BLAKE MANAGER 7839 1981/05/01 00:00:00 2850 30
7782 CLARK MANAGER 7839 1981/06/09 00:00:00 2450 10
7788 SCOTT ANALYST 7566 1987/04/19 00:00:00 3000 20
7839 KING PRESIDENT 1981/11/17 00:00:00 5000 10
7844 TURNER SALESMAN 7698 1981/09/08 00:00:00 1500 0 30
7876 ADAMS CLERK 7788 1987/05/23 00:00:00 1100 20
7900 JAMES CLERK 7698 1981/12/03 00:00:00 950 30
7902 FORD ANALYST 7566 1981/12/03 00:00:00 3000 20
7934 MILLER CLERK 7782 1982/01/23 00:00:00 1300 10
14 rows selected.
SQL>
SQL> --// getting that interface to run unexpected code - we
SQL> --// rename BILLY.EMP table to something else
SQL> exec BILLY.GetTableData( 'TABLE(USER1.PipeLineHack( ''alter table emp rename to emp_has_been_hacked''))', :c );
PL/SQL procedure successfully completed.
SQL> print c
COLUMN_VALUE
SQL hack successful
SQL> -
Call WDA from ABAP via function module
Hi WDA experts,
is there any possibility to call a WDA within a ABAP report AND include it in the process.
The best would be to call a WDA via a function module - make some inputs on the WDA side - press submit and the function module gives me the data from the webdynpro back to my application.
I know that I can call a WDA via the function CALL_BROWSER, but in this case the WDA application is fully independent from the report and I am not able to post any data back to the report.
I also know FM WDY_EXECUTE_IN_PLACE, but in this case I need a HTML container to display the WDA and there it seems that I also never get back any data back to the report.
Any hints are appreciated.Not too hard:
CALL WDA passing in a KEY on start plug.
write the data to a shared memory object using the key passed as the
key to a shared memort object on the submit.
(see blogs on writing Shared maemory objects in ABAP)
Then simply exit APP.
On return read the data from the Shared memory Object.
The shared memory object lives across the 2 sessions.
cheers
Phil. -
Calling a Webservice via a Function in PL/SQL
Hi
I am trying to call a webservice from a function, but i am getting an error, i am not sure that i am using the correct url for the end point or actions
Below is the class i am calling..
Please could some assist.
FUNCTION add_new_user (xmlstruct IN VARCHAR2)
RETURN VARCHAR2
IS
req xx_demo_soap.request;
resp xx_demo_soap.response;
BEGIN
req :=
xx_demo_soap.new_request
('processRequest',
'xmlns="http://extServices"'
xx_demo_soap.ADD_PARAMETER (req, 'processReq', 'xsd:string', xmlstruct);
resp :=
xx_demo_soap.invoke
(req,
'http://wbrbap92/LDAP_Self-Service/services/LdapProcWS',
'http://wbrbap92/LDAP_Self-Service/services/LdapProcWS/'
RETURN xx_demo_soap.get_return_value
(resp,
'processRequestResponse',
'xmlns="http://extServices"'
END;
Also here is the WSDL file
\<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://extServices" xmlns:impl="http://extServices" xmlns:intf="http://extServices" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsi="http://ws-i.org/profiles/basic/1.1/xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<wsdl:types>
<schema targetNamespace="http://extServices" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<element name="firstTestResponse">
<complexType>
<sequence>
<element name="firstTestReturn" nillable="true" type="xsd:string"/>
</sequence>
</complexType>
</element>
<element name="processDelete">
<complexType>
<sequence>
<element name="processDel" nillable="true" type="xsd:string"/>
</sequence>
</complexType>
</element>
<element name="processDeleteResponse">
<complexType>
<sequence>
<element name="processDeleteReturn" nillable="true" type="xsd:string"/>
</sequence>
</complexType>
</element>
<element name="processRequest">
<complexType>
<sequence>
<element name="processReq" nillable="true" type="xsd:string"/>
</sequence>
</complexType>
</element>
<element name="processRequestResponse">
<complexType>
<sequence>
<element name="processRequestReturn" nillable="true" type="xsd:string"/>
</sequence>
</complexType>
</element>
<element name="processModify">
<complexType>
<sequence>
<element name="processMod" nillable="true" type="xsd:string"/>
</sequence>
</complexType>
</element>
<element name="processModifyResponse">
<complexType>
<sequence>
<element name="processModifyReturn" nillable="true" type="xsd:string"/>
</sequence>
</complexType>
</element>
<element name="firstTest">
<complexType>
<sequence/>
</complexType>
</element>
</schema>
</wsdl:types>
<wsdl:message name="processRequestResponse">
<wsdl:part element="impl:processRequestResponse" name="parameters"/>
</wsdl:message>
<wsdl:message name="processDeleteRequest">
<wsdl:part element="impl:processDelete" name="parameters"/>
</wsdl:message>
<wsdl:message name="firstTestResponse">
<wsdl:part element="impl:firstTestResponse" name="parameters"/>
</wsdl:message>
<wsdl:message name="processRequestRequest">
<wsdl:part element="impl:processRequest" name="parameters"/>
</wsdl:message>
<wsdl:message name="processModifyRequest">
<wsdl:part element="impl:processModify" name="parameters"/>
</wsdl:message>
<wsdl:message name="processModifyResponse">
<wsdl:part element="impl:processModifyResponse" name="parameters"/>
</wsdl:message>
<wsdl:message name="processDeleteResponse">
<wsdl:part element="impl:processDeleteResponse" name="parameters"/>
</wsdl:message>
<wsdl:message name="firstTestRequest">
<wsdl:part element="impl:firstTest" name="parameters"/>
</wsdl:message>
<wsdl:portType name="LdapProcWS">
<wsdl:operation name="firstTest">
<wsdl:input message="impl:firstTestRequest" name="firstTestRequest"/>
<wsdl:output message="impl:firstTestResponse" name="firstTestResponse"/>
</wsdl:operation>
<wsdl:operation name="processDelete">
<wsdl:input message="impl:processDeleteRequest" name="processDeleteRequest"/>
<wsdl:output message="impl:processDeleteResponse" name="processDeleteResponse"/>
</wsdl:operation>
<wsdl:operation name="processRequest">
<wsdl:input message="impl:processRequestRequest" name="processRequestRequest"/>
<wsdl:output message="impl:processRequestResponse" name="processRequestResponse"/>
</wsdl:operation>
<wsdl:operation name="processModify">
<wsdl:input message="impl:processModifyRequest" name="processModifyRequest"/>
<wsdl:output message="impl:processModifyResponse" name="processModifyResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="LdapProcWSSoapBinding" type="impl:LdapProcWS">
<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="firstTest">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="firstTestRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="firstTestResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="processDelete">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="processDeleteRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="processDeleteResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="processRequest">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="processRequestRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="processRequestResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="processModify">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="processModifyRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="processModifyResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="LdapProcWSService">
<wsdl:port binding="impl:LdapProcWSSoapBinding" name="LdapProcWS">
<wsdlsoap:address location="http://wbrbap92/LDAP_Self-Service/services/LdapProcWS"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
ThanksTry this..
CREATE OR REPLACE PACKAGE L_WEBSERVICE_INVOKE
AS
** Name: L_WEBSERVICE_INVOKE
PROCEDURE P_CREATE_XML(envolope IN OUT NOCOPY varchar2);
PROCEDURE P_INVOKE_WEBSERVICE(rs_error_msg IN OUT VARCHAR2,
on_result IN OUT NUMBER);
PROCEDURE SHOW_ENVELOPE(env IN VARCHAR2);
END L_WEBSERVICE_INVOKE;
show errors;
create or replace PACKAGE BODY L_WEBSERVICE_INVOKE
AS
PROCEDURE P_CREATE_XML(envolope IN OUT NOCOPY varchar2)
AS
BEGIN
envolope := '<?xml version="1.0" encoding="UTF-8" ?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:q0="http://extServices" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><SOAP-ENV:Body><q0:processRequest><processReq><?xml version='1.0'?><users><user><uid>W0001</uid><surname>Bruce</surname><firstName>Jacob</firstName><idNumber>6611254858081</idNumber><idType>P</idType><email>[email protected]</email><employer>FNB</employer><empNumber>W3546333</empNumber><department>Collections</department><region></region><branch>Southside</branch><division>Corporate</division></user><user><uid>W0034</uid><surname>Brian</surname><firstName>Sutters</firstName><idNumber>3445554858081</idNumber><idType>V</idType><email>[email protected]</email><employer>Wesbank</employer><empNumber>W3455455</empNumber><department>Fraud</department><region>PTA West</region><branch>Southside</branch><division>Corporate</division></user></users></processReq></q0:processRequest></SOAP-ENV:Body></SOAP-ENV:Envelope>';
END P_CREATE_XML;
PROCEDURE P_INVOKE_WEBSERVICE(rs_error_msg IN OUT VARCHAR2,
on_result IN OUT NUMBER)
AS
ls_out_resp varchar2(32767);
http_req utl_http.req;
http_resp utl_http.resp;
ls_http_req_url varchar2(4000);
ls_result VARCHAR2(2000);
name VARCHAR2(256); -- Response header name
value VARCHAR2(1024); -- Response header value
line VARCHAR2(4000); -- Response body
ls_webservice_url varchar2(1024);
ls_in_request varchar2(4000);
is_webservice_err varchar2(2000);
BEGIN
on_result:=0;
ls_http_req_url := 'http://wbrbap92/LDAP_Self-Service/services/LdapProcWS';
--Construct the Input Soap Request
P_CREATE_XML(ls_in_request);
--show_envelope(ls_in_request);
-- Establish the connection
http_req := utl_http.begin_request(ls_http_req_url, 'POST' ,'HTTP/1.1');
-- The Content-Length header has to indicate the amount of data in the XML document
utl_http.set_header(http_req, 'Content-Type', 'text/xml');
utl_http.set_header(http_req, 'Content-Length', to_char(length(ls_in_request)) );
-- POST the XML document
utl_http.write_text(http_req,ls_in_request);
-- Now process the HTTP server's response
http_resp := utl_http.get_response(http_req);
dbms_output.put_line('HTTP response status code: ' || http_resp.status_code);
dbms_output.put_line('HTTP response reason phrase: ' || http_resp.reason_phrase);
utl_http.read_text(http_resp, ls_out_resp);
show_envelope(ls_out_resp);
utl_http.end_response(http_resp);
EXCEPTION
WHEN Utl_Http.request_failed THEN
on_result:=-1;
rs_error_msg:='L_WEBSERVICE_INVOKE.p_invoke_webservice-request_failed: ' ||UTL_HTTP.GET_DETAILED_SQLERRM;
Utl_Http.end_request (http_req);
WHEN Utl_Http.http_server_error THEN
on_result:=-1;
rs_error_msg:='L_WEBSERVICE_INVOKE.p_invoke_webservice-Http_Server_Error: ' ||UTL_HTTP.GET_DETAILED_SQLERRM;
Utl_Http.end_request (http_req);
WHEN Utl_Http.http_client_error THEN
on_result:=-1;
rs_error_msg:='L_WEBSERVICE_INVOKE.p_invoke_webservice-Http_Client_Error: ' ||UTL_HTTP.GET_DETAILED_SQLERRM;
Utl_Http.end_request (http_req);
when others then
on_result:=-1;
rs_error_msg := 'L_WEBSERVICE_INVOKE.P_INVOKE_WEBSERVICE: ' || SQLERRM;
Utl_Http.end_request (http_req);
END P_INVOKE_WEBSERVICE;
PROCEDURE SHOW_ENVELOPE(env IN VARCHAR2)
AS
i pls_integer;
len pls_integer;
BEGIN
i := 1;
len := length(env);
WHILE (i <= len)
LOOP
dbms_output.put_line(substr(env, i, 100));
i:=i+100;
END LOOP;
END SHOW_ENVELOPE;
END L_WEBSERVICE_INVOKE;
Now execute the anonymous block
set serverout on size 1000000;
DECLARE
RS_ERROR_MSG VARCHAR2(2000);
ON_RESULT NUMBER;
BEGIN
L_WEBSERVICE_INVOKE.P_INVOKE_WEBSERVICE(RS_ERROR_MSG,ON_RESULT);
END;
Good luck!!!
Bhagat
Message was edited by:
Bugs
Message was edited by:
Bugs -
I'm trying to return a REF CURSOR from a function and get the following error:
ORA-00932: inconsistent datatypes: expected CURSER got NUMBER
ORA-06512: at "CERTS.JIMMY", line 17
ORA-06512: at line 10
Here is my function:
CREATE OR REPLACE PACKAGE jimmy
AS
TYPE refc IS REF CURSOR
RETURN equipment%rowtype;
FUNCTION getresults(p_ssan_in IN equipment.ssan%TYPE,
p_type_in IN equipment.equip_type%TYPE)
RETURN refc;
END jimmy;
CREATE OR REPLACE PACKAGE BODY jimmy
AS
FUNCTION getresults( p_ssan_in IN equipment.ssan%TYPE,
p_type_in IN equipment.equip_type%TYPE)
RETURN refc
IS
l_cursor refc;
isretired equipment.retired%TYPE := 'N';
qry varchar2(100) := 'SELECT * ' ||
'FROM equipment ' ||
'WHERE ssan = :b1 ' ||
'AND equip_type = :b2 ' ||
'AND retired = :b3';
BEGIN
EXECUTE IMMEDIATE qry
INTO l_cursor
USING p_ssan_in, p_type_in, isretired;
RETURN l_cursor;
END getresults;
END jimmy;
The data types for the parameters are all varchar2. I don't know why it says it is returning a number.I tried your suggestion:
BEGIN
OPEN l_cursor
FOR qry
USING p_ssan_in, p_type_in, isretired;
RETURN l_cursor;
END getresults;
But I get an error:
PLS-00455: cursor 'L_CURSOR' cannot be used in dynamic SQL OPEN statement
Maybe you are looking for
-
Infinity 2 up and down speed, very slow, huge ping...
Hello wonderful friendly people, i'm looking for a bit of help to narrow down the cause of the terrible internet connection I have. I live in a flat in a new build block in Bristol, just moved in with the owner who has had a few different connections
-
After my last iOS update my iphone 4 no longer syncs with my macbook. How do I fix that?
-
How to install new hard drive on Macbook Pro
My hard drive failed and I am no longer able to boot up the Macbook. If I go and buy a new hard drive and replace it with the broken one, what will happen when I turn it on. It will be a brand new drive with nothing on it. Will it automatically start
-
Fwding Alert in CCMS to Alert Management???
Hi, I'm trying to fwd the alerts coming in CCMS to Alert Management System. Both are in the same machine.I follwed the steps given in the SAp help.But i did not get the result. I was not able to do one step which tells us to "Specify RFC Destination
-
Secure Empty Trash Progress Bar Stalls With 4 Items Left
Greetings All, I've recently installed OS X 10.5.1 and have had pretty good luck. I just tried to use the Secure Empty Trash function and the progress bar seems to be stalled with 4 items left. The trash can did "empty" with the associated sound effe