In Oracle, I would sometimes like to create constructs such as these ones
SELECT * FROM TABLE(STRINGS('a', 'b', 'c'))
SELECT * FROM TABLE(NUMBERS(1, 2, 3))
Obviously, I can declare my own types for the above. I can choose between TABLE
and VARRAY
. For example:
CREATE TYPE STRINGS AS TABLE OF VARCHAR2(100);
CREATE TYPE NUMBERS AS VARRAY(100) OF NUMBER(10);
In this particular case, another solution is to write things like
SELECT 'a' FROM DUAL UNION ALL
SELECT 'b' FROM DUAL UNION ALL
SELECT 'c' FROM DUAL
But I may have more complex examples where I will really need a TABLE
/ VARRAY
type. So what if my SQL is running on an unknown system where I cannot create types because I may not have the necessary grants?
So my question is: Does Oracle know "anonymous" TABLE
/ VARRAY
types that are available on any Oracle instance? Similar to Postgres / H2 / HSQLDB's simple ARRAY
types?
UPDATE: I am mostly running this SQL from Java, if this is relevant. No need to explain PL/SQL to me, I'm really just looking for anonymous SQL array types (i.e. "anonymous" standalone stored types). If they don't exist at all, the answer is NO
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…