How to call procedure with Object types in java
Hi,
We have procedure declaration as follows
===============
TYPE TEST_TYPE AS OBJECT (NAME VARCHAR2(10));
TYPE TESTTYPE1 AS object (student1 TESTTYPE,student2 TESTTYPE,student3 TESTTYPE);
TYPE rect AS OBJECT
-- The type has 3 attributes.
length NUMBER,
width NUMBER,
area NUMBER,
-- Define a constructor that has only 2 parameters.
CONSTRUCTOR FUNCTION rect(length NUMBER, width NUMBER)
RETURN SELF AS RESULT
PROCEDURE G(obj1 in TESTTYPE1,obj2 out rect) as
n1 testtype;
n2 testtype;
n3 testtype;
n4 testtype;
begin
obj2 := NEW rect(10,20,200);
n1 := obj1.student1;
n2 := obj1.student2;
n3 := obj1.student3;
obj2.length :=20;
end;
=====================================================
I am not able to call the procedure in java code as I cannot figure out which out parameter type will it be registered using registeroutparameter. using cursor or struct type fails.
please let me know how I can pass values from stored procedure with objects to java.
I'm not sure what you're trying to accomplish with your procedure, but in general, this is an example of how you could use oracle.sql.STRUCT.
First, prepare your java.sql.CallableStatement using java.sql.CallableStatement cStmt = java.sql.Connection.prepareCall({ call G(?, ?) });
Note that you don't have to use the OracleCallableStatement. The java.sql.CallableStatement will work just fine.
For the IN parameter, you need to create three TEST_TYPE objects. Then you need to create one TESTTYPE1 object.
These will all be instances of oracle.sql.STRUCT.
To create a oracle.sql.STRUCT object you need a descriptor and a set of attributes. For example, to create a TEST_TYPE object you would do the following
1. StructDescriptor sd = StructDescriptor.createDescriptor("TEST_TYPE", java.sql.Connection).
2. Add a VARCHAR2 attribute to an array of attributes (e.g. Object[] attributes = new Object[]{"Student Name"})
3. oracle.sql.STRUCT struct = new oracle.sql.STRUCT(sd, java.sql.Connection, attributes)
Then do something similar to create the TESTTYPE1 object, except that the attribute array will contain three instances of TEST_TYPE struct objects.
To bind the IN parameter you need to use the java.sql.CallableStatement.setObject(1, <Instance of TESTTYPE1 object>).
To register the OUT parameter, you need to call java.sql.CallableStatement.registerOutParameter(2, oracle.jdbc.OracleTypes.STRUCT, "RECT").
Then, execute your procedure using cStmt.execute();
Retrieve your OUT parameter using oracle.sql.STRUCT struct = (oracle.sql.STRUCT)cStmt.getObject(2).
Once you've done that, to get the values of the attributes of all of your STRUCT objects, you need their descriptors and their metadata.
Similar Messages
-
Can somebody help...
I have a procedure which takes parameter as IN OUT extended object type .Below is the example.
PROCEDURE p_save (example IN OUT xyz_obj)
my object type "xyz_obj" have elements with other object types also, and that itself have around 100 elements.
And when calling the above procedure for test purpose, how is it possible to pass partial elements of the object type rather than setting all unused elements to null.user13026549 wrote:
Can somebody help...
I have a procedure which takes parameter as IN OUT extended object type .Below is the example.
PROCEDURE p_save (example IN OUT xyz_obj)
my object type "xyz_obj" have elements with other object types also, and that itself have around 100 elements.
And when calling the above procedure for test purpose, how is it possible to pass partial elements of the object type rather than setting all unused elements to null.
It ISN'T possible. How could it be? Each attribute has to be set to something don't you think?
A common way to handle that is to define a public package variable that is an instance of the object type and has ALL elements set to null. As Odie suggested a custom constructor function can be used for that.
Then you create your procedure instance by starting with an instance of the package variable (where everything is null) and setting values for the attributes you need. -
DB Adapter - Calling Stored Procedure with Object Type
So, we are using JDeveloper 10.1.3.3
We are trying to create an ESB process that invokes a SP with an object type. However, the owner of the package / SP, is NOT the owner of the object type. When going through the DB Adapter wizard, it gives us the following error:
When attempting to use the DB Adapter in JDeveloper to create a partner link to execute a stored procedure. JDeveloper returns the following error:
Unable to import WSDL.
Error while writing wsdl file
Database type is either not supported or is not implemented.
Check to ensure that the type of the parameter is one of the supported datatypes or that there is a collection or user defined type definition representing this type defined in the database.
However, if I create a wrapper package / SP, it works just fine. I'd really like to not be having to create wrapper code for these SPs to work. Is this resolved in 11g? Is there a patch available for 10.1.3.3?
I think this is a JDeveloper Wizard issue, but thought I'd post this here as well.
Thanks,
BradWThis problem can be resolved by granting execute permission on the object type to the caller. For example, if the stored procedure is in schema1 and the object type is in schema2 then you would connect as schema2 and execute
SQL> grant execute on <object type> to schema1
Referencing object types defined in other schemas is documented. This is the described method for accessing object types in other schemas. -
Need some help on procedure calling procedure using object type reg
dear all,
i need to test one procedure by passing only one value but how do i pass single value. i am showing the details of few section on which i am working on. here is few details about the package.
Description: package pkj_emp contains two procedure pkj_emp and procedure proc_rem.
purpose:based on passing dname values to procedure pkj_emp, cursor cur_emp will fetch empid from emp table and then we are passing 4 empid records to procedure proc_rem using empid object type.Inside the procedure proc_rem it will delete all 4 records of table A,B,C and D at one short.
Requirement:i need to test for only one value that means is it possible i can pass only one value using the cursor cur_emp.
create or replace package pkj_emp
TYPE obj_emp IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
procedure proc_emp(empid obj_emp);
create or replace package body pkj_emp
as
procedure(
dname varchar2;
as
cursor cur_emp is select emp_id from emp a,dept d
where a.deptid=d.deptid
and d.deptname=dname;
begin
count:=0;
for cur_emp_rec in cur_emp LOOP
empid(count) := cur_emp_rec.emp_id;
IF (count = 4) THEN
proc_rem(empid); // calling another procedure
commit;
END IF;
count := count + 1;
END LOOP;
end;
proc_rem(
empid obj_emp;
is
begin
delete from A where emp_id in (empid(0),empid(1),empid(2),empid(3));
delete from B where emp_id in (empid(0),empid(1),empid(2),empid(3));
delete from c where emp_id in (empid(0),empid(1),empid(2),empid(3));
delete from d where emp_id in (empid(0),empid(1),empid(2),empid(3));
end;
regards
LaxmanYou have hardcoded your IN LIST in the REM procedure. I recommend changing the code to take a variable number of inputs. You could do something like the following:
SQL> CREATE TABLE A (ID NUMBER);
Table created.
SQL> CREATE TABLE B (ID NUMBER);
Table created.
SQL> CREATE TABLE C (ID NUMBER);
Table created.
SQL> CREATE TABLE D (ID NUMBER);
Table created.
SQL> INSERT INTO A VALUES(7566);
1 row created.
SQL> INSERT INTO B VALUES(7902);
1 row created.
SQL> INSERT INTO C VALUES(7876);
1 row created.
SQL> INSERT INTO D VALUES(7369);
1 row created.
SQL> CREATE OR REPLACE TYPE EMP_TYPE AS TABLE OF NUMBER(4);
2 /
Type created.
SQL> CREATE OR REPLACE PACKAGE PKJ_EMP
2 AS
3 PROCEDURE PKJ_EMP
4 (
5 DNAME IN SCOTT.EMP.DEPTNO%TYPE
6 );
7
8 PROCEDURE REM
9 (
10 pEMPList IN EMP_TYPE
11 );
12 END PKJ_EMP;
13 /
Package created.
SQL> CREATE OR REPLACE PACKAGE BODY PKJ_EMP
2 AS
3 PROCEDURE PKJ_EMP
4 (
5 DNAME IN SCOTT.EMP.DEPTNO%TYPE
6 )
7 AS
8 pEMPList EMP_TYPE := EMP_TYPE();
9 i NUMBER := 1;
10 BEGIN
11 FOR r IN
12 (
13 SELECT EMPNO
14 FROM SCOTT.EMP
15 WHERE DEPTNO = DNAME
16 )
17 LOOP
18 pEMPList.EXTEND;
19 pEMPList(i) := r.EMPNO;
20
21 i := i + 1;
22 END LOOP;
23
24 REM(pEMPList);
25 END PKJ_EMP;
26
27 PROCEDURE REM
28 (
29 pEMPList IN EMP_TYPE
30 )
31 AS
32 BEGIN
33 DELETE FROM A WHERE ID IN (SELECT COLUMN_VALUE FROM TABLE(pEMPList));
34 DELETE FROM B WHERE ID IN (SELECT COLUMN_VALUE FROM TABLE(pEMPList));
35 DELETE FROM C WHERE ID IN (SELECT COLUMN_VALUE FROM TABLE(pEMPList));
36 DELETE FROM D WHERE ID IN (SELECT COLUMN_VALUE FROM TABLE(pEMPList));
37 END REM;
38 END PKJ_EMP;
39 /
Package body created.
SQL> EXEC PKJ_EMP.PKJ_EMP(20);
PL/SQL procedure successfully completed.
SQL> SELECT * FROM A;
no rows selected
SQL> SELECT * FROM B;
no rows selected
SQL> SELECT * FROM C;
no rows selected
SQL> SELECT * FROM D;
no rows selected
SQL> spool off;HTH! -
Ever used the Table API (TAPI) with object type in the DB?
Hi all,
We are trying to generate the table API of a table that has a column defined by an object type. It works without problems if that column always has a value (is instantiated in object term). The problem is when we update a row where the column is null (all attributes of the object are null thus the object is not instantiated).
The "before update row" trigger of the Table API fails with error "ora-30625-method dispath on NULL SELF argument is disallowed".
Any of you guys made it work? If so, how?
Thanksuser8879206 wrote:
Hi friends,
I have a procedure with object type IN OUT parameters which is used for fetching status. We are calling this from Java. But I want to call it from oracle for testing purpose. I am trying from my end but not able to do it as of now. This is the first time I am dealing with object type.We need more information. What is wrong? Your code looked okay and you did not mention any Oracle errors. What is happening that should not be or not happening that should be?
You can call the procedure with a simple call in PL/SQL but will not be able to use it in SQL because 1) it is a procedure and 2) it has an OUT argument. A sample call should look something like (untested)
declare
x rec2;
y rec3;
begin
--use the arguments rru was defined with as the arguments in the same order: types rec2 (x), rec3 (y)
rru(x,y);
end;>
Any help would be appreciated.
Details are given below.
CREATE OR REPLACE TYPE REC1 AS OBJECT
(RELAY_USAGE VARCHAR2(30)
,STATE VARCHAR2(1)
TYPE REC AS TABLE OF REC1;
CREATE OR REPLACE TYPE REC2 AS OBJECT
(GSRN VARCHAR2(18)
,METERING_POINT_NAME VARCHAR2(80)
,RELAYS REC)
CREATE OR REPLACE TYPE REC3 AS OBJECT
(INFO VARCHAR2(2000)
,STATUS NUMBER
PROCEDURE RRU(
rcRelayControl IN OUT REC2
, rcResp IN OUT REC3)
IS
BEGIN
APKG.GetDetails(rcRelayControl, rcResp);
IF rcResp.Status = BPKG.iStatusFailure THEN
rcResp.Info := BPKG.Get_Message('20889', rcResp.Info);
END IF;
END RRU;
How to call this procedure in oracle?
Thanks. -
Mapping refcursors with object types in a procedure
Hi all,
I need some help regarding the mapping of refcursors with object types .
Example: Procedure "A" has object types as input/output parameters which lies in the Web Method Application as a API.
We are creating a procedure "B" which has ref cursors as input/ouput parameters
which will map to the Procedure "A"'s object type parameters.
It will be highly needful for the solution.
Regards
SaugataYour pseudocode has a lot of steps in it, but you didn't say which step you need help with. Since I already covered going from a nested table type to a refcursor, I'll assume you want an example that goes the other way now, like from a refcursor to a nested table type. Here's one ...
SQL>
SQL>
SQL> set serveroutput on
SQL>
SQL> create type nested_table_type as table of varchar2(14) ;
2 /
Type created.
SQL> show errors
No errors.
SQL>
SQL>
SQL> create function func
2 ( p_cursor in sys_refcursor )
3 return nested_table_type
4 as
5 v_nested_table nested_table_type ;
6 begin
7
8 fetch p_cursor bulk collect into v_nested_table ;
9 return( v_nested_table );
10
11 end;
12 /
Function created.
SQL> show errors
No errors.
SQL>
SQL> select func( cursor( select dname from dept ) ) as nested_table from dual ;
NESTED_TABLE
NESTED_TABLE_TYPE('ACCOUNTING', 'RESEARCH', 'SALES', 'OPERATIONS')If your cursor selects objects instead of simple data types, the code is pretty much the same.
SQL> create type object_type as object ( c1 varchar2(14), c2 varchar2(13) );
2 /
Type created.
SQL> show errors
No errors.
SQL>
SQL> create type nested_table_type as table of object_type ;
2 /
Type created.
SQL> show errors
No errors.
SQL>
SQL>
SQL>
SQL> create function func
2 ( p_cursor in sys_refcursor )
3 return nested_table_type
4 as
5 v_nested_table nested_table_type ;
6 begin
7
8 fetch p_cursor bulk collect into v_nested_table ;
9 return( v_nested_table );
10
11 end;
12 /
Function created.
SQL> show errors
No errors.
SQL>
SQL> select
2 func( cursor( select object_type( dname, loc ) from dept ) ) as object_table
3 from dual ;
OBJECT_TABLE(C1, C2)
NESTED_TABLE_TYPE
( OBJECT_TYPE('ACCOUNTING', 'NEW YORK'),
OBJECT_TYPE('RESEARCH', 'DALLAS'),
OBJECT_TYPE('SALES', 'CHICAGO'),
OBJECT_TYPE('OPERATIONS', 'BOSTON')
)(NB I manually reformated the query results for clarity). -
How to call procedure in which one formal parameter is associative array ty
how to call procedure in which one formal parameter is associative array type,
pls explain with eg.>
above code work fine but when i use case then it give error like
i identifier should be declare
& my code is as
CASE v_array(i)
WHEN 'A' THEN
insert into di_ivpn_report (ID, test_name, table_name, status, entity, proposition)
values (v_att_id, v_att_name, 'DI_'||v_array(i)||'_REPORT'||'_'||v_att_id,
v_status, v_ent_name, v_array(i));
WHEN 'B' THEN
insert into di_mpls_report (ID, test_name, table_name, status, entity, proposition)
values (v_att_id, v_att_name, 'DI_'||v_array(i)||'_REPORT'||'_'||v_att_id,
v_status, v_ent_name, v_array(i));
END CASE;
>
Then you have to use ordinary loop
PROCEDURE insert_update_***_array (TRANID IN VARCHAR2, ATT_NAME IN VARCHAR2, ENT_NAME VARCHAR2, v_array IN ***_array)
IS
v_tranid VARCHAR2(1);
v_att_name VARCHAR2(100) := ATT_NAME;
v_ent_name VARCHAR2(100) := ENT_NAME;
v_att_id VARCHAR2(6);
v_ent_id NUMBER;
v_status VARCHAR2(20) DEFAULT 'INACTIVE';
I NUMBER;
BEGIN
i := v_array.first;
while i is not null loop
CASE v_array(i)
WHEN 'A' THEN
insert into di_ivpn_report (ID, test_name, table_name, status, entity, proposition)
values (v_att_id, v_att_name, 'DI_'||v_array(i)||'_REPORT'||'_'||v_att_id,
v_status, v_ent_name, v_array(i));
WHEN 'B' THEN
insert into di_mpls_report (ID, test_name, table_name, status, entity, proposition)
values (v_att_id, v_att_name, 'DI_'||v_array(i)||'_REPORT'||'_'||v_att_id,
v_status, v_ent_name, v_array(i));
END CASE;
i := v_array.next(i);
end loop;
end; -
How to call GOS(Generic Object service) attachment ( BMP file ) into SAP
How to call GOS(Generic Object service) attachment ( BMP file ) into SAP script
Example: MM02 Service object there attaching the bmp file the same file i need to call script based on the material number
Please provide the procedure and coding.
Thanks in advance
RajuHi,
The following link may be useful to u.
help.sap.com/printdocu/.../BCSRVOBS.pdf -
Any experience with Object Types and Forms6i / 9i ???
Has anyone got any experience in working with Object Types and Object Views together with Forms 6i or 9i???
TIA
Rob ZoeteweijHi AnneCarmen,
Check this small video, http://project02.businesscatalyst.com/Jing/2012-07-13_0508.swf
This is just an example where I am trying to demonstrate how the html embedded into the frame sticks to only one image and not to all the other images. Also, how to keep the thumbnails. Under menu options you can modify the transition and speed option as per your need.
Regards,
Abhishek Maurya -
How to call procedure and package in BI
IN OBIEE how to call procedure- function and pass parameter in it.??
Thanks
Jatin.Do you mean DB function. Check this link:
http://oracle-bi.siebelunleashed.com/articles/callingdb-function-in-obiee/
For OBIEE 11g, you have additional options to make calls with Action Framework. For now, I think the above link will help.
If helpful pls mark as correct or helpful -
How to Call Procedure or Function
Hi,
How to call a procedure or function in apex, Please let me know
Thanks
SudhirHi,
This post might help
Re: How to Call procedure In Processes
Regards,
Jari -
How to call a COM object from an Oracle Form?
Hi All,
Pls advice. How to call a COM object from an Oracle Form?
Thanks.try asking the "Form" forum
-
How to call procedure in Java from SQL Server Database
Hello Every Body
i Have Question about
How to call procedure in Java from SQL Server Database
ThanksHi,
have you tried a Google search? I just gave it a 3 second try and already found: http://stackoverflow.com/questions/6113674/how-do-i-execute-a-ms-sql-server-stored-procedure-in-java-jsp-returning-table-d
Frank -
Hi all,
in scott Schema by ADF B.C 10.1.3, I created an entity object like emp
and created view object EmpView from emp and dept entities
and Application Module
and when draging EmpView and dropping it in jspx
while running I got an error :
JB0-25003 your EmpView View Object has no Type
How to determine a View Object Type (read only or updatable) in B.C ?
ThanksHi,
this should not require any manual confiuration. Can you select the ApplicationModule in the model, right click on it and run the ADf BC tester ? Check if he ViewObject runs if not added to JSF
Frank -
How to create table with row type in smart forms
How to create table with row type in smart forms with out line type
please explain me the procedureHI,
A table type describes the structure and functional attributes of an internal table in ABAP. In ABAP programs you can reference a table type TTYP defined in the ABAP Dictionary with the command DATA <inttab> TYPE TTYP. An internal table <inttab> is created in the program with the attributes defined for TTYP in the ABAP Dictionary.
A table type is defined by:
its line type, that defines the structure and data type attributes of a line of the internal table
the options for managing and accessing the data ( access mode) in the internal table
the key ( key definition and key category) of the internal table
The row type is defined by directly entering the data type, length and number of decimal places or by referencing a data element, structured type ( structure, table or view) or other table type. Or the row type can be a reference type.
<b>for more info :</b> http://help.sap.com/saphelp_nw2004s/helpdata/en/fc/eb366d358411d1829f0000e829fbfe/content.htm
Internal table
Regards
Sudheer
Maybe you are looking for
-
Hi, One of my client needs the custom report as follows . The report should display the MONTHLY SALES QTY , AVAILABLE STOCK AT THE ENDOF THE MONTH for an Item by Warehouse or Location. The format is like this It
-
Want to access RFC in new server instead of old server
we got a request to move RFC function module from P12 to other system, now the RFC is moved and need to understand what should be done to access new system RFC instead of old RFC. Thanks & Regards Ramkumar Amgoth
-
I got this phone today, all looks good except it wont let me send texts or some other features. I can call without problem. The error in the notes of the messages which can't be sent is: Message sending failed No network support for messages. It's re
-
(oracle.jbo.DMLException) JBO-26061: Error while opening JDBC connection.How to remove this exception while running ADF application in Integrated weblogic server?
-
Forgot security question answers.how can I reset?
I remember my password and I want to change it, but i cant do it without answering the security questions. I dont remember the answer. I looked for an option to reset the question/answer In "manage my Id" > "password and security" and I couldn't fin