Oracle 9i Object Type ..using self
I have created and object with
several attributes of standard oracle datatypes. I have one that is of a custom object type. this object provides encapsulated functionality. I instansiate the internal custom object using a constructor function. the constructor includes the creation of a primary key. once the constructor is done, the object is initialized( an internal flag is set, which should only be done once)
To use this custom object in a member method, I have to do something like this..
( i have summarized code for brevity)
MEMBER FUNCTION foo( ) return obj
is
l_self PARENT_OBJ_TYPE:= SELF;
local INTERNAL_OBJ :=SELF.internal_obj;
begin
local.method1() -- insert record( flag is true)
local.method1() --insert another record( but this time the flag that was set upon construction is now set to FALSE..
I get an error.)
end;
I do not do anything tricky. the behavior seems to be that object types do not keep state appropriately.
any ideas of why this could be happening?
there was no real error code just unexpected behavior. it did not crash. I figured it out. it had to do with passing self as a parameter in out so that it keeps state
Similar Messages
-
Oracle Spatial Object types in Designer 6
Hi all,
I'm trying to design a database that uses the new Oracle Spatial Object types (MDSYS.SDO_GEOMETRY) etc. I have been able to capture the object types from Oracle8i but when i try to save the design in the repository it fails. I am assuming that the version of Oracle Designer I am using does not support MDSYS.SDO_GEOMETRY. Is this correct and if so what version of Designer should I be using?
MartinHi Saso,
I'm sorry I don't have any help for you but maybe yo can answer a question for me relating to sdo_geometry. I'm trying to capture a database schema which contains tables with sdo_geometry columns & this fails because I don't have that object defined.
So how do I access the Oracle Object Types branch to define MDSYS.SDO_GEOMETRY? Is it in the object navigator or designer?
Thanks,
Jim Greetham -
I just installed Adobe InDesign CC 2014 and now I can't scale objects/type using Command+Shift Key. Has anyone else had this problem and if so, any solution?
There is a conflict with third party software or your system keyboard shortcuts. Lately, there have been many postings about conflicts with Chrome extensions so check there first.
It's not a new problem. I wrote about it on InDesignSecrets.com in 2006:
The Missing Keystrokes Mystery | InDesignSecrets -
Passing Object types using JDBC
I need to pass Oracle user-defined object types in and out of
PL/SQL stored procedures. Is this possible???
Thanks
nullHi Tina,
I just had another thought. JDBC for 8.0 doesn't support
user-defined SQL types. This feature isn't implemented until 8i.
Sorry about the false lead!
So you'd have to wrapper your object in another PL/SQL method
which 'explodes' the user-defined type, as:
procedure can_call_from_jdbc (ename varchar2, empno number, ...)
is...
begin
call my_procedure(employee_t(ename, empno, ...));
end;
Pierre
Oracle Product Development Team wrote:
: Hi Tina,
: Yikes! I'm glad you asked; it made me realize that some info
: that's supposed to be posted on our external site is missing.
I
: think it'll take about a week to push this to our external
site.
: I'll try to find you a version and email it to you directly.
: Thanks!
: Pierre
: Tina Creighton (guest) wrote:
: : I'm currently using version 8.04 with Objects option, I'm
: trying
: : to locate the oracle.jpub class. Is there a way to download
: the
: : new jdbc that works with objects. Thanks. Tina
: : Oracle Product Development Team wrote:
: : : Absolutely!
: : : the easiest thing is first to use JPub to generate a Java
: : object
: : : which is an analogue to the SQL object you have. For
: example,
: : : if your SQL object is called 'EMPLOYEE_T', you can invoke
: JPub
: : : with:
: : : $ jpub -sql=employee_t -url=jdbc:oracle:oci8:@
: : -user=scott/tiger
: : : or even
: : : $ java oracle.jpub.Main -sql=employee_t
: -url=jdbc:oracle:oci8:@
: : : -user=scott/tiger
: : : This'll give you a Java class used to represent Java
: instances
: : of
: : : the SQL 'employee_t', featuring friendly setters and getter
: for
: : : the fields.
: : : If you have PL/SQL programs which take arguments of type
: : : employee_t, such as:
: : : PROCEDURE P1 (N NUMBER, E EMPLOYEE_T) IS...
: : : PROCEDURE P2 (N NUMBER, E OUT EMPLOYEE_T) IS...
: : : PROCEDURE P3 (N NUMBER, E IN OUT EMPLOYEE_T) IS...
: : : You can call them in a SQLJ program as:
: : : main () {
: : : employee_t e; // the class generated by JPub
: : : #sql {call P1(1, :e);}
: : : #sql {call P2(2, :out e);}
: : : #sql {call P3(3, :in out e);}
: : : to call your three PL/SQL procedures. After the call to P2
: and
: : : P3, your
: : : variable 'e' will be populated with the contents of the new
: : : employee_t value
: : : that was output from the PL/SQL method.
: : : (SQLJ is just a shorthand way of calling JDBC. SQLJ
programs
: : are
: : : translated
: : : into SQLJ programs by calling the "SQLJ Translator":
: : : $ sqlj myfile.sqlj
: : : Pierre
: : : Tina creighton (guest) wrote:
: : : : I need to pass Oracle user-defined object types in and
out
: of
: : : : PL/SQL stored procedures. Is this possible???
: : : : Thanks
: : : Oracle Technology Network
: : : http://technet.oracle.com
: Oracle Technology Network
: http://technet.oracle.com
Oracle Technology Network
http://technet.oracle.com
null -
Trying to pass Oracle array/object type to Java
I have a Java class with two inner classes that are loaded into Oracle:
public class PDFJ
public static class TextObject
public String font_name;
public int font_size;
public String font_style;
public String text_string;
public static class ColumnObject
public int left_pos;
public int right_pos;
public int top_pos;
public int bottom_pos;
public int leading;
public TextObject[] column_texts;
}I have object types in Oracle as such that bind to the Java classes:
CREATE OR REPLACE TYPE "PROGRAMMER"."PDFJ_TEXT" AS OBJECT
EXTERNAL NAME 'PDFJ$TextObject'
LANGUAGE JAVA
USING SQLData(
"FONT_NAME" VARCHAR2(25) EXTERNAL NAME 'font_name',
"FONT_SIZE" NUMBER EXTERNAL NAME 'font_size',
"FONT_STYLE" VARCHAR2(1) EXTERNAL NAME 'font_style',
"TEXT_STRING" VARCHAR2(4000) EXTERNAL NAME 'text_string'
CREATE OR REPLACE TYPE "PROGRAMMER"."PDFJ_TEXT_ARRAY" AS
TABLE OF "PROGRAMMER"."PDFJ_TEXT";
CREATE OR REPLACE TYPE "PROGRAMMER"."PDFJ_COLUMN" AS OBJECT
EXTERNAL NAME 'PDFJ$ColumnObject'
LANGUAGE JAVA
USING SQLData(
"LEFT_POS" NUMBER EXTERNAL NAME 'left_pos',
"RIGHT_POS" NUMBER EXTERNAL NAME 'right_pos',
"TOP_POS" NUMBER EXTERNAL NAME 'top_pos',
"BOTTOM_POS" NUMBER EXTERNAL NAME 'bottom_pos',
"LEADING" NUMBER EXTERNAL NAME 'leading',
"COLUMN_TEXTS" "PROGRAMMER"."PDFJ_TEXT_ARRAY" EXTERNAL NAME 'column_texts'
CREATE OR REPLACE TYPE "PROGRAMMER"."PDFJ_COLUMN_ARRAY" AS
TABLE OF "PROGRAMMER"."PDFJ_COLUMN";
/I successfully (as far as I know) build a PDFJ_COLUMN_ARRAY object in a PL/SQL procedure. The PDFJ_COLUMN_ARRAY contains PDFJ_COLUMN objects; each of those objects contains a PDFJ_TEXT_ARRAY of PDFJ_TEXT objects (Example: pdf_column_array(i).pdf_text_array(i).text_string := 'something';). In this procedure, I pass this PDFJ_COLUMN_ARRAY as a parameter to a Java function. I assume the Java function parameter is supposed to be a oracle.sql.ARRAY object.
I cannot figure out how to decompose this generic ARRAY object into a ColumnObject[] array. I also tried Googling and searching the forums, but I can't figure out matching search criteria. I was wondering if anyone here knows anything about passing user-defined Oracle type objects to a Java function and retrieving the user-defined Java class equivalents that they are supposedly mapped to--especially a user-defined array type of user-defined object types containing another user-defined array type of user-defined object types.Ok. I will try asking on the JDBC forum. So, don't
flame me for cross-posting. :PWe won't, if over there you just post basically a
link to this one.
sigh Guess what, he did it the flame-deserving way. It's crossposted at:
http://forum.java.sun.com/thread.jspa?threadID=602805
<flame level="mild">Never ceases to amaze me how people don't think that posting a duplicate rather than a simple link isn't wasteful, as people could end up answering in both of them, not seeing each other's answers</flame> -
Oracle table object type - Error
Hi,
I have created an oracle object as like
[CREATE OR REPLACE TYPE t_test_obj IS OBJECT (
testid INTEGER,
testdesc VARCHAR2(64)
Then created the type table from above
[ create or replace type t_table as table of t_test_obj;]
i want to create the table containing the above type like below
create table t_tab_test (test1 t_table); but i received the error as like
ERROR at line 1:
ORA-22913: must specify table name for nested table column or attribute
Requirement: As one my function returns this table type object and i want to insert those values in a table hence i want this. Any other pointers are also helpful.
Please help.
Regards,
KapilThanks for reply.
As i described in Requirement, my function return the table type, hence if i try to insert i get error as below. t_table is the return type from function. I need conversion from table type to object type.
SQL> insert into testing values(1,t_table(1,'a'));
insert into testing values(1,t_table(1,'a'))
ERROR at line 1:
ORA-00932: inconsistent datatypes: expected IRP_DBO.T_TEST_OBJ got IRP_DBO.T_TABLE -
Oracle query with out using self join
hi friends,
i have one table for exeample PERSTATUS
pk/fK STUDENT NUMBER SUBJECT MARKS STATUS
1 ACCOUNTS 15 RED
1 MATHS 35 YELLOW
1 SCINECE 45 GREEN
2 ACCOUNTS 55 BROWN
2 MATHS 35 YELLOW
2 SCINECE 45 GREEN
3 ACCOUNTS 15 RED
3 MATHS 35 YELLOW
3 SCINECE 45 GREEN
i want students how status is both red and yellow so i am using self join
i want students status is both red and yellow so i am using self join
SELECT PS.STUDENTNUMBER,PS.STATUS,PS.STATUS1 FROM PERSTATUS PS ,PERSTATUS PS1
WHERE PS.STUDENTNUMBER-PS1.STUDENTNUMER
PS.STATUS='RED' AND PS1.STAUTS='YELLOW'
i want students status is both RD and YELLOW AND GREEN so i am using self join( two self joinS}
SELECT PS.STUDENTNUMBER,PS.STATUS,PS.STATUS,PS2.STATUS FROM PERSTATUS PS ,PERSTATUS PS1,PERSTATUS PS2
WHERE PS.STUDENTNUMBER-PS1.STUDENTNUMER AND PS.STUDENTNUMBER-PS2.STUDENTNUMBER
PS.STATUS='RED' AND PS1.STAUTS='YELLOW' AND PS2.STAUTUS='GREEN'
if i require MORE STATUS then more self joins required, is there any alternative to achive this
and if results comes in multiple rows are accepted (since with the above query result will come in single row)
i tried to use group by (studentnumber,status) with status='red' and status='yellow'
but it is not possible could you povidet he solutionHi,
Whenever you have a problem, please post CREATE TABLE and INSERT statements for your sample data, and the exact results you want from that data. Explain how you get those results from that data.
See the forum FAQ {message:id=9360002}
Here's an example of how to post the sample data:
CREATE TABLE perstatus
( studentnumber NUMBER
, subject VARCHAR2 (10)
, marks NUMBER
, status VARCHAR2 (10)
INSERT INTO perstatus (studentnumber, subject, marks, status)
VALUES (1, 'ACCOUNTS', 15, 'RED');
INSERT INTO perstatus (studentnumber, subject , marks, status)
VALUES (1, 'MATHS', 35, 'YELLOW');
INSERT INTO perstatus (studentnumber, subject, marks, status)
VALUES (1, 'SCINECE', 45, 'GREEN');
INSERT INTO perstatus (studentnumber, subject, marks, status)
VALUES (2, 'ACCOUNTS', 55, 'BROWN');
INSERT INTO perstatus (studentnumber, subject , marks, status)
VALUES (2, 'MATHS', 35, 'YELLOW');
INSERT INTO perstatus (studentnumber, subject, marks, status)
VALUES (2, 'SCINECE', 45, 'GREEN');
INSERT INTO perstatus (studentnumber, subject, marks, status)
VALUES (3, 'ACCOUNTS', 15, 'RED');
INSERT INTO perstatus (studentnumber, subject , marks, status)
VALUES (3, 'MATHS', 35, 'YELLOW');
INSERT INTO perstatus (studentnumber, subject, marks, status)
VALUES (3, 'SCINECE', 45, 'GREEN');You were on the right track, thinking about GROUP BY. You're interested in something about the whole group of rows that has the same studentnumber. Looking at any individual row won't tell you if that row is part of the group you're interested in or not.
If you want to see information about the group as a whole, you can do the whole job with GROUP BY. In this case, studnetnumber is the only thing that an entire group has in common. If you wanted to see the studentnumbers that had both RED and YELLOW, that is:
STUDENTNUMBER
1
3here's one way you could do it:
SELECT studentnumber
FROM perstatus
WHERE status IN ('RED', 'YELLOW')
GROUP BY studentnumber
HAVING COUNT (DISTINCT status) = 2 -- That is, both RED and YELLOW
ORDER BY studentnumber
;But say you wanted to see details about individuals in the group; for example, say we want to see all the columns for students that have all 3 of RED, YELLOW and GREEN, like this:
STUDENTNUMBER SUBJECT MARKS STATUS
1 SCINECE 45 GREEN
1 ACCOUNTS 15 RED
1 MATHS 35 YELLOW
3 SCINECE 45 GREEN
3 ACCOUNTS 15 RED
3 MATHS 35 YELLOWWe used the aggregate COUNT function earlier, but aggregate functions require collapsing the results down to one row per group.
However, most of the aggregate functions, like COUNT, have analytic counterparts, that can give the same results without collapsing the result set. Here's one way to get the results above, using the analytic COUNT function:
WITH got_cnt AS
SELECT studentnumber, subject, marks, status
, COUNT ( DISTINCT CASE
WHEN status IN ('RED', 'YELLOW', 'GREEN')
THEN status
END
) OVER (PARTITION BY studentnumber) AS cnt
FROM perstatus
SELECT studentnumber, subject, marks, status
FROM got_cnt
WHERE cnt = 3
ORDER BY studentnumber
, status
; -
How to Convert OBJECT_TYPE to the Object Type Used for DBMS_METADATA?
How do you convert the object type in ALL_OBJECTS to the object type that DBMA_METADATA.GET_DDL expects?
Thanks,
Kurzmaybe one needs to find a mapping between sys.metaview$ and all_objects:
SQL> select type, xmltag, udt, viewname from sys.metaview$ where type like '%PACKAGE%'
TYPE XMLTAG UDT VIEWNAME
DE_S_PACKAGE
DE_S_COMP_PACKAGE
DE_S_COMP_PACKAGE2
DE_S_COMP_PACKAGE_SPEC
DE_S_PACKAGE_BODY1
DE_S_PACKAGE_BODY
SE_PACKAGE
SE_COMP_PACKAGE
SE_COMP_PACKAGE2
SE_COMP_PACKAGE_SPEC
SE_PACKAGE_BODY
PACKAGE PACKAGE_T KU$_PROC_T KU$_PKG_VIEW
PACKAGE PACKAGE_BODY_T KU$_PROC_T KU$_PKGBDY_VIEW
PACKAGE FULL_PACKAGE_T KU$_FULL_PKG_T KU$_FULL_PKG_VIEW
PACKAGE_SPEC PACKAGE_T KU$_PROC_T KU$_PKG_VIEW
PACKAGE_BODY PACKAGE_BODY_T KU$_EXP_PKG_BODY_T KU$_EXP_PKG_BODY_VIEW
ALTER_PACKAGE_SPEC ALTER_PACKAGE_SPEC_T KU$_ALTER_PROC_T KU$_ALTER_PKGSPC_VIEW
ALTER_PACKAGE_BODY ALTER_PACKAGE_BODY_T KU$_ALTER_PROC_T KU$_ALTER_PKGBDY_VIEW
18 rows selected. -
Is there a good way to model oracle object types using ERD's in designer 6i. I can only figure out how to map to tables with columns of predefined datatypes (varchar2, number, date, long). I'd like to use designer to create new datatypes. Is this possible? Thanks.
Hi Wiiliam
Sorry for the late acknowledgement (i dozed off!).. Thanks for the response. So the private instance specific to a session ensure that theres no conflict between multiple requests to the same stored proc and hence no conflict of data... Great
Chaitanya -
Plsql object type polymorphism
Hi everyone.
Is adhoc polymorphism possible in pl/sql using Oracle's object types? Here is some sample code that I tried on an Oracle 10.2.0.3 64-bit database running on Solaris.
Connected.
09:58:58 SQL> create type root_ty as object (
09:59:03 2 a1 varchar2(32 char)
09:59:03 3 ) not final
09:59:03 4 /
Type created.
Elapsed: 00:00:00.17
09:59:05 SQL> create type sub_ty under root_ty (
09:59:10 2 a2 varchar2(32 char)
09:59:10 3 , constructor function sub_ty(str in varchar2) return self as resul
09:59:10 4 , member procedure display_a2
09:59:10 5 ) final
09:59:10 6 /
Type created.
Elapsed: 00:00:00.06
09:59:12 SQL> create or replace type body sub_ty is
09:59:18 2 constructor function sub_ty(str in varchar2)
09:59:18 3 return self as result
09:59:18 4 is
09:59:18 5 begin
09:59:18 6 self.a2 := str;
09:59:18 7
09:59:18 8 return;
09:59:18 9 end;
09:59:18 10
09:59:18 11 member procedure display_a2
09:59:18 12 is
09:59:18 13 begin
09:59:18 14 dbms_output.put_line('a2 value is .... '||a2);
09:59:18 15 end;
09:59:18 16 end;
09:59:18 17 /
Type body created.
Elapsed: 00:00:00.04
09:59:20 SQL> set serveroutput on
10:00:31 SQL> declare
10:00:35 2 l_ty root_ty;
10:00:35 3 begin
10:00:35 4 l_ty := new sub_ty('Woot!');
10:00:35 5
10:00:35 6 l_ty.display_a2();
10:00:35 7 end;
10:00:35 8 /
l_ty.display_a2();
ERROR at line 6:
ORA-06550: line 6, column 8:
PLS-00302: component 'DISPLAY_A2' must be declared
ORA-06550: line 6, column 3:
PL/SQL: Statement ignored
Elapsed: 00:00:00.06
10:00:37 SQL> declare
10:00:53 2 l_ty root_ty;
10:00:53 3 begin
10:00:53 4 l_ty := new sub_ty('Woot!');
10:00:53 5
10:00:53 6 -- l_ty.display_a2();
10:00:53 7 end;
10:00:53 8 /
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.01
10:00:53 SQL> declare
10:01:30 2 l_ty sub_ty;
10:01:30 3 begin
10:01:30 4 l_ty := new sub_ty('Woot!');
10:01:30 5
10:01:30 6 l_ty.display_a2();
10:01:30 7 end;
10:01:30 8 /
a2 value is .... Woot!
PL/SQL procedure successfully completed.Certainly seems like this should be possible ... Am I missing something simple?
Thanks for any input.
- KRHere is an example of what polymorphism is supposed to do:
SQL> create type bird as object
2 (name varchar2 (30)
3 , member function fly return varchar2
4 , member function make_a_noise return varchar2)
5 not final
6 /
Type created.
SQL>
SQL> create type birds_nt as table of bird;
2 /
Type created.
SQL>
SQL>
SQL> create or replace type body bird as
2
3 member function fly return varchar2
4 is
5 begin
6 return 'my name is '||self.name;
7 end;
8
9 member function make_a_noise return varchar2
10 is
11 begin
12 return 'generic twitter';
13 end;
14
15 end;
16 /
Type body created.
SQL>
SQL>
SQL> create type duck under bird (
2 overriding member function make_a_noise return varchar2
3 , member procedure waddle
4 );
5 /
Type created.
SQL>
SQL> create or replace type body duck as
2
3
4 overriding member function make_a_noise return varchar2
5 is
6 begin
7 return 'quack!';
8 end;
9
10 member procedure waddle
11 is
12 begin
13 null;
14 end;
15
16
17 end;
18 /
Type body created.
SQL>
SQL>
SQL>
SQL> create type chicken under bird (
2 overriding member function make_a_noise return varchar2
3 , member procedure peck
4 )
5 not final;
6 /
Type created.
SQL>
SQL> create or replace type body chicken as
2
3
4 overriding member function make_a_noise return varchar2
5 is
6 begin
7 return 'cluck!';
8 end;
9
10 member procedure peck
11 is
12 begin
13 null;
14 end;
15
16
17 end;
18 /
Type body created.
SQL>
SQL> create type canary under bird (
2 overriding member function make_a_noise return varchar2
3 );
4 /
Type created.
SQL>
SQL> create or replace type body canary as
2
3
4 overriding member function make_a_noise return varchar2
5 is
6 begin
7 return 'I taught I taw a puddy tat!!!';
8 end;
9
10
11 end;
12 /
Type body created.
SQL>
SQL> create type rooster under chicken (
2 overriding member function make_a_noise return varchar2
3 )
4 ;
5 /
Type created.
SQL>
SQL> create or replace type body rooster as
2
3
4 overriding member function make_a_noise return varchar2
5 is
6 begin
7 return 'That''s a joke... I say, that''s a joke, son.';
8 end;
9
10
11 end;
12 /
Type body created.
SQL>
SQL>
SQL>
SQL>
SQL> declare
2 my_aviary birds_nt := birds_nt();
3 begin
4 my_aviary.extend(5);
5 my_aviary(1) := duck('Donald');
6 my_aviary(2) := chicken('Chicken Little');
7 my_aviary(3) := canary('Tweetie Pie');
8 my_aviary(4) := rooster('Foghorn Leghorn');
9 my_aviary(5) := bird('?');
10 for idx in my_aviary.first()..my_aviary.last()
11 loop
12 dbms_output.put_line( my_aviary(idx).fly() );
13 dbms_output.put_line( my_aviary(idx).make_a_noise() );
14 end loop;
15 end;
16 /
my name is Donald
quack!
my name is Chicken Little
cluck!
my name is Tweetie Pie
I taught I taw a puddy tat!!!
my name is Foghorn Leghorn
That's a joke... I say, that's a joke, son.
my name is ?
generic twitter
PL/SQL procedure successfully completed.
SQL>Now, in that loop woudl it make sense to execute a peck() on all of those entries? Nope. Furthermore as far as I can tell it is not possible to find out what sub-type an object is from with PL/SQL, so you couldn't even use Padders's TREAT ploy.
So: if you want to do something generic use a super-type. If you want to do something specific use a sub-type.
Cheers, APC
blog: http://radiofreetooting.blogspot.com -
How could I Encrypt the data of SDO_GEOMETRY type using DBMS_CRYPTO package
Hi:
I want to Encrypt the data of SDO_GEOMETRY object type using DBMS_CRYPTO package.
What could I do? hope anyone can help me,give me a suggestions!
thanks in advance.
lgswell, the spatial api would not be able to handle this data anymore, so what you are trying to do is converting an SDO_GEOMETRY to some cryptable user type (see http://download-uk.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_crypto.htm#sthref1506) and encrypting this.
Before using the SDO_GEOMETRY type will have to decrypt and reconvert it again and pass it to the spatial query or function. -
Get object type attribute value
1 am trying binding Oracle Object types to java object types using the ORAData interface.
I created a simple object type called att_mesg_type with the syntax
create type att_mesg_type as object (subject varchar2(200),Text varchar2(1000));
I then created a class called attMesgType using Jpublisher which implements the interface.
The getSubject() and getText() method return '???'.
Anybody has any insights? Any inputs are appreciated.declare
attr_name varchar2(10) := 'ATTR1';
attr_value varchar2(50);
type_instance MyType := MyType('VALUE 1', 'VALUE 2');
begin
execute immediate 'declare type_instance MyType := :1; begin :2 := type_instance.' || attr_name || '; end;'
using type_instance,out attr_value;
dbms_output.put_line(attr_value);
end;
VALUE 1
PL/SQL procedure successfully completed.
SQL> SY. -
Bind problem for varchar2 of object type??
Hello all,
I am trying out binding Oracle Object types to java object types using the SQLData interface.
I created a simple object type called employee with the syntax
create type employee as object (empName varchar2(50),empNo number(9));
I then created a class called EmplyoeeObj which implements the interface. The code for the readSQL and
writeSQL methods are below:
public void readSQL(SQLInput stream, String typeName) throws SQLException {
empName = stream.readString();
empNo = stream.readInt();
public void writeSQL(SQLOutput stream) throws SQLException {
stream.writeString(empName);
stream.writeInt(empNo);
empName is a String and empNo is an int. The code that does the calling is:
String query = "{call test_employee(?)}";
Map map = connection.getTypeMap();
map.put("CISWEB.EMPLOYEE",
Class.forName("test.jdbc.EmployeeObj"));
/*Set back the type map with the new mappings*/
connection.setTypeMap(map);
/*Create a statement to make the call */
ocs = (OracleCallableStatement)connection.prepareCall(query);
ocs.registerOutParameter(1,
OracleTypes.STRUCT,
"CISWEB.EMPLOYEE");
boolean isWorked = ocs.execute();
System.out.println("Execute finished........");
Object outParam = ocs.getObject(1);
System.out.println("Object was obtained........" + outParam);
System.out.println("name:" + ((EmployeeObj)outParam).getName());
As can be seen I have created a stored procedure which has one out parameter. All
this preocedure does is assign an Employee object to the out parameter with a name of
'Alex' and an employee number of 9.
The code runs and all but I get this strange result. In the print I am getting the employee number
coming out correctly but the employee name comes out as 3 question marks. I can't understand why
"Alex" does not out. I have tried different things such as adding a new varchar2 to the object type and new a new integer and what I observer is that I keep getting 3 question marks coming back instead of whatever I assign for the employee name. Could someone please help and let me know what could be wrong?
I have no clue as what is causing this weird behaviour.
Thanks.Hi,
i have not really a idea. But at the next step i would
try the same procedure with in/out parameter and use a
initialized string. Maybe there is a problem to
determine the length of string.
Bye ThomasThanks for you reply Thomas,
This is the code for stored procedure that I use. As can be seen I just assign an employee to the
out parameter.
CREATE OR REPLACE PROCEDURE test_employee(emp out EMPLOYEE) IS
BEGIN
emp := EMPLOYEE('Alex',49);
END;
Now in the java code when the statement >>
System.out.println("name:" + ((EmployeeObj)outParam).getName());
executes I get the name coming out as the String: "???". That is three question marks. It is very weird. I then attempted to create the object using JPublisher and I get the same result. I attempted not only to use hte SQLData interface but Oracle's ORAData interfaces as well. I went to to create a table with column as the EMPLOYEE type and use in insert to put the same object and and then sellect * from the table to the the and I still get the 3 question marks for the name and the number comes out correctly.
I am not sure what could be causing the text to come out as three question marks. I am using Oracle 9.2.0.4.0 and the ojdbc_g.jar drivers version :9.2.0.3.0. Any help would be greatly appreciated.
Thanks -
Hi All,
I need to create a custom object type using SWO1.
The object type needs to be linked to a report program with selection screen(or its tcode).
The selection screen carries just 1field. The output is a new screen.
Would appreciate if any1 can tell me the step-by-step process to accomplish my objective.
-Ram.Enter a name.
Hit create. Populate the manadatory pop ups don't populate super type.
Blow out the key field. Create a key field.
Blow out the methods - add a method. Add the code for the method - select the method and hit the program button add code as below:
BEGIN_METHOD RUNDUPREPORT CHANGING CONTAINER.
SET PARAMETER ID 'VPA' FIELD OBJECT-KEY-PARTNEREMPLOYEEID.
export object-key-partneremployeeid to memory id '99'.
CALL TRANSACTION 'ZEML' AND SKIP FIRST SCREEN.
*object-key-partneremployeeid.
END_METHOD.
Create your event.
My method calls an abap I wrote that is bound to a transaction.
You will need to set the release status for all of the elements of your object and the object itself.
The question I have is why. Are you calling the object in a workflow? If so you will need to use the fm as below:
DATA: OBJTYPE LIKE SWETYPECOU-OBJTYPE VALUE 'ZRM_WWCONT',
EVENT LIKE SWETYPECOU-EVENT VALUE 'DuplicateEmail',
OBJKEY LIKE SWEINSTCOU-OBJKEY,
EVENTID LIKE SWEDUMEVID-EVTID.
DATA: BEGIN OF EVENT_CONTAINER OCCURS 0.
INCLUDE STRUCTURE SWCONT.
DATA: END OF EVENT_CONTAINER.
OBJKEY = KNVK-PARNR.
CALL FUNCTION 'SWE_EVENT_CREATE'
EXPORTING
OBJTYPE = OBJTYPE
OBJKEY = OBJKEY
EVENT = EVENT
START_WITH_DELAY = ' '
START_RECFB_SYNCHRON = ' '
IMPORTING
EVENT_ID = EVENTID
TABLES
EVENT_CONTAINER = EVENT_CONTAINER
EXCEPTIONS
OBJTYPE_NOT_FOUND = 1
OTHERS = 2.
COMMIT WORK.
Good Luck. -
Hi!
I want to create new object type using trans SWO1.
When i try to create for example object type ZEMP_NEW , i need also the supertype.
I want to create new buisness object witout using existing one or with delegation.
How do i do it?
Do i miss something?
regards
yifathi,
Check this SAP help link,
http://help.sap.com/saphelp_nw2004s/helpdata/en/4f/5668735cf211d194a30000e82dec10/frameset.htm
rgds
anver
if hlped mark points
Maybe you are looking for
-
Can I install windows on a fresh hard drive?
I'm installing a fresh hard drive into a macbook pro, I'm wondering if the hard drive will accept a windows 7 disc to install as OS, or will it only accept OSX, and if I'd have to go through bootcamp.
-
Find and Replace Font Colors in Multiple Text Boxes
Hello, I have Illustrator version 15 I made many text boxes with multiple colors, red and black on each letter. I was wondering if there is a find and replace tool for multiple text boxes. I want to change the reds to black and the blacks to light gr
-
T23 will not install Windows XP
Hello IBM/Lenovo Community members! My name is Justin. I recently aquired an old IBM T23 (type 2647) from my work. It is fully functional, and has some upgraded specs. Currently, it has 512 MB of SD RAM and a 40 GB hard drive that is not the original
-
Ever since I switched to Snow Leopard, I'm having an odd issue with Time Machine. First of all, the switchover to SL with respect to Time Machine went smoothly. However, every time I restart my machine, I have to go to TM preferences and tell it whic
-
Why doesn't anyone care about the 20 states limit!!!
Need i say more...??? This product would change the way you present interactive media on-line... But the 20 state limit is a deal breaker! I'm not looking for a discussion on ways around this product flaw, but some words of encouragement from users