简体   繁体   中英

PL SQL - How to iterate for each column in a select statement?

I have declared a table array type would like to add a bunch of values to the array so that I can later perform a select distinct from the array.

My values to be added to the array are strings like this:

"1","2","3", ..... 

I want to add each string to the array maybe something like:

FOR i IN SELECT "1","2","3" LOOP
    myarray(i) := ????

then later I want to select distinct values from the array. Is there an easy way to do this?

If I was doing this in SQL server, I would simply create a temp table, insert my values into the table, then select distinct from that table, but I am not sure if this is the best way with oracle?

这项工作将从表中选择与众不同的t.column_value(sys.odcivarchar2list('1','2','3','4','5','1'))t;

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