I have a type MyType, which is defined as follows:
create or replace type MyType as varray(20000) of number(18);
And the MyTable table is defined as follows:
create table MyTable ( id number(18) primary key ,widgets MyType )
I am trying to select widgets for each row and its logically previous row in MyTable using the following SQL:
select t.id ,lag(t.widgets,1) over (order by t.id) as widgets_previous from MyTable t order by t.id;
and I get the answer:
ORA-00932: inconsistent datatypes: expected - got MYSCHEMA.MYTYPE
If I run the same query using a column like varchar or number instead of MyType, it works fine.
The column type in the current row and the previous row should be the same, so I can only assume that this is due to a user-defined type.
Do I need to do something to use a LAG with a user-defined type or does the LAG not support user-defined types? If the latter, are there any other utility functions that would provide the same functionality, or would I need to make a traditional independent union to achieve the same?
function sql oracle user-defined-types
Pancho
source share