Home » Developer & Programmer » JDeveloper, Java & XML » Default value für PL/SQL-Funktion
Default value für PL/SQL-Funktion [message #179249] Mon, 26 June 2006 08:31 Go to next message
hfbm2004
Messages: 8
Registered: November 2005
Junior Member
Hi,

I've the following function:
FUNCTION testfunc_intnull ( id_int IN NUMBER DEFAULT NULL
,id_vch IN VARCHAR2
)
RETURN NUMBER
IS
BEGIN
IF id_int IS NULL
THEN
RETURN 1;
ELSE
RETURN 2;
END IF;
EXCEPTION
WHEN OTHERS THEN
RETURN 999;
END testfunc_intnull;

And have created a web service with jdeveloper 10.1.2.
The function does work in an Anonymous PL/SQL block(DECLARE,BEGIN,END).
In the Web Service, When the Field id_int is empty, it returns following Exception:

<?xml version="1.0" encoding="UTF-8" ?>
- <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
- <SOAP-ENV:Body>
- <SOAP-ENV:Fault>
<faultcode>SOAP-ENV:Server.Exception:</faultcode>
<faultstring>java.lang.NumberFormatException</faultstring>
<faultactor>/Application13-Project-context-root/Falluebersicht</faultactor>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

1. Which value sends the web service to the PL/SQL-function, when the field is empty?
2. Where can i configure in jdeveloper the web service , so that it sends a NULL, whenever the field is emty?

I have created a JSP-File to handle the Problem, but i want to solve the Problem for the link, which jdeveloper automatically generates, when i run the web service.

Thanks

Habib
Re: Default value für PL/SQL-Funktion [message #179333 is a reply to message #179249] Mon, 26 June 2006 23:44 Go to previous messageGo to next message
hobbes
Messages: 173
Registered: January 2006
Senior Member
In order to send in NULL input to the function, make sure that the input variable to the PL/SQL method looks as below before the invoke activity.
<Invoke_1_testfunc_intnull_InputVariable>
  <part xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="InputParameters">
    <InputParameters xmlns="http://xmlns.oracle.com/pcbpel/adapter/db/TESTSCHEMA/TESTFUNC_INTNULL/">
      <ID_INT xmlns="" /> 
      <ID_VCH xmlns="">some string value</ID_VCH> 
    </InputParameters>
  </part>
</Invoke_1_testfunc_intnull_InputVariable>

I tested with a value 'A' assigned to parameter id_vch, and input from the client for id_int. Worked as expected.

For id_int unspecified:
<messages>
  <Invoke_1_testfunc_intnull_InputVariable>
    <part xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="InputParameters">
      <InputParameters xmlns="http://xmlns.oracle.com/pcbpel/adapter/db/TESTSCHEMA/TESTFUNC_INTNULL/">
        <ID_INT xmlns="" /> 
        <ID_VCH xmlns="">A</ID_VCH> 
      </InputParameters>
    </part>
  </Invoke_1_testfunc_intnull_InputVariable>
  <Invoke_1_testfunc_intnull_OutputVariable>
    <part xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="OutputParameters">
      <db:OutputParameters xmlns:db="http://xmlns.oracle.com/pcbpel/adapter/db/TESTSCHEMA/TESTFUNC_INTNULL/"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
         <TESTFUNC_INTNULL>1</TESTFUNC_INTNULL> 
      </db:OutputParameters>
    </part>
    <part xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="response-headers">null</part> 
  </Invoke_1_testfunc_intnull_OutputVariable>
</messages>

For id_int specified:
<messages>
  <Invoke_1_testfunc_intnull_InputVariable>
    <part xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="InputParameters">
      <InputParameters xmlns="http://xmlns.oracle.com/pcbpel/adapter/db/TESTSCHEMA/TESTFUNC_INTNULL/">
        <ID_INT xmlns="">5</ID_INT> 
        <ID_VCH xmlns="">A</ID_VCH> 
      </InputParameters>
    </part>
  </Invoke_1_testfunc_intnull_InputVariable>
  <Invoke_1_testfunc_intnull_OutputVariable>
    <part xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="OutputParameters">
      <db:OutputParameters xmlns:db="http://xmlns.oracle.com/pcbpel/adapter/db/TESTSCHEMA/TESTFUNC_INTNULL/"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
         <TESTFUNC_INTNULL>2</TESTFUNC_INTNULL> 
      </db:OutputParameters>
    </part>
    <part xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="response-headers">null</part> 
  </Invoke_1_testfunc_intnull_OutputVariable>
</messages>
Re: Default value für PL/SQL-Funktion [message #179334 is a reply to message #179249] Mon, 26 June 2006 23:56 Go to previous messageGo to next message
hobbes
Messages: 173
Registered: January 2006
Senior Member
To answer part (2) of your query: You can use the assign activity to initialize input variables.
Re: Default value für PL/SQL-Funktion [message #179339 is a reply to message #179333] Tue, 27 June 2006 00:50 Go to previous messageGo to next message
hfbm2004
Messages: 8
Registered: November 2005
Junior Member
Hi hobbes,

thanks for reply.
Can you please tell me, which file is to be changed and where can i initialize the input variables.

Thanks in advance

Habib
Re: Default value für PL/SQL-Funktion [message #179344 is a reply to message #179249] Tue, 27 June 2006 01:07 Go to previous message
hobbes
Messages: 173
Registered: January 2006
Senior Member
Assuming you are working on a BPEL process project in JDev, this is one way to initialize input to the service:

1. Open file <Project Name>.bpel in Diagram View
2. Drag an Assign activity from the Component Pallette to the location where you want it on the diagram.
3. Double-click on the Assign activity icon, give it an appropriate name and create Copy Rules for the input values.

Example: The following assign activity initializes id_vch to 'A' and copies input from client to id_int.
    <assign name="assignInput">
      <copy>
        <from expression="'A'"/>
        <to variable="Invoke_1_testfunc_null_InputVariable" part="InputParameters" query="/ns2:InputParameters/ID_VCH"/>
      </copy>
      <copy>
        <from variable="inputVariable" part="payload" query="/client:BPELProcess1ProcessRequest/client:input"/>
        <to variable="Invoke_1_testfunc_null_InputVariable" part="InputParameters" query="/ns2:InputParameters/ID_INT"/>
      </copy>
    </assign>
Previous Topic: Changig Database Connection for a web service
Next Topic: java.lang.AbstractMethodError: oracle.jdbc.driver.OracleResultSetImpl.getClob
Goto Forum:
  


Current Time: Fri Nov 22 05:46:59 CST 2024