Pl sql invalid datatype error for table casting(PL/SQL: ORA-00902: invalid)
See the code snippet -
Create or Replace Package xyz.abc as
TYPE rec_local is record of (primary_key emp.p_key%type, nam emp.name%type,addres emp.address%type);
Type tab_local is Table of rec_local;
Procedure exclude_pkey (tab1 IN tab_local );
End xyz.abc
Create or Replace Package Body xyz.abc as
Procedure exclude_pkey (tab1 IN tab_local );
Cursor cur is
select primary_key
from table(*cast(tab1 as tab_local *)))
where primary_key NOT IN (select primary_key
from emp)
BEGIN
END exclude_pkey ;
End abc;
I came to know the process that for query purpose we cant use pl/sql type, it must sql type, i.e. creating object and table of that object type in sql,and use of MEMEBER OF ,but what should i do in this case where insted of IN(MEMBER OF can be used for the case of IN) ,NOT IN is used for query.
please reply,
thank you
You are only selecting a single column, primary_key, in your cursor.
You could use the built in sys.ODCINumberlist or sys.ODCIVarchar2list data types instead and pass in only the primary_key.
Re: Passing an array to an Oracle stored procedure
http://download.oracle.com/docs/cd/E11882_01/appdev.112/e10765/ext_types_ref.htm#ADDCI5012
If you are on an old version you can create your own types with the same definition.
Using a cursor like that I can tell that you want to do whatever this does as slowly and inefficiently as possible though.
Re: using cursor to sum numbers, gives error
Re: global temporary table row order
Similar Messages
-
Table cast PL/SQL: ORA-00902: invalid datatype
I m getting
PL/SQL: ORA-00902: invalid datatype
error in
OPEN pPymtCur FOR
SELECT *
FROM TABLE(CAST( up_gap_tra_reports.myArray AS traArray));
in my package up_gap_tra_reports.
CREATE OR REPLACE PACKAGE GAPSDVEL.up_gap_tra_reports
AS
TYPE traRecord IS RECORD
group1StudEnrol NUMBER(6,1),
group2StudEnrol NUMBER(6,1),
pymtAmt gap_payment.NET_AMT%TYPE
TYPE traArray IS TABLE OF traRecord;
myArray traArray := traArray() ;
END up_gap_tra_reports;
I hv alreay declared traArray type.
pls help me to solve this.Meghna wrote:
is there any way to use pl/sql collection in SQL or refcur without creating it because i am not able to create type in database.The only way I am aware of is pipelined function:
create or replace
package pkg1
is
type traRecord
is record(
ename emp.ename%type,
sal emp.sal%type
TYPE traArray IS TABLE OF traRecord;
function f1
return traArray
pipelined;
end;
create or replace
package body pkg1
is
function f1
return traArray
pipelined
is
v_rec traRecord;
begin
v_rec.ename := 'Sam';
v_rec.sal := 1000;
pipe row(v_rec);
v_rec.ename := 'John';
v_rec.sal := 1500;
pipe row(v_rec);
v_rec.ename := 'Mary';
v_rec.sal := 2000;
pipe row(v_rec);
return;
end;
end;
/Now you can:
SQL> select * from table(pkg1.f1)
2 /
ENAME SAL
Sam 1000
John 1500
Mary 2000
SQL>Keep in mind, it will create system generated types:
SQL> select type_name from user_types
2 /
TYPE_NAME
SYS_PLSQL_73305_9_1
SYS_PLSQL_73305_DUMMY_1
SYS_PLSQL_73305_34_1
SQL> desc SYS_PLSQL_73305_9_1
Name Null? Type
ENAME VARCHAR2(10)
SAL NUMBER(7,2)
SQL> desc SYS_PLSQL_73305_DUMMY_1
SYS_PLSQL_73305_DUMMY_1 TABLE OF NUMBER
SQL> desc SYS_PLSQL_73305_34_1
SYS_PLSQL_73305_34_1 TABLE OF SYS_PLSQL_73305_9_1
Name Null? Type
ENAME VARCHAR2(10)
SAL NUMBER(7,2)
SQL> SY. -
ORA-00902: invalid datatype comile error while using CAST function
Hi everyone,
I'm getting ORA-00902: invalid datatype compilation error while using CAST function.
open ref_cursor_list for select empName from TABLE(CAST(part_t AS partnumberlist));
The partnumberlist and ref_cursor_list is declared in the Package spec as given below.
TYPE ref_cursor_list IS REF CURSOR;
TYPE partnumberlist IS TABLE OF emp.empName%TYPE;
The error points the partnumberlist as invalid datatype in TOAD because of this i'm unable to compile the package.
Any suggestion
Thanks and regards
Sathish GopalHere is my code for
package Spec
CREATE OR REPLACE PACKAGE "HISTORICAL_COMMENTZ" AS
TYPE prior_part_data_record IS RECORD (
prior_part_row_id PGM_RPLCMNT_PART.PR_PART_ROW_S_ID%TYPE,
prior_pgm_chng_s_id PGM_RPLCMNT_PART.PR_PGM_CHNG_S_ID%TYPE
TYPE parts_list IS TABLE OF prior_part_data_record;
--TYPE parts_list IS TABLE OF NUMBER;
TYPE partnumberlist IS TABLE OF PGM_RPLCMNT_PART.PR_PART_ROW_S_ID%TYPE;
TYPE partnumber_cursor IS REF CURSOR;
TYPE comment_record IS RECORD (
pgm_s_id PGM_PART_CMNT.PGM_S_ID%TYPE,
part_row_s_id PGM_PART_CMNT.PART_ROW_S_ID%TYPE,
pgm_chng_s_id PGM_PART_CMNT.PGM_CHNG_S_ID%TYPE,
cmnt_txt PGM_PART_CMNT.CMNT_TXT%TYPE,
cmnt_dt PGM_PART_CMNT.CMNT_DT%TYPE,
updt_rsrc_id PGM_PART_CMNT.UPDT_RSRC_ID%TYPE
TYPE comment_list IS TABLE OF comment_record;
global_pgm_s_id INTEGER := 0;
global_part_row_s_id INTEGER := 0;
err_num NUMBER := 999999;
err_msg VARCHAR2 (250);
PROCEDURE getComments (
pgm_s_id IN NUMBER,
part_row_s_id IN NUMBER,
partnumber_cursorlist out partnumber_cursor);
END;
Package Body
CREATE OR REPLACE PACKAGE BODY HISTORICAL_COMMENTZ
AS
FUNCTION getPriorPart
(param_prior_pgm_chng_s_id IN PGM_RPLCMNT_PART.PR_PGM_CHNG_S_ID%TYPE,
return_prior_part_data_record IN OUT prior_part_data_record
RETURN INTEGER
IS
retVal INTEGER;
prior_part_row_id INTEGER;
prior_pgm_chng_s_id INTEGER;
local_prior_part_data_record prior_part_data_record;
BEGIN
SELECT PR_PART_ROW_S_ID AS prior_part_row_id, PR_PGM_CHNG_S_ID AS prior_pgm_chng_s_id
INTO local_prior_part_data_record
--SELECT PR_PART_ROW_S_ID INTO retVal
FROM PGM_RPLCMNT_PART
WHERE PGM_S_ID = global_pgm_s_id AND CUR_PGM_CHNG_S_ID = param_prior_pgm_chng_s_id;
return_prior_part_data_record := local_prior_part_data_record;
retVal := 0;
RETURN retVal;
EXCEPTION
WHEN NO_DATA_FOUND
THEN
err_num := SQLCODE;
err_msg := 'SQL Error ' || SUBSTR (SQLERRM, 1, 250);
DBMS_OUTPUT.put_line ('SQLERROR = ' || err_msg);
retVal := -1;
RETURN retVal;
WHEN OTHERS
THEN
err_num := SQLCODE;
err_msg := 'SQL Error ' || SUBSTR (SQLERRM, 1, 250);
DBMS_OUTPUT.put_line ('SQLERROR = ' || err_msg);
retVal := -1;
RETURN retVal;
END getPriorPart;
FUNCTION getComment (found_parts_list IN parts_list, comments OUT comment_list)
RETURN INTEGER
IS
CURSOR init_cursor
IS
SELECT PGM_S_ID,PART_ROW_S_ID,PGM_CHNG_S_ID,CMNT_TXT,CMNT_DT,UPDT_RSRC_ID
FROM PGM_PART_CMNT WHERE 1 = 2;
retVal INTEGER;
indexNum PLS_INTEGER;
local_part_record prior_part_data_record;
local_comment_record comment_record;
local_part_row_s_id NUMBER;
i PLS_INTEGER;
BEGIN
OPEN init_cursor;
FETCH init_cursor
BULK COLLECT INTO comments;
i := 0;
indexNum := found_parts_list.FIRST;
WHILE indexNum IS NOT NULL
LOOP
local_part_record := found_parts_list(indexnum);
local_part_row_s_id := local_part_record.prior_part_row_id;
SELECT PGM_S_ID,PART_ROW_S_ID,PGM_CHNG_S_ID,CMNT_TXT,CMNT_DT,UPDT_RSRC_ID
INTO local_comment_record FROM PGM_PART_CMNT
WHERE PGM_S_ID = global_pgm_s_id
AND PART_ROW_S_ID = local_part_row_s_id;
comments(i) := local_comment_record;
i := i + 1;
END LOOP;
RETURN retval;
EXCEPTION
WHEN NO_DATA_FOUND
THEN
err_num := SQLCODE;
err_msg := 'SQL Error ' || SUBSTR (SQLERRM, 1, 250);
DBMS_OUTPUT.put_line ('SQLERROR = ' || err_msg);
RETURN retval;
WHEN OTHERS
THEN
err_num := SQLCODE;
err_msg := 'SQL Error ' || SUBSTR (SQLERRM, 1, 250);
DBMS_OUTPUT.put_line ('SQLERROR = ' || err_msg);
RETURN retval;
END getComment;
PROCEDURE getComments
pgm_s_id IN NUMBER,
part_row_s_id IN NUMBER,
partnumber_cursorlist OUT partnumber_cursor)
IS
comment_recordlist comment_record;
retPartnumberlist partnumberlist;
found_parts_list parts_list;
local_part_record prior_part_data_record;
is_more_parts BOOLEAN;
driver_chng_s_id NUMBER;
num_parts NUMBER;
retVal NUMBER;
comments comment_list;
returnPartnumberlist partnumberlist;
iloopCounter PLS_INTEGER;
inx1 PLS_INTEGER;
part_t partnumberlist :=partnumberlist(100,200,300);
CURSOR part_list_init_cursor
IS
SELECT PR_PART_ROW_S_ID,PR_PGM_CHNG_S_ID FROM PGM_RPLCMNT_PART WHERE 1 = 2;
CURSOR inIt_cursor
IS
SELECT 0 FROM DUAL WHERE 1 = 2;
BEGIN
DBMS_OUTPUT.ENABLE (5000000);
global_pgm_s_id := pgm_s_id;
global_part_row_s_id := part_row_s_id;
SELECT PART_ROW_S_ID AS prior_part_row_id, PR_PGM_CHNG_S_ID AS prior_pgm_chng_s_id
INTO local_part_record
FROM PGM_RPLCMNT_PART
WHERE PGM_S_ID = global_pgm_s_id AND PART_ROW_S_ID = global_part_row_s_id AND
CUR_PGM_CHNG_S_ID IN (SELECT MAX(CUR_PGM_CHNG_S_ID) FROM PGM_RPLCMNT_PART WHERE
PGM_S_ID = global_pgm_s_id AND PART_ROW_S_ID = global_part_row_s_id
GROUP BY PART_ROW_S_ID);
OPEN part_list_init_cursor;
FETCH part_list_init_cursor
BULK COLLECT INTO found_parts_list;
-- Add the existing part to the found list
found_parts_list.EXTEND;
found_parts_list(1) := local_part_record;
driver_chng_s_id := local_part_record.prior_pgm_chng_s_id;
num_parts := 1;
is_more_parts := TRUE;
WHILE (is_more_parts) LOOP
retVal := getPriorPart(driver_chng_s_id,local_part_record);
IF (retVal != -1) THEN
found_parts_list.EXTEND;
num_parts := num_parts + 1;
found_parts_list(num_parts) := local_part_record;
driver_chng_s_id := local_part_record.prior_pgm_chng_s_id;
ELSE
is_more_parts := FALSE;
END IF;
END LOOP;
--num_parts := getComment(found_parts_list,comments);
OPEN init_cursor;
FETCH init_cursor
BULK COLLECT INTO returnPartnumberlist;
num_parts := found_parts_list.COUNT;
FOR iloopCounter IN 1 .. num_parts
LOOP
returnPartnumberlist.EXTEND;
returnPartnumberlist(iloopCounter) := found_parts_list(iloopCounter).prior_part_row_id;
END LOOP;
retPartnumberlist := returnPartnumberlist;
open
* partnumber_cursorlist for select PR_PART_ROW_S_ID from TABLE(CAST(retPartnumberlist AS historical_commentz.partnumberlist));*
DBMS_OUTPUT.put_line('Done....!');
EXCEPTION
some code..............................
END getComments;
END HISTORICAL_COMMENTZ;
/ -
"ORA-00902: invalid datatype" when trying to register local schema
I'm trying to register a local schema which uses/includes a global schema(s). I validated the schemas using XMLSpy.
Registering the global schema(s) was successful. Registering these global schemas was done under user "Generic". For local schemas, that use global schema, a new user is created, and the following script is executed.
SQL> --
SQL> -- Create user
SQL> --
SQL> create user &1 identified by &2
2 temporary TABLESPACE temp
3 default TABLESPACE users;
old 1: create user &1 identified by &2
new 1: create user Simple identified by Simple
User created.
Elapsed: 00:00:00.03
SQL> --
SQL> -- Grant privileges
SQL> --
SQL> grant create session to &1;
old 1: grant create session to &1
new 1: grant create session to Simple
Grant succeeded.
Elapsed: 00:00:00.01
SQL> grant resource to &1;
old 1: grant resource to &1
new 1: grant resource to Simple
Grant succeeded.
Elapsed: 00:00:00.01
SQL> -- Dunno if following is required for local schemas, but if I remove I can't FTP
SQL> grant dba, xdbadmin to &1;
old 1: grant dba, xdbadmin to &1
new 1: grant dba, xdbadmin to Simple
Grant succeeded.
Elapsed: 00:00:00.02
SQL>
SQL> --
SQL> -- Connect ;-)
SQL> --
SQL> connect &1/&2@SVF91;
Connected.
===========================================================
SQL> --
SQL> -- Register the schema in Oracle
SQL> --
SQL> BEGIN
2 DBMS_XMLSchema.registerSchema(
3 schemaURL => '&1',
4 schemaDoc => xdbURIType('&2').getClob(),
5 local => TRUE,
6 genTypes => TRUE,
7 genBean => FALSE,
8 genTables => TRUE);
9 END;
10 /
old 3: schemaURL => '&1',
new 3: schemaURL => 'http://http://ehvl091a:8080/home/Simple/xsd/SimplePOI.xsd',
old 4: schemaDoc => xdbURIType('&2').getClob(),
new 4: schemaDoc => xdbURIType('/home/Simple/xsd/SimplePOI.xsd').getClob(),
BEGIN
ERROR at line 1:
ORA-31084: error while creating table "SIMPLE"."SIMPLE_XPOI" for element
"XPOIS"
ORA-00902: invalid datatype
ORA-06512: at "XDB.DBMS_XMLSCHEMA_INT", line 20
ORA-06512: at "XDB.DBMS_XMLSCHEMA", line 31
ORA-06512: at line 2
The schema I use is:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:POI="POI" xmlns:xdb="http://xmlns.oracle.com/xdb" targetNamespace="POI" elementFormDefault="qualified" attributeFormDefault="unqualified" xdb:storeVarrayAsTable="true">
<xs:include schemaLocation="http://ehvl091a:8080/home/Generic/xsd/POI.xsd"/>
<xs:element name="XPOIS" xdb:defaultTable="SIMPLE_XPOI">
<xs:annotation>
<xs:documentation>A collection of XPOI</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="Simple" minOccurs="3" maxOccurs="unbounded" xdb:columnProps="NOT SUBSTITUTABLE">
<xs:complexType>
<xs:complexContent>
<xs:extension base="POI:POIType"/>
</xs:complexContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
I'm new at this XML (Oracle) stuff, so i could really use some pointers on how to tackle this. Thanks in advance.The following example works for me...
SQL> connect / as sysdba
Connected.
SQL> --
SQL> drop user global cascade
2 /
User dropped.
SQL> drop user local cascade
2 /
User dropped.
SQL> create user global identified by global
2 /
User created.
SQL> grant connect, resource, alter session, create view, xdbadmin to global
2 /
Grant succeeded.
SQL> create user local identified by local
2 /
User created.
SQL> grant connect, resource, alter session, create view to local
2 /
Grant succeeded.
SQL> connect global/global
Connected.
SQL> --
SQL> var schemaURL varchar2(256)
SQL> var schemaPath varchar2(256)
SQL> --
SQL> begin
2 :schemaURL := 'poTypes.xsd';
3 :schemaPath := '/public/poTypes.xsd';
4 end;
5 /
PL/SQL procedure successfully completed.
SQL> declare
2 res boolean;
3 xmlSchema xmlType := xmlType(
4 '<!-- edited with XML Spy v4.0 U (http://www.xmlspy.com) by Mark (Drake) -->
5 <xs:schema xmlns="http://xmlns.oralce.com/demo/xdb/purchaseOrderTypes" targetNamespace="http://xmlns.oralce.com/demo/xdb/purchaseOrderT
ypes" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xdb="http://xmlns.oracle.com/xdb" version="1.0" xdb:storeVarrayAsTable="true">
6 <xs:complexType name="LineItemsType" xdb:SQLType="LINEITEMS_T">
7 <xs:sequence>
8 <xs:element name="LineItem" type="LineItemType" maxOccurs="unbounded" xdb:SQLName="LINEITEM" xdb:SQLCollType="LINEIT
EM_V"/>
9 </xs:sequence>
10 </xs:complexType>
11 <xs:complexType name="LineItemType" xdb:SQLType="LINEITEM_T">
12 <xs:sequence>
13 <xs:element name="Description" type="DescriptionType" xdb:SQLName="DESCRIPTION"/>
14 <xs:element name="Part" type="PartType" xdb:SQLName="PART"/>
15 </xs:sequence>
16 <xs:attribute name="ItemNumber" type="xs:integer" xdb:SQLName="ITEMNUMBER" xdb:SQLType="NUMBER"/>
17 </xs:complexType>
18 <xs:complexType name="PartType" xdb:SQLType="PART_T">
19 <xs:attribute name="Id" xdb:SQLName="PART_NUMBER" xdb:SQLType="VARCHAR2">
20 <xs:simpleType>
21 <xs:restriction base="xs:string">
22 <xs:minLength value="10"/>
23 <xs:maxLength value="14"/>
24 </xs:restriction>
25 </xs:simpleType>
26 </xs:attribute>
27 <xs:attribute name="Quantity" type="moneyType" xdb:SQLName="QUANTITY"/>
28 <xs:attribute name="UnitPrice" type="quantityType" xdb:SQLName="UNITPRICE"/>
29 </xs:complexType>
30 <xs:simpleType name="ReferenceType">
31 <xs:restriction base="xs:string">
32 <xs:minLength value="18"/>
33 <xs:maxLength value="30"/>
34 </xs:restriction>
35 </xs:simpleType>
36 <xs:complexType name="ActionsType" xdb:SQLType="ACTIONS_T">
37 <xs:sequence>
38 <xs:element name="Action" maxOccurs="4" xdb:SQLName="ACTION" xdb:SQLCollType="ACTION_V">
39 <xs:complexType xdb:SQLType="ACTION_T">
40 <xs:sequence>
41 <xs:element name="User" type="UserType" xdb:SQLName="ACTIONED_BY"/>
42 <xs:element name="Date" type="DateType" minOccurs="0" xdb:SQLName="DATE_ACTIONED"/>
43 </xs:sequence>
44 </xs:complexType>
45 </xs:element>
46 </xs:sequence>
47 </xs:complexType>
48 <xs:complexType name="RejectionType" xdb:SQLType="REJECTION_T">
49 <xs:all>
50 <xs:element name="User" type="UserType" minOccurs="0" xdb:SQLName="REJECTED_BY"/>
51 <xs:element name="Date" type="DateType" minOccurs="0" xdb:SQLName="DATE_REJECTED"/>
52 <xs:element name="Comments" type="CommentsType" minOccurs="0" xdb:SQLName="REASON_REJECTED"/>
53 </xs:all>
54 </xs:complexType>
55 <xs:complexType name="ShippingInstructionsType" xdb:SQLType="SHIPPING_INSTRUCTIONS_T">
56 <xs:sequence>
57 <xs:element name="name" type="NameType" minOccurs="0" xdb:SQLName="SHIP_TO_NAME"/>
58 <xs:element name="address" type="AddressType" minOccurs="0" xdb:SQLName="SHIP_TO_ADDRESS"/>
59 <xs:element name="telephone" type="TelephoneType" minOccurs="0" xdb:SQLName="SHIP_TO_PHONE"/>
60 </xs:sequence>
61 </xs:complexType>
62 <xs:simpleType name="moneyType">
63 <xs:restriction base="xs:decimal">
64 <xs:fractionDigits value="2"/>
65 <xs:totalDigits value="12"/>
66 </xs:restriction>
67 </xs:simpleType>
68 <xs:simpleType name="quantityType">
69 <xs:restriction base="xs:decimal">
70 <xs:fractionDigits value="4"/>
71 <xs:totalDigits value="8"/>
72 </xs:restriction>
73 </xs:simpleType>
74 <xs:simpleType name="UserType">
75 <xs:restriction base="xs:string">
76 <xs:minLength value="1"/>
77 <xs:maxLength value="10"/>
78 </xs:restriction>
79 </xs:simpleType>
80 <xs:simpleType name="RequestorType">
81 <xs:restriction base="xs:string">
82 <xs:minLength value="0"/>
83 <xs:maxLength value="128"/>
84 </xs:restriction>
85 </xs:simpleType>
86 <xs:simpleType name="CostCenterType">
87 <xs:restriction base="xs:string">
88 <xs:minLength value="1"/>
89 <xs:maxLength value="4"/>
90 </xs:restriction>
91 </xs:simpleType>
92 <xs:simpleType name="VendorType">
93 <xs:restriction base="xs:string">
94 <xs:minLength value="0"/>
95 <xs:maxLength value="20"/>
96 </xs:restriction>
97 </xs:simpleType>
98 <xs:simpleType name="PurchaseOrderNumberType">
99 <xs:restriction base="xs:integer"/>
100 </xs:simpleType>
101 <xs:simpleType name="SpecialInstructionsType">
102 <xs:restriction base="xs:string">
103 <xs:minLength value="0"/>
104 <xs:maxLength value="2048"/>
105 </xs:restriction>
106 </xs:simpleType>
107 <xs:simpleType name="NameType">
108 <xs:restriction base="xs:string">
109 <xs:minLength value="1"/>
110 <xs:maxLength value="20"/>
111 </xs:restriction>
112 </xs:simpleType>
113 <xs:simpleType name="AddressType">
114 <xs:restriction base="xs:string">
115 <xs:minLength value="1"/>
116 <xs:maxLength value="256"/>
117 </xs:restriction>
118 </xs:simpleType>
119 <xs:simpleType name="TelephoneType">
120 <xs:restriction base="xs:string">
121 <xs:minLength value="1"/>
122 <xs:maxLength value="24"/>
123 </xs:restriction>
124 </xs:simpleType>
125 <xs:simpleType name="DateType">
126 <xs:restriction base="xs:date"/>
127 </xs:simpleType>
128 <xs:simpleType name="CommentsType">
129 <xs:restriction base="xs:string">
130 <xs:minLength value="1"/>
131 <xs:maxLength value="2048"/>
132 </xs:restriction>
133 </xs:simpleType>
134 <xs:simpleType name="DescriptionType">
135 <xs:restriction base="xs:string">
136 <xs:minLength value="1"/>
137 <xs:maxLength value="256"/>
138 </xs:restriction>
139 </xs:simpleType>
140 </xs:schema>');
141 begin
142 if (dbms_xdb.existsResource(:schemaPath)) then
143 dbms_xdb.deleteResource(:schemaPath);
144 end if;
145 res := dbms_xdb.createResource(:schemaPath,xmlSchema);
146 end;
147 /
PL/SQL procedure successfully completed.
SQL> begin
2 dbms_xmlschema.registerSchema
3 (
4 :schemaURL,
5 xdbURIType(:schemaPath).getClob(),
6 FALSE,TRUE,FALSE,FALSE
7 );
8 end;
9 /
PL/SQL procedure successfully completed.
SQL> connect local/local
Connected.
SQL> --
SQL> var schemaURL varchar2(256)
SQL> var schemaPath varchar2(256)
SQL> --
SQL> begin
2 :schemaURL := 'po.xsd';
3 :schemaPath := '/public/po.xsd';
4 end;
5 /
PL/SQL procedure successfully completed.
SQL> declare
2 res boolean;
3 xmlSchema xmlType := xmlType(
4 '<xs:schema xmlns="http://xmlns.oralce.com/demo/xdb/purchaseOrder" targetNamespace="http://xmlns.oralce.com/demo/xdb/purchaseOrder" xm
lns:types="http://xmlns.oralce.com/demo/xdb/purchaseOrderTypes" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xdb="http://xmlns.oracle.c
om/xdb" version="1.0" xdb:storeVarrayAsTable="true">
5 <xs:import namespace="http://xmlns.oralce.com/demo/xdb/purchaseOrderTypes" schemaLocation="poTypes.xsd"/>
6 <xs:element name="PurchaseOrder" type="PurchaseOrderType" xdb:defaultTable="PURCHASEORDER"/>
7 <xs:complexType name="PurchaseOrderType" xdb:SQLType="PURCHASEORDER_T">
8 <xs:sequence>
9 <xs:element name="Reference" type="types:ReferenceType" xdb:SQLName="REFERENCE"/>
10 <xs:element name="Actions" type="types:ActionsType" xdb:SQLName="ACTIONS"/>
11 <xs:element name="Reject" type="types:RejectionType" minOccurs="0" xdb:SQLName="REJECTION"/>
12 <xs:element name="Requestor" type="types:RequestorType" xdb:SQLName="REQUESTOR"/>
13 <xs:element name="User" type="types:UserType" xdb:SQLName="USERID"/>
14 <xs:element name="CostCenter" type="types:CostCenterType" xdb:SQLName="COST_CENTER"/>
15 <xs:element name="ShippingInstructions" type="types:ShippingInstructionsType" xdb:SQLName="SHIPPING_INSTRUCTIONS"/>
16 <xs:element name="SpecialInstructions" type="types:SpecialInstructionsType" xdb:SQLName="SPECIAL_INSTRUCTIONS"/>
17 <xs:element name="LineItems" type="types:LineItemsType" xdb:SQLName="LINEITEMS"/>
18 </xs:sequence>
19 </xs:complexType>
20 </xs:schema>');
21 begin
22 if (dbms_xdb.existsResource(:schemaPath)) then
23 dbms_xdb.deleteResource(:schemaPath);
24 end if;
25 res := dbms_xdb.createResource(:schemaPath,xmlSchema);
26 end;
27 /
PL/SQL procedure successfully completed.
SQL> begin
2 dbms_xmlschema.registerSchema
3 (
4 :schemaURL,
5 xdbURIType(:schemaPath).getClob(),
6 TRUE,TRUE,FALSE,TRUE
7 );
8 end;
9 /
PL/SQL procedure successfully completed.
SQL> desc PURCHASEORDER
Name Null? Type
TABLE of SYS.XMLTYPE(XMLSchema "po.xsd" Element "PurchaseOrder") STORAGE Object-relational TYPE "PURCHASEORDER_T"
SQL> desc PURCHASEORDER_T
PURCHASEORDER_T is NOT FINAL
Name Null? Type
SYS_XDBPD$ XDB.XDB$RAW_LIST_T
REFERENCE VARCHAR2(30 CHAR)
ACTIONS GLOBAL.ACTIONS_T
REJECTION GLOBAL.REJECTION_T
REQUESTOR VARCHAR2(128 CHAR)
USERID VARCHAR2(10 CHAR)
COST_CENTER VARCHAR2(4 CHAR)
SHIPPING_INSTRUCTIONS GLOBAL.SHIPPING_INSTRUCTIONS
_T
SPECIAL_INSTRUCTIONS VARCHAR2(2048 CHAR)
LINEITEMS GLOBAL.LINEITEMS_T
SQL>I'm not sure what you were trying here in your xml schema
xdb:columnProps="NOT SUBSTITUTABLE">
or whether or not this annotation is the source of the problem -
ORA-00902: invalid datatype
There is a table t_emp, having column clm1, clm2, clm3, clm4, etc.
Datatype of columns:-
clm1 -- Number
clm2 -- Number(12)
clm3 -- Char(4)
Now, I am trying to create a primary key using statement:
alter table t_emp
add constraint primary key (clm1, clm2, clm3)It gives oralce error ORA-00902: invalid datatype.
what is wrong at this place?
Any thought?
Regards,
RiteshYou need to give your primary key a name (which is good practice anyway):
SQL> r
1 create table t_emp (
2 clm1 Number,
3 clm2 Number(12),
4 clm3 Char(4)
5* )
Table created.
SQL> alter table t_emp
2 add constraint primary key (clm1, clm2, clm3)
3 /
add constraint primary key (clm1, clm2, clm3)
ERROR at line 2:
ORA-00902: invalid datatype
SQL> ed
Wrote file afiedt.buf
1 alter table t_emp
2* add constraint temp_pk primary key (clm1, clm2, clm3)
SQL> r
1 alter table t_emp
2* add constraint temp_pk primary key (clm1, clm2, clm3)
Table altered.
SQL>Cheers, APC
blog: http://radiofreetooting.blogspot.com -
Need help with "ORA-00902: invalid datatype" while creating a view
I am using Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production With the Partitioning, OLAP and Data Mining options.....
when I try ti create a view, I am getting ORA-00902 error.
SQL> create view sales_view as
2 select *
3 from table(OLAP_TABLE('global DURATION session',
4 'sales_type_table',
5 '',
6 'DIMENSION time_id FROM time
7 DIMENSION channel_id FROM channel
8 DIMENSION product_id FROM product
9 DIMENSION customer_id FROM customer
10 MEASURE sales FROM sales
11 MEASURE units FROM units
12 MEASURE extended_cost FROM extended_cost
13 MEASURE forecast_sales FROM fcast_sales
14 ROW2CELL olap_calc'));
create view sales_view as
ERROR at line 1:
ORA-00902: invalid datatype
ORA-06512: at "SYS.OLAPIMPL_T", line 23
ORA-06512: at "SYS.OLAPIMPL_T", line 17
ORA-06512: at line 4
I am new to Oracle.... using document "40261_leveragingtools.pdf" as a guide against a cube created using "Global_AWM10g_Handson.doc".
AWM displays data from cube without a problem.
I would welcome any assistance.Can you provide the definition of sales_type_table? Also, Are all of the dimensions you have created of type TEXT?
Swapan. -
Help ORA-00902: invalid datatype
I am getting the following error for a constraint I have created, cant see why it doesnt work?
(EXISTS(SELECT best_buy_gourmet_name
ERROR at line 5:
ORA-00902: invalid datatype
This constraint is just below my variable declerations in a create Endorses table:
CONSTRAINT
(EXISTS(SELECT best_buy_gourmet_name
FROM(SELECT * FROM Sells,Endorses WHERE Sells.shop_name = Endorses.shop_name)
GROUP BY best_buy_gourmet_name HAVING COUNT(*) > 0)),
Thanks for your timeYou cannot do this in a CHECK constraint. What you need to do is define a foreign key between ENDORSES and SELLS tables.
Cheers, APC -
OEHR Sample Objects Installation - ORA-00902: invalid datatype
When I was trying to install the supporting objects, I received a CREATE TYPE privilege error previously. Then the DBA updated APEX to 2.2.1 to fix the problem. It did but know I'm gettingn ORA-00901:invalid datatype and othere errors with creating the tables, views,etc. Can somebody help me. I'm running APEX with database version 9.2
Can somebody help me? I can not install the database objects. I get an invalid datatype error when the install script attempts to install the tables.
Please help! -
Invalid Number Error for Decimal Field While Loading Data
I am loading a delimited text file using the SQL* loader however I am reciving an error in my decimal fields. When a decimal field only has leading zeros before the decimal point I receive invalid number error. Below will clarify:
i.e.) 00000000.30 [*Invalid number*]
i.e.) 00046567.45 [*Valid number*]
i.e.) 00000001.00 [*Valid number*]
I've tried setting the precision/scale in the table, tried declaring it a decimal field instead of number, none of these methods fixed the issue. Any help I would really appreciate.
POLICY_NUMBER NUMBER,
EFFECTIVE_DATE DATE "YYYYMMDD" NULLIF EFFECTIVE_DATE = '',
TRANSACTION_DATE DATE "YYYYMMDD",
TRANSACTION_AMOUNT DECIMAL EXTERNAL, -- Tried TRANSACTION_AMOUNT DECIMAL EXTERNAL (10) & TRANSACTION_AMOUNT NUMBER
MF_TRX_CODE NUMBER,
USER_ID CHAR,
GROUP_NUMBER NUMBER,
EXPIRATION_DATE DATE "YYYYMMDD" NULLIF EXPIRATION_DATE = '',
BILL_NUMBER NUMBER,Any help is greatly appreciated. Thanks before hand.Hi,
Connected to Oracle Database 10g Express Edition Release 10.2.0.1.0
Connected as hr
SQL> SELECT * FROM TEST;
TRANSACTION_AMOUNT
SQL> SELECT * FROM TEST;
TRANSACTION_AMOUNT
11000,00
293,37
2000,00
1134,32
0,30
SQL>Between the selects I loaded the table with sql*loader using...
Load Data
INFILE *
APPEND
INTO TABLE TEST
FIELDS TERMINATED BY '|'
TRAILING NULLCOLS
TRANSACTION_AMOUNT DECIMAL EXTERNAL
BEGINDATA
00011000.00
00000293.37
00002000.00
00001134.32
00000000.30The log is
SQL*Loader: Release 10.2.0.1.0 - Production on Tue Dec 23 17:23:47 2008
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Control File: test.ctl
Data File: test.ctl
Bad File: test.bad
Discard File: none specified
(Allow all discards)
Number to load: ALL
Number to skip: 0
Errors allowed: 50
Bind array: 64 rows, maximum of 256000 bytes
Continuation: none specified
Path used: Conventional
Table TEST, loaded from every logical record.
Insert option in effect for this table: APPEND
TRAILING NULLCOLS option in effect
Column Name Position Len Term Encl Datatype
TRANSACTION_AMOUNT FIRST * | CHARACTER
Table TEST:
5 Rows successfully loaded.
0 Rows not loaded due to data errors.
0 Rows not loaded because all WHEN clauses were failed.
0 Rows not loaded because all fields were null.
Space allocated for bind array: 16512 bytes(64 rows)
Read buffer bytes: 1048576
Total logical records skipped: 0
Total logical records read: 5
Total logical records rejected: 0
Total logical records discarded: 0
Run began on Tue Dec 23 17:23:47 2008
Run ended on Tue Dec 23 17:23:50 2008
Elapsed time was: 00:00:02.86
CPU time was: 00:00:00.06Regards, -
Error in table(Cast)
Hi
I tried the following code
could you please resolve the error in this code
create or replace type numlist as table of number;
declare
var numlist;
begin
select 1 into var
from table(cast(var));
end;
/thanksME_XE?create or replace type numlist as table of number;
2 /
Type created.
Elapsed: 00:00:00.62
ME_XE?
ME_XE?declare
2 var numlist := numlist(1,2,3);
3 begin
4
5 for x in
6 (
7 select column_value
8 from table(cast(var as numlist))
9 )
10 loop
11 dbms_output.put_line('value = ' || x.column_value);
12 end loop;
13
14 end;
15 /
value = 1
value = 2
value = 3
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.46 -
Error when executing statement for table/stored proc. : ORA-00911
Hi All,
I am posting IDOC->XI->JDBC, approx 5000 Idocs.
But few messages are giving following error in XI-_SXMB_MONI
Can any one guide me what is the cause of error? I check whole Idoc data I am not able to see bad character? can any once guide me what are the bad character in XML to post data in oracle? so that i can search in XML and how to avoide this error.
"com.sap.aii.af.ra.ms.api.MessagingException: Error processing request in sax parser: Error when executing statement for table/stored proc. 'HRP1001' (structure 'INSERT_PAD34'): java.sql.SQLException: ORA-00911: invalid character"> I am talking about following IDOC.<ZRMD_A06> ->
> <E1PLOGI SEGMENT="1">-> <E1PITYP SEGMENT="1"> ->
> <E1PAD34 SEGMENT="1"> -><PROZT>0.00 #</PROZT>.
> Can we remove this # during message mapping in XI??
sure you can remove it using Replace function or by writing UDF.
as I am seing # is last character..<b>so remove # with " " (single space) and then use the TRIM fucntion.</b>
Thanks
Farooq.
*<b>Rewards points if you find it useful*</b> -
Invalid number error for bind dialog
Oracle SQL Developer version 1.1.2.25 BUILD MAIN-25.79
Running under WinXP
Issue description:
We get an invalid number error when bind variable filled with an enter in the bind dialogIt is hard to say what is causing your problem without the specifics (ie query and value entered for the bind variable). Try running the same statement with the value of the bind variable in place of the bind variable (ie instead of running "select * from dual where dummy = :var" with a value of 'x' for :var, run "select * from dual where dummy = 'x'"). If you get the same error, then it is not an issue with the use of bind variables.
Be aware that currently you cannot define the data type of bind variables (unlike TOAD, etc) and they are all treated as character values. I wouldn't have thought that this would cause you problem unless you are using a bind variable to restrict a numeric column to a specific value and you are entering a non-numeric bind (ie "select * from people where person_id = :id" and using 'xyz' as the value for :id). -
Java.sql.SQLException: FATAL ERROR for DB2
Hi
In my scenario IDOC-XI-DB2,
When I am getting following error message in communication channel. I have checked all the field length, they are correctly displayed. Please let me know how to resolve the same.
Message processing failed. Cause: com.sap.aii.af.ra.ms.api.RecoverableException: Error processing request in sax parser: Error when executing statement for table/stored proc. 'BI5FILMM.BSOMSAPP' (structure 'StatementInsert'): java.sql.SQLException: FATAL ERROR document format in structure 'StatementInsert': expected 'access' tag(s) not found
Payload is as follows
<?xml version="1.0" encoding="UTF-8" ?>
- <I805_Abstr_CustOutlet_MT>
- <StatementInsert>
- <STATUS action="INSERT">
<table>BI5FILMM.BSOMSAPP</table>
<key OUTLET_NO="0001231229" OUTLET_RF="0002122756" OMFUNC="CRT" />
- <access>
<STATUS>N</STATUS>
<IFCEDATE>1080701</IFCEDATE>
<IFCETIME>160849</IFCETIME>
<OUTLETTYPE>Y</OUTLETTYPE>
<NAME>DREW SMITH AGAINXXXXXXXXXXXXXXXXXXX</NAME>
<STREET>E</STREET>
<STATE>NSW</STATE>
<POST_CODE>2000</POST_CODE>
<PHONE_NO>567999</PHONE_NO>
<ALTPHONE>11111</ALTPHONE>
<FAX_NO>111</FAX_NO>
<CNTCT_PERS>Constant</CNTCT_PERS>
<ALTNAME>Constant</ALTNAME>
<EMAIL1>Drew_downunder</EMAIL1>
<EMAIL2>DREW_DOWNUNDER</EMAIL2>
<SFE_CODE>G</SFE_CODE>
<BILL_TO>0001231229</BILL_TO>
<SUPP_DATE>080801</SUPP_DATE>
</access>
</STATUS>
</StatementInsert>
- <StatementProce>
- <STATUS action="EXECUTE">
<table>CC5PTF.BSOMPSAP</table>
<Para1 isInput="true" type="CHAR">BI5FILMM</Para1>
<Para2 isInput="true" type="CHAR">BMIJOBD</Para2>
</STATUS>
</StatementProce>
</I805_Abstr_CustOutlet_MT>Hi Ria,
In your input try to make the access tag in capitals(ACCESS) and try. I am not sure though. I think its case sensitive. Just try and let me know. Also your second action="EXECUTE" does not has any access parameters. Refer to this blog:
JDBC Receiver Adapter -- Synchronous Select Step by Step
It might be useful.
Regards,
Sanjeev. -
"Invalid Number" error for no apparent reason
Hi.
We're transferring data from one table on one DB to a data warehouse on a separate DB. All Oracle 11g running on Windows Server 2003.
The columns all match data wise, and it's a simple select and insert.
However, we got an ORA-01722: invalid number error on one run. We checked all the data, which was fine (all 540,000 rows) and ran it again with no error this time.
I'd like to know if anyone knows why this would happen if there is no issue with the data validity. I'll take all guesses or known issues and check them against our systems. If anyone knows how I can get this to repeat I'd be grateful as it's all running fine now.
Cheers
SiThe data is transferred using a Java program. Select into an OracleResultSet() then read each row result into a prepared statement. Were using the batch send, I believe every 100 rows.
The source columns match the target columns for name and type, with two exceptions where the column name is slightly different but the column type still matches.
There are not triggers on either the source or target tables.
Cheers
Si -
Error creating table on MS SQL Server with OC4J standalone
Hi there,
I'm trying to deploy an EJB application to OC4J standalone using a MS SQL Server 2000 database, MS SQL Server JDBC Drivers and OC4J 9.0.3 standalone but i keep getting this error:
Auto-creating table: create table Functieprofiel_competentieNiveau_CompetentieNiveau_functieprofiel_LBOS_Ear_LBOS_Ejb (Functieprofiel_FUNCTIE_ID bigint identity not null, COMP_ID bigint identity null, NIVEAU_ID sql_variant(255) null)
Error creating table: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Could not create IDENTITY attribute on nullable column 'COMP_ID', table 'Functieprofiel_competentieNiveau_CompetentieNiveau_functieprofiel_LBOS_Ear_LBOS_Ejb'.
Deployment succeeds after this but the application does not run properly. Can anyone help me with this? I have no idea what to do.
Rob HeikoopRb -
if you want to stop the auto-creation of tables, try going to the j2ee/home/config directory of your OC4J installation. Open the application.xml file and modify the attribute autocreate-tables to be set to false.
That should stop the default table creation as a global property, unless you specifically override it at the specific deployed application level.
You can then manually create the tables on the sql-server database instance. If you keep the column names the same as the field names in the bean, then you shouldn't need to do any manual mapping. To be sure of the column names to use, take a look in the orion-ejb-jar.xml which gets generated in the j2ee/home/application-deployments/<app-name>/<ejb-module-name> to see what table/column names the generator defaulted to
-steve-
-steve-
Maybe you are looking for
-
How to chage the display name in SC browser for the custome fields?
Hi, I created 2 custom fields for Shopping cart in SRM. How to chage the display name in SC browser for this custome fields? Thanks Kevin
-
Financial Reporting - PDF Table of Contents not working
I am using FR to run scheduled batches each weekend. Some of the books are over 100 pages in length and we have a Table of Contents (TOC) with each book created. The page numbers within the TOC are correct and correspond to the correct report. Howeve
-
How o set envoirmental settings of OAS 10g (10.1.2.0.2)?
Hi, I am first time installing the OAS 10g (having OSS and OID) on OEL 5.5 x86 , and after that I will go to integrate it with EBS (12.0.6) with database 10g. I have 3 machines: 1: One for oracle Application server (EBS r12 (12.0.6)) ----> Red Hat Li
-
Shared members in duplicate member enabled EPMA outlines
Hi all, I have created an EPMA ASO "allow duplicate members application". I want to create an alternate shared hierarchy but all teh shared members are getting deployed in essbase as stored members. Do I need to enable any other property also so that
-
IMessage has become unreliable?
Has anyone else noticed that iMessage has become horribly unreliable in the past few weeks? I regularly use iMessage to chat with friends, and my account is activated on an iPhone 5S, iPad Mini and two Macs running Mavericks. Until a few weeks ago ev