still some unanswered questions
Hannibal, November 24, 2003 - 6:32 am UTC
Hello Tom,
thx for all your help. i must comeback with some questions ... as you can see i tested the sys.anydata
with some objects and tables of objects. by using my little look-function i could look into the dump and
i guess i got a glimps on how your are storing the data magically :-). however, i looks like the results
of vsize and dump are only correct as long as the data is not too big???? the result of vsize on column
11 should be much bigger then column 10 but it is'nt, so i guess you shift the data to an other place
when it gets to big for a LONG or what ever. so i start to think vsize does only work for small(er) items.
is this correct? how can i get the real size of a bigger object if possible? is there a at least chance
to recognize that the value given by vsize is not the real value but a much smaller one. f.e., by examening
the dump?
i dislike it to ask you again if you could give an example for the correct usage of
sys.anydata.ConvertCollection. i know you are very buisy ... may be you give me a link where i can
read more on this topic.
regards
hannibal
== just creating some entryies ..
jom@NINA.US.ORACLE.COM> desc t
Name Null? Type
----------------------------------------------------- -------- ------------------------------------
ID NUMBER(38)
LDATA SYS.ANYDATA
jom@NINA.US.ORACLE.COM> insert into t values ( 1 , sys.anydata.convertnumber(1));
1 row created.
jom@NINA.US.ORACLE.COM> insert into t values ( 2 , sys.anydata.convertvarchar2('tom'));
1 row created.
jom@NINA.US.ORACLE.COM> insert into t values ( 3 , sys.anydata.convertdate(sysdate));
1 row created.
jom@NINA.US.ORACLE.COM> desc myobj
Name Null? Type
----------------------------------------------------- -------- ------------------------------------
HEADER VARCHAR2(256)
BODY VARCHAR2(1024)
== taking a object type
jom@NINA.US.ORACLE.COM> r
1 declare
2 obj myobj;
3 begin
4 obj := myobj(null,null);
5 obj.header := 'this is the header';
6 obj.body := 'this is the body - just a text ... ';
7 insert into t values ( 6 , sys.anydata.convertobject(obj));
8* end;
jom@NINA.US.ORACLE.COM> r
1 declare
2 obj myobj;
3 begin
4 obj := myobj(null,null);
5 obj.header := 'this is the header';
6 obj.body := 'this is the body - just a looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
og text ... ';
7 insert into t values ( 7 , sys.anydata.convertobject(obj));
8* end;
PL/SQL procedure successfully completed.
==taking a more complex object type
jom@NINA.US.ORACLE.COM> desc obj_test_tab;
obj_test_tab TABLE OF OBJ_TEST
Name Null? Type
----------------------------------------------------- -------- ------------------------------------
X NUMBER(5)
S VARCHAR2(32)
jom@NINA.US.ORACLE.COM> desc obj_test
Name Null? Type
----------------------------------------------------- -------- ------------------------------------
X NUMBER(5)
S VARCHAR2(32)
jom@NINA.US.ORACLE.COM> create or replace type myobj2 as object ( payload obj_test_tab );
2 /
Type created.
jom@NINA.US.ORACLE.COM> desc myobj2
Name Null? Type
----------------------------------------------------- -------- ------------------------------------
PAYLOAD OBJ_TEST_TAB
jom@NINA.US.ORACLE.COM> r
1 declare
2 obj2 myobj2;
3 tab obj_test_tab;
4 obj obj_test;
5 begin
6 obj := obj_test( null, null);
7 tab := obj_test_tab(null);
8 obj.x := 1;
9 obj.s := 'hallo';
10 tab.extend;
11 tab(1) := obj;
12 obj.x := 2;
13 obj.s := 'hallo2';
14 tab.extend;
15 tab(2) := obj;
16 obj2 := myobj2(null);
17 obj2.payload := tab;
18 insert into t values ( 10 , sys.anydata.convertobject(obj2));
19* end;
PL/SQL procedure successfully completed.
jom@NINA.US.ORACLE.COM> r
1 declare
2 obj2 myobj2;
3 tab obj_test_tab;
4 obj obj_test;
5 v_int int;
6 begin
7 obj := obj_test( null, null);
8 tab := obj_test_tab(null);
9 for v_int in 1..1000
10 loop
11 obj.x := v_int;
12 obj.s := 'hallo'||to_char(v_int);
13 tab.extend;
14 tab(v_int) := obj;
15 end loop;
16 obj2 := myobj2(null);
17 obj2.payload := tab;
18 insert into t values ( 11 , sys.anydata.convertobject(obj2));
19* end;
PL/SQL procedure successfully completed.
== the size is o.k., this is a much bigger object type.
jom@NINA.US.ORACLE.COM> r
1 declare
2 obj2 myobj2;
3 tab obj_test_tab;
4 obj obj_test;
5 v_int int;
6 begin
7 obj := obj_test( null, null);
8 tab := obj_test_tab(null);
9 for v_int in 1..1000
10 loop
11 obj.x := v_int;
12 obj.s := 'hallo'||to_char(v_int);
13 tab.extend;
14 tab(v_int) := obj;
15 end loop;
16 obj2 := myobj2(null);
17 obj2.payload := tab;
18 dbms_output.put_line(tab(600).s);
19 dbms_output.put_line(tab.count);
20* end;
hallo600
1001
PL/SQL procedure successfully completed.
jom@NINA.US.ORACLE.COM> r
1* select t.id , t.ldata, t.ldata.gettypename(), vsize(t.ldata) , dump(t.ldata), look(substr(dump(t.ldata),instr(dump(t.ldata),':'
,1,1)+2)) from t t
ID
----------
LDATA()
----------------------------------------------------------------------------------------------------
T.LDATA.GETTYPENAME()
----------------------------------------------------------------------------------------------------
VSIZE(T.LDATA)
--------------
DUMP(T.LDATA)
----------------------------------------------------------------------------------------------------
LOOK(SUBSTR(DUMP(T.LDATA),INSTR(DUMP(T.LDATA),':',1,1)+2))
----------------------------------------------------------------------------------------------------
1
ANYDATA()
SYS.NUMBER
48
Typ=58 Len=48: 0,1,0,0,0,0,0,1,0,0,0,0,148,115,0,32,9,0,0,0,0,0,0,16,0,0,0,0,0,1,133,1,16,1,1,0,2,0,
2,0,0,0,0,2,193,2,0,0
? ? ös ? ?à???? ? ? ?-?
2
ANYDATA()
SYS.VARCHAR2
49
Typ=58 Len=49: 0,1,0,0,0,0,0,1,0,0,0,0,148,116,0,33,9,0,0,0,0,0,0,17,0,0,0,0,0,1,133,1,17,1,1,0,2,0,
9,0,0,0,0,3,116,111,109,0,0
? ? öt ! ? ?à???? ? ?tom
3
ANYDATA()
SYS.DATE
53
Typ=58 Len=53: 0,1,0,0,0,0,0,1,0,0,0,0,148,117,0,37,9,0,0,0,0,0,0,21,0,0,0,0,0,1,133,1,21,1,1,0,2,0,
12,0,0,0,0,7,120,103,11,24,12,12,59,0,0
? ? öu % § ?à?§?? ? ? xg????;
5
ANYDATA()
JOM.MYOBJ
69
Typ=58 Len=69: 0,1,0,0,0,0,0,1,0,0,0,0,148,118,0,53,9,0,0,0,0,0,0,37,0,0,0,0,0,1,133,1,37,1,1,0,4,0,
108,194,204,83,80,126,191,69,39,165,152,44,62,150,104,32,64,0,1,0,0,0,0,5,132,1,5,255,255,0,0
? ? öv 5 % ?à?%?? ? l-¦SP~+E'Ñÿ,>ûh @ ? ?ä??
6
ANYDATA()
JOM.MYOBJ
122
Typ=58 Len=122: 0,1,0,0,0,0,0,1,0,0,0,0,148,119,0,106,9,0,0,0,0,0,0,90,0,0,0,0,0,1,133,1,90,1,1,0,4,
0,108,194,204,83,80,126,191,69,39,165,152,44,62,150,104,32,64,0,1,0,0,0,0,58,132,1,58,18,116,104,105
,115,32,105,115,32,116,104,101,32,104,101,97,100,101,114,35,116,104,105,115,32,105,115,32,116,104,10
1,32,98,111,100,121,32,45,32,106,117,115,116,32,97,32,116,101,120,116,32,46,46,46,32,0,0
? ? öw j Z ?à?Z?? ? l-¦SP~+E'Ñÿ,>ûh @ ? :ä?:?this is the header#this is the bod
y - just a text ...
7
ANYDATA()
JOM.MYOBJ
357
Typ=58 Len=357: 0,1,0,0,0,0,0,1,0,0,0,0,148,120,1,85,9,0,0,0,0,0,1,69,0,0,0,0,0,1,133,1,254,0,0,1,69
,1,1,0,4,0,108,194,204,83,80,126,191,69,39,165,152,44,62,150,104,32,64,0,1,0,0,0,1,33,132,1,254,0,0,
1,33,18,116,104,105,115,32,105,115,32,116,104,101,32,104,101,97,100,101,114,254,0,0,1,2,116,104,105,
115,32,105,115,32,116,104,101,32,98,111,100,121,32,45,32,106,117,115,116,32,97,32,108,111,111,111,11
1,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,11
1,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,11
1,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,11
1,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,11
1,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,11
1,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,11
1,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,11
1,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,11
1,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,103,32,116,101,120,116,32,46,46,46
,32,0,0
? ? öx?U ?E ?à?¦ ?E?? ? l-¦SP~+E'Ñÿ,>ûh @ ? ?!ä?¦ ?!?this is the header¦ ??thi
s is the body - just a loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
oooooooooooooooooooooooooooooooooooooooooooog text ...
10
ANYDATA()
JOM.MYOBJ2
103
Typ=58 Len=103: 0,1,0,0,0,0,0,1,0,0,0,0,148,167,0,87,9,0,0,0,0,0,0,71,0,0,0,0,0,1,133,1,71,1,1,0,4,0
,108,102,5,16,101,175,197,73,143,149,81,147,71,42,254,98,132,0,1,0,0,0,0,39,132,1,39,35,136,1,35,1,3
,0,3,12,132,1,12,2,193,2,5,104,97,108,108,111,13,132,1,13,2,193,3,6,104,97,108,108,111,50,255,0,0
?-??hallo2 öº W G ?à?G?? ? lf??e»+IÅòQôG*¦bä ? 'ä?'#ê?#?? ??ä???-??hallo
11
ANYDATA()
JOM.MYOBJ2
44
Typ=58 Len=44: 0,1,0,0,0,0,0,1,0,0,0,0,148,168,0,28,5,0,0,0,0,2,2,72,0,0,0,0,0,2,2,192,0,20,2,192,0,
21,2,192,0,22,0,0
? ? ö¿ ?? ??H ??+ ¶?+ §?+ ?
8 rows selected.
November 24, 2003 - 8:30 am UTC
it is going to be LOB storage and once the LOB gets bigger then about 4,000 bytes -- it goes out of line.
there is no capability beyond what I've shown for "getting the size" (not really sure why you "need" the size)