简体   繁体   中英

Insert Array into Table Oracle Apex

I got an table which looks like this:

CREATE TABLE "USER"
  (     "NUMBER" VARCHAR2(8) NOT NULL ENABLE,
        "ROLE" VARCHAR2(100) NOT NULL ENABLE,
        "QUESTION_ORDER" "T_NUMARRAY",
        "FORENAME" VARCHAR2(20),
        "SURNAME" VARCHAR2(20),
        CONSTRAINT "USER_PK" PRIMARY KEY ("NUMBER")
  USING INDEX ENABLE
  )
VARRAY "QUESTION_ORDER" STORE AS SECUREFILE LOB
/

I'm trying to Update the column Order with an Array which is filled with numbers. My Code which generates the Array:

DECLARE
     TYPE T_NUMARRAY IS TABLE OF number INDEX BY BINARY_INTEGER;
     numArray T_NUMARRAY;
BEGIN
     SELECT PAGE_ID BULK COLLECT INTO numArray FROM APEX_APPLICATION_PAGES WHERE APPLICATION_ID = 943 AND PAGE_NAME LIKE '%Questions_%' ORDER BY PAGE_ID ASC;
     FOR i IN 1 .. numArray.Count Loop
        UPDATE USER SET Question_Order = numArray WHERE QNUMMER = :APP_USER;
     END LOOP;
END

When I try to Update the entrys in the table then I get the error: ORA-06550: line 9, colum 48: PLS-00382: expression is of wrong type I don't know how to INSERT the array correctly. Maybe someone can help me? :)

If you really have a table with a column of type T_NUMARRAY , then T_NUMARRAY has to be defined at the schema level using the CREATE TYPE statement. If that is true, then you must not define T_NUMARRAY locally. Remove the line right after DECLARE where you define a local collection with the same name.

I would feel much better about this answer if you provided more information in your question. Please add the DDL that creates the table for starters.

Do you really, really need to store the data as an array? I would avoid that if possible and instead store the data in the "normal" way.

I added the DDL in first Post.

Yeah I really need an Array, because I wanna save multiple numbers in one Column and use them later on a diffrent Page. Where I can SELECT the Array into an Classic Report. The User should be able to able to select his order of the Question if he wanna start with question 1 or maybe 5. I got another page where I gonna SELECT that column and then I need every number of the Array.

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