简体   繁体   中英

Oracle SQL: create a dumy table from a substitution variable

In Oracle SQL, I can create a dummy table thanks to the code shown below:

select crca.*
from my_real_table real_table, 
     table(ntde.ENCRYPT_ALL(:inputParam)) enc
where
    ...

I would like to be able to do same thing without using ntde.ENCRYPT_ALL , I would like to do something like that:

select crca.*
from my_real_table real_table, 
     table(:inputParam) enc
where
    ...

It does not work and I get this error:

  1. 00000 - "cannot access rows from a non-nested table item"
    *Cause: attempt to access rows of an item whose type is not known at
    parse time or that is not of a nested table type
    *Action: use CAST to cast the item to a nested table type

Do you know how to do that please?

As the exception says, use CAST :

SELECT c.*
FROM   my_real_table r 
       CROSS JOIN TABLE( CAST(:inputParam AS your_collection_type) ) c

This assumes that:

  • the bind variable contains an collection (and not a string); and

  • the bind variable is being passed from an application (this is a Java example ); and

  • you have created an SQL collection type to cast the bind variable to. For example:

     CREATE TYPE your_collection_type AS TABLE OF NUMBER;

    Or, instead of creating your own collection type, you could use a built in collection (or VARRAY ) such as SYS.ODCIVARCHAR2LIST .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM