Forum Stats

  • 3,769,349 Users
  • 2,252,952 Discussions
  • 7,874,993 Comments

Discussions

Error: ERR-1002 Unable to find item ID for item "ROWID"

John like many others
John like many others Member Posts: 107 Red Ribbon
edited Aug 11, 2020 5:42AM in APEX Discussions

Hello

I have an Interactive GRID and would like to insert/update by PL/SQL on Processing (Interactive Grid - Automatic Row Processing (DML)). Therefore I have taken the code template in the Help area and adjusted for my table:

begin

    case :APEX$ROW_STATUS

    when 'C' then

        insert into T_IB_SD_AIC_AUM_EXCLUSIONS_T ( cont_type_gk, validfrom, validto, bu_gk_list )

        values ( :CONT_TYPE_GK, :VALIDFROM, :VALIDTO, :BU_GK_LIST )

        returning rowid into :ROWID;

    when 'U' then

        update T_IB_SD_AIC_AUM_EXCLUSIONS_T

           set cont_type_gk = :CONT_TYPE_GK,

               validfrom = :VALIDFROM,

               validto = :VALIDTO,

               bu_gk_list = REPLACE(:BU_GK_LIST, ':', ',')

         where rowid = :ROWID;

    when 'D' then

        delete T_IB_SD_AIC_AUM_EXCLUSIONS_T

         where rowid = :ROWID;

    end case;

end;

-> The column ROWID is present and defined as PK

- Update will be ignored, no error message but the original record appears after refreshing the region

- Insert statement returns an error message: Error: ERR-1002 Unable to find item ID for item "ROWID"

I'm a bit confused it says "item" because it's a column. I'm aware Apex is pretty stupid about hidden fields and made the ROWID column visible in the interactive Grid but still the same error message.

Anyone has an idea what the problem is and how to fix it?

-> Oracle Apex 19.2

John like many others

Best Answer

  • John like many others
    John like many others Member Posts: 107 Red Ribbon
    edited Aug 11, 2020 5:23AM Accepted Answer

    Found it...

    I had to read the ROWID with an alias like PK_ROWID and use this a identifier inside APEX, then it works!

    Maybe this problem won't occur if the source is a table/view. In my case it's an SQL statement.So instead of:
    SELECT ROWID, <any other columns>...

    I did:

    SELECT ROWID AS PK_ROWID, <any other columns>...

    Not sure it this is a bug APEX wise but this is a working solution (works also with update and delete).

    John like many others

Answers

  • Keyser
    Keyser Member Posts: 829 Bronze Trophy
    edited Aug 11, 2020 2:05AM

    I've tried to reproduce the issue using the EMP table on 20.1 but can't, it works fine

    can you put this into your "JavaScript Initialization Code" for the ROWID item, run the page and copy/paste the output from your browser dev tool console

    function( options ) {    console.log(options);    return options;}
  • Vikas Kumar Pandey
    Vikas Kumar Pandey Member Posts: 13 Red Ribbon
    edited Aug 11, 2020 2:27AM

    Hi there,

    Your code is ok and use ROWID in select query.

  • John like many others
    John like many others Member Posts: 107 Red Ribbon
    edited Aug 11, 2020 3:27AM

    Thank you guys for help, really appreciated!

    Added your code in ROWID on Javascript initialization, output:

    1. Object
      1. dataType: "ROWID"
      2. id: "147320781881306831"
      3. isHidden: true
      4. isPrimaryKey: true
      5. isReadOnly: false
      6. name: "ROWID"
      7. staticId: "C147320781881306831"
      8. __proto__: Object

    As every row in an interactive GRID has it's own ROWID I assume APEX is aware of that.

  • Keyser
    Keyser Member Posts: 829 Bronze Trophy
    edited Aug 11, 2020 3:57AM

    this is mine from 20.1

    1. Object
      1. dataType: "ROWID"
      2. id: "33623506008920468369"
      3. isHidden: true
      4. isPrimaryKey: true
      5. name: "ROWID"
      6. staticId: "C33623506008920468369"
      7. __proto__: Object

    isReadOnly is the only difference, you could try setting that back but i don't see why it would break it

    personally I'm not a fan of using ROWID, under certain conditions it can change and that would cause you all sorts of problems...

    https://docs.oracle.com/en/database/oracle/oracle-database/12.2/sqlrf/ROWID-Pseudocolumn.html#GUID-F6E0FBD2-983C-495D-98…

    is there a reason you aren't using a normal Primary Key for your DML?

    John like many others
  • John like many others
    John like many others Member Posts: 107 Red Ribbon
    edited Aug 11, 2020 4:35AM

    I initially had it to "value protected" (read only) also to try out if this is the problem....

    Now you may laugh: The table HAS a primary and I initially used it but after loading the mask all records in the displayed GRID were blue (selected) and whenever I changed a value in a record and clicked into the same column in another row it took over the values from the previous set record.I don't have this effect using ROWID but nevertheless I can try to set the original PK and see how the save process will handle that. Yes, agree, the official PK of the table should be used...

  • John like many others
    John like many others Member Posts: 107 Red Ribbon
    edited Aug 11, 2020 4:42AM

    And all this because it's not possible to set an own separator for multiple chosen values (Poup LOV, Checkbox) in the DB (colon is used). So I have to do a replace ", " -> ":" on reading and on storing back from ":" to "," (it's any existing table I can't change it's content because there are load processes expecting a comma separator). The mask is VERY simple but now spending hours for such things... Nevertheless I'm happy for your hints, thank you!

  • John like many others
    John like many others Member Posts: 107 Red Ribbon
    edited Aug 11, 2020 4:49AM

    Switching back to original PK but of course further problems with Apex: They PK (2 columns) are enterable attributes and Apex has difficulties when set/overwritten by user and PK is visible as such. No more words for that...

  • John like many others
    John like many others Member Posts: 107 Red Ribbon
    edited Aug 11, 2020 5:23AM Accepted Answer

    Found it...

    I had to read the ROWID with an alias like PK_ROWID and use this a identifier inside APEX, then it works!

    Maybe this problem won't occur if the source is a table/view. In my case it's an SQL statement.So instead of:
    SELECT ROWID, <any other columns>...

    I did:

    SELECT ROWID AS PK_ROWID, <any other columns>...

    Not sure it this is a bug APEX wise but this is a working solution (works also with update and delete).

    John like many others