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.
Similar Messages
-
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 youYou 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 -
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
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. -
"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 -
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! -
PL/SQL: ORA-00932: inconsistent datatypes: expected REF got CHAR
SQL> desc o.rel_module;
Name Null? Type
ID NOT NULL NUMBER(6)
TYPE NOT NULL CHAR(7)
BUILDDATE NOT NULL NUMBER(4)
DESIGNROOT NOT NULL NUMBER(6)
SQL> desc rel_module
Name Null? Type
ID NOT NULL NUMBER(6)
DESIGNROOT NOT NULL NUMBER(6)
REL_COMPOSITEPARTS REL_COMPOSITEPART_TAB
SQL> desc REL_COMPOSITEPART_TAB
REL_COMPOSITEPART_TAB TABLE OF REL_COMPOSITEPART
SQL> desc REL_COMPOSITEPART
Name Null? Type
TYPE CHAR(7)
BUILDDATE NUMBER(4)
SQL> create or replace procedure rel_module_p
2 as
3 cursor c is select ID, TYPE, BUILDDATE, DESIGNROOT from o.rel_module;
4 begin
5 FOR i in c
6 LOOP
7 INSERT into rel_module(id,REL_CompositeParts,DESIGNROOT)
Values (i.ID,REL_CompositePart_TAB(i.type,i.builddate), i.designroot);
8 END LOOP;
9 END;
10 /
Warning: Procedure created with compilation errors.
SQL> show err
Errors for PROCEDURE REL_MODULE_P:
LINE/COL ERROR
7/1 PL/SQL: SQL Statement ignored
7/93 PL/SQL: ORA-00932: inconsistent datatypes: expected REF got CHAR
Can you please tell me where needs correction.801556 wrote:
Can you please tell me where needs correction.Just a fix would be:
create or replace procedure rel_module_p
as
cursor c is select ID, TYPE, BUILDDATE, DESIGNROOT from o.rel_module;
begin
FOR i in c
LOOP
INSERT into rel_module(id,REL_CompositeParts,DESIGNROOT)
values (i.ID,REL_CompositePart_TAB(REL_COMPOSITEPART(i.type,i.builddate)), i.designroot);
END LOOP;
END;
/However, I'd assume what you want is:
create or replace procedure rel_module_p
as
cursor c is select ID,CAST(COLLECT(REL_COMPOSITEPART(TYPE,BUILDDATE)) AS REL_CompositePart_TAB) REL_COMPOSITEPARTS, DESIGNROOT
from rel_module
group by id,DESIGNROOT;
begin
FOR i in c
LOOP
INSERT into rel_moduleX(id,REL_CompositeParts,DESIGNROOT)
values (i.ID,i.REL_COMPOSITEPARTS, i.designroot);
END LOOP;
END;
/SY. -
PL/SQL: ORA-00932: inconsistent datatypes: expected UDT got NUMBER
Hi all,
Wondering if you could assist? I'm exploring User Types and having a small problem. I'm getting the above error for a user type I have created which I'm calling in a function. Here's what my code looks like which I'm running the 'scott' schema for testing purposes
SQL> CREATE OR REPLACE TYPE NBR_COLL AS TABLE OF NUMBER;
2 /
Type created.
SQL> create or replace FUNCTION first_rec_only
2 (
3 NUM_ID IN NUMBER
4 ) RETURN NUMBER IS
5 v_num NBR_COLL;
6 BEGIN
7 select deptno into v_num from dept;
8 RETURN v_num(v_num.FIRST);
9 END first_rec_only;
10 /
Warning: Function created with compilation errors.
SQL> show errors
Errors for FUNCTION FIRST_REC_ONLY:
LINE/COL ERROR
7/4 PL/SQL: SQL Statement ignored
7/11 PL/SQL: ORA-00932: inconsistent datatypes: expected UDT got
NUMBER
SQL>
Any clues to what I'm doing wrong? Cheers.The deptno column is a number, you cannot directly select a number into your type, you need to use your type's constructor.
Something like:
CREATE OR REPLACE FUNCTION first_rec_only (NUM_ID IN NUMBER) RETURN NUMBER IS
v_num NBR_COLL;
BEGIN
SELECT nbr_coll(deptno) INTO v_num from dept;
RETURN v_num(v_num.FIRST);
END first_rec_only;Note that although this will compile, it will throw ORA-01422: exact fetch returns more than requested number of rows when you run it. you need to either use the input parameter as a predicate on your query against dept, use rownum = 1 in the query or use bulk BULK COLLECT INTO, depending on what exactly you want to accomplish.
John -
Error: PL/SQL ORA-00932 inconsistent datatype when using LONG value
Good morning:
I am using a work PL/SQL script where I am using a LONG value in a cursor. When I execute it, I am receiving:
PL/SQL ORA-00932 inconsistent datatype: expected NUMBER got LONG
set serveroutput ON SIZE 1000000
set heading off
set feedback off
set trimspool off
set echo off
set term off
set pagesize 0
SPOOL &so_outfile;
DECLARE
v_data_file varchar2(30);
-- v_sch_code varchar2(10);
-- v_instance_name varchar2(10);
ws_path payroll.pybutfl.pybutfl_utl_file_path%TYPE;
v_data_line VARCHAR2 (2000) := NULL;
fhandle_o UTL_FILE.file_type;
v_line_count NUMBER := 0;
v_selected_count NUMBER := 0;
v_error_count NUMBER := 0;
v_written_count NUMBER := 0;
v_error_text VARCHAR2 (50) := ' AMACONF_ERR: Unable to write the line. ';
v_errm VARCHAR2 (255);
v_sqlerrm VARCHAR2 (255);
v_payment_type VARCHAR2(10);
CURSOR C1 IS
select RTRIM
AMRCONF_PIDM_ERR ||'|'||
AMRCONF_IDEN_CODE_ERR ||'|'||
AMRCONF_ENTRY_DATE_ERR ||'|'||
AMRCONF_CONFID_IND_ERR ||'|'||
*AMRCONF_COMMENT_ERR ||'|'||*
AMRSUBJ_SUBJ_CODE_ERR ||'|'||
ERROR_CODE ||'|'||
ERROR_CODE_TEXT ) data_line
from WSUALUMNI.AMRCONF_ERR;
BEGIN
DBMS_OUTPUT.put_line ('Program Generating AMACOMT Mass Update Error File ');
IF UTL_FILE.is_open (fhandle_o)
THEN
UTL_FILE.fclose (fhandle_o);
END IF;
/* Name The File Here */
v_data_file := ('Amaconf_error.txt');
SELECT RTRIM (pybutfl_utl_file_path)
INTO ws_path
FROM payroll.pybutfl;
fhandle_o := UTL_FILE.fopen (ws_path, v_data_file, 'w');
DBMS_OUTPUT.put_line ('UTLFILE file for this run is: ' || ws_path||'/'||v_data_file);
v_written_count := 0;
FOR c1_rec IN C1 LOOP
BEGIN
v_selected_count := v_selected_count + 1;
v_data_line := rtrim(c1_rec.data_line);
UTL_FILE.put_line (fhandle_o, v_data_line);
v_written_count := v_written_count + 1;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line (v_error_text);
v_error_count := v_error_count + 1;
END;
END LOOP;
DBMS_OUTPUT.put_line ('Number of Records Selected: ' || v_selected_count);
DBMS_OUTPUT.put_line ('Number of Records Written: ' || v_written_count);
IF UTL_FILE.is_open (fhandle_o)
THEN
UTL_FILE.fclose (fhandle_o);
END IF;
END;
SPOOL OFF;If I comment out the "AMRCONF_COMMENT_ERR ||'|'||" line, then the script works fine. The table was created as:
Create Table WSUALUMNI.AMRCONF_ERR
AMRCONF_PIDM_ERR NUMBER (8) NOT NULL,
AMRCONF_IDEN_CODE_ERR VARCHAR2(5) NOT NULL,
AMRCONF_ENTRY_DATE_ERR DATE NOT NULL,
AMRCONF_CONFID_IND_ERR VARCHAR2(1),
AMRCONF_COMMENT_ERR LONG,
AMRSUBJ_SUBJ_CODE_ERR VARCHAR2(5) NOT NULL,
ERROR_CODE VARCHAR2(12) NOT NULL,
ERROR_CODE_TEXT VARCHAR2(50) NOT NULL
); I don't get what is the problem here in the script.Hi,
Feew suggestions
1) LONG is a deprecated type hence if possible start working on changing that column
2) CLOB will your preferred datatype over LONG.
3) you cannot use RTRIM on long.
here is a very quick example
drop table h
create table h (x long,y varchar2(100))
select rtrim(x) from h
select rtrim(y) from hSolution:
[http://www.oracle.com/technology/oramag/code/tips2003/052503.html]
need a better solution change the datatype to clob and
drop table h
create table h (x clob,y varchar2(100))
select dbms_lob.substr( x, 4000, 1 ) from h
select rtrim(y) from hCheers!!!
Bhushan -
I have a PL/SQL script processing information between Oracle database and MySQL database. My script ran perfectly with DG4ODBC 11.1.0.7. Then we upgraded Oracle to 10.2.0 and DG4ODBC 11.2.0.2. Now if I run my script from Solaris command line like ./myscript.shl, I get the following errors:
PL/SQL: ORA-00904: "cmswhit_moodle1"."mdl_grade_grades"."finalgrade": invalid identifier
PL/SQL: ORA-00904: "cmswhit_moodle1"."mdl_question_states"."attempt": invalid identifier
The strange thing is if I run the same query by cut and paste into sqlplus from command line, the query works perfectly without any problems.
What is the cause of this problem?
Any help would be greatly appreciated.
JeffreyHi Klaus,
The problem was solved after I updated MySQL ODBC to a new version from 5.1.8 to 5.1.13.
Summary of the problem and its solution:
The Problem: It appears that dg4odbc 11.2.0.2 requires a newer version of MyODBC. Previously I used MyODBC 5.1.8 which ran into problems with dg4odbc 11.20.0.2.
The Solution: After I updated MyODBC to 5.1.13, my PL/SQL scripts all work.
I need to point out that with MyODBC 5.1.8, I can run queries and updates from SQL*Plus console, but now PL/SQL scripts.
I'll close this thread.
Once again, thank you and happy holidays.
Jeffrey -
What this problem? table(cast(array))
exits in databse one type
" type InNumberTab is table of number;"
declare
v_tbseq_trans:= InNumberTab(null);
select count(*) into v_cont
from dados_propriedade dp
where dp.num_pessoa=p_num_pessoa
group by num_nirf;
v_tbseq_trans.EXTEND(SQL%ROWCOUNT);
v_cont:=0;
for v_cs in
(select to_number(replace(dp.num_nirf,'-','')) nirf, max(dp.seq_transacao) seq_transacao
from dados_propriedade dp
where dp.num_pessoa=p_num_pessoa
group by dp.num_nirf) loop
v_tbseq_trans(v_cont):=v_cs.seq_transacao;
v_cont:=v_cont+1;
END LOOP;
open p_cursor_prop for
select
from dados_propriedade dp
where dp.seq_transacao in (SELECT column_value FROM TABLE(CAST(v_tbseq_trans as InNumberTab)));I'll try to guess what you mean.
If you need to use object or collection type in SQL query you should declare in in SQL server not in PL/SQL code:
SQL> declare
2 type na is table of number;
3 nat na := na(1,2,3);
4 begin
5 for x in (select column_value y from table(cast(nat as na))) loop
6 dbms_output.put_line(x.y);
7 end loop;
8 end;
9 /
for x in (select column_value y from table(cast(nat as na))) loop
ERROR at line 5:
ORA-06550: line 5, column 56:
PL/SQL: ORA-00902: invalid datatype
ORA-06550: line 5, column 11:
PL/SQL: SQL Statement ignored
ORA-06550: line 6, column 25:
PLS-00364: loop index variable 'X' use is invalid
ORA-06550: line 6, column 4:
PL/SQL: Statement ignored
SQL> set serveroutput on
SQL> create type na is table of number;
2 /
Type created.
SQL> declare
2 nat na := na(1,2,3);
3 begin
4 for x in (select column_value y from table(cast(nat as na))) loop
5 dbms_output.put_line(x.y);
6 end loop;
7 end;
8 /
1
2
3
PL/SQL procedure successfully completed.Is it your problem ?
Rgds. -
Table(cast - invalid datatype problem
Hi All,
Basic scenario:
PACKAGE
create or replace
PACKAGE C2_PAYMENT_DOC IS
TYPE bin_array IS TABLE OF NUMBER
INDEX BY BINARY_INTEGER;
FUNCTION test_fun(l_doc_id IN integer) RETURN bin_array;
PACKAGE_BODY
create or replace
package body C2_PAYMENT_DOC as
FUNCTION test_fun (l_doc_id IN integer) RETURN bin_array IS
l_gross bin_array;
begin
c2_purchase_invoice.get_inv_gross_amount(l_doc_id, l_gross(1));
return l_gross;
end;
END;
QUERY
select * from Table(Cast(c2_payment_doc.test_fun(1) As bin_array));
Result of the query is ORA-00902: invalid datatype
How can I make the select statement valid?
Thanks in advance,
BartekYou can not use local collection types in SQL. You must create type bin_array as SQL nested table type. Also, depending on version you might not need to cast:
SQL> CREATE OR REPLACE
2 TYPE bin_array
3 AS TABLE OF NUMBER
4 /
Type created.
SQL> create or replace
2 PACKAGE C2_PAYMENT_DOC IS
3 FUNCTION test_fun(l_doc_id IN integer) RETURN bin_array;
4 end;
5 /
Package created.
SQL> create or replace
2 package body C2_PAYMENT_DOC as
3
4 FUNCTION test_fun (l_doc_id IN integer) RETURN bin_array IS
5 l_gross bin_array := bin_array();
6 begin
7 l_gross.extend;
8 l_gross(1) := l_doc_id;
9 return l_gross;
10 end;
11 END;
12 /
Package body created.
SQL> select * from Table(Cast(c2_payment_doc.test_fun(1) As bin_array));
COLUMN_VALUE
1
SQL> select * from Table(c2_payment_doc.test_fun(1))
2 /
COLUMN_VALUE
1
SQL> SY. -
ORA-00902 on trying to Select a Nested Table
I have created a Table having Nested Table as below:
create type INT_ARRAY as table of INTEGER;
create table test1 (
id number not null,
name varchar2(500),
prot_NT int_array,
constraint test1_pk primary key(id))
STORAGE (INITIAL 512K
NEXT 512K
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0)
nested table prot_NT store as prot_NT_TAB ;
And I am doing following select using an executeQuery on a PreparedStatement (I am not using any oracle extensions. I am using JDK1.2.2 on Solaris with Weblogic 5.1 appServer. jdbc driver is oracle.jdbc.driver.OracleDriver version 8.1.6.0.0):
Select id, name, prot_nt from test1
Some times this executeQuery works fine. But some times I get SQLException with "ORA-00902: invalid datatype". Same tables and same query behaves differently at different times.
Is there any problem with this usage?? Is there any known problem? I am trying to get Nested Table to a int[]. What is recommended procedure for doing this? Please help me out! Thanks in advance!By this point you've probably either solved the problem, or just dropped the database, but for anyone else interested, here's something you can do.
You can drop the queue table by setting event 10851 with the following steps:
1. Log into SQL*Plus or Server Manager as a user with DBA privileges.
2. Issue command: alter session set events '10851 trace name context forever, level 2'; Statement Processed.
3. Drop table <queue_table>; Statement Processed.
Solution Explanation: =====================
Event 10851 disables error 24005 when attempting to manually drop a queue table. It should be noted that this is the "Hard Way" of dropping queue tables, and should only be practiced after all formal procedures, i.e., using the "DBMS_AQADM.DROP_QUEUE_TABLE" procedure, has failed to drop the table.
Cheers,
Doug
Maybe you are looking for
-
'how to code for table control wizard in module pool program
Hi Gurus, Please provide me a sample code of table control wizard... Thanks in advance!!!! Regards, Kranthi
-
Hi All, We have installed content server ver 630 on IBM-AIX ver 5.3 machines along with Apache web server ver Apache_1.3.41. while starting the server following is the error, $ apachectl start Syntax error on line 205 of /apache/kprcs/conf/httpd.conf
-
I want to create either a video or a photo slide show of some newspaper headlines to load on my website. Could someone explain how to do this? Is there a way that I could get these articles off of newspaper archive to iMove or iPhoto?
-
How to Change "Send to YouTube" Account
I was going to test uploading a video to YouTube using the "Send to YouTube" option and I signed into the wrong account. I can't seem to find any way of changing the account. I tried signing in and out of the stand alone YouTube app, but it didn't an
-
Will my iPad work on Wi-Fi overseas? (Going from UK to USA )
I'm going to USA and want to knowing my iPad will work as normal on my friends wifi?