admin管理员组

文章数量:1122832

I have a form on a page where I want to populate item values by uploading a CSV file containing item names and their corresponding values. I am creating a collection based on the CSV content. How can I set the form item names with the corresponding values from the Collection?

I am trying to call the process on pre rendering after header.

    DECLARE
    l_field_name  VARCHAR2(32767);
    l_field_value VARCHAR2(32767);
BEGIN
    FOR rec IN (SELECT * FROM APEX_COLLECTIONS WHERE collection_name = 'POPULATE') LOOP
        l_field_name := rec.c001;  
        l_field_value := rec.c002; 
        EXECUTE IMMEDIATE 'BEGIN :1 := :2; END;'
        USING OUT l_field_name, l_field_value;
    END LOOP;
END;

but there value is not updating.

I have a form on a page where I want to populate item values by uploading a CSV file containing item names and their corresponding values. I am creating a collection based on the CSV content. How can I set the form item names with the corresponding values from the Collection?

I am trying to call the process on pre rendering after header.

    DECLARE
    l_field_name  VARCHAR2(32767);
    l_field_value VARCHAR2(32767);
BEGIN
    FOR rec IN (SELECT * FROM APEX_COLLECTIONS WHERE collection_name = 'POPULATE') LOOP
        l_field_name := rec.c001;  
        l_field_value := rec.c002; 
        EXECUTE IMMEDIATE 'BEGIN :1 := :2; END;'
        USING OUT l_field_name, l_field_value;
    END LOOP;
END;

but there value is not updating.

Share Improve this question edited Nov 22, 2024 at 13:42 Abneesh Kumar asked Nov 22, 2024 at 12:34 Abneesh KumarAbneesh Kumar 32 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Page items are available as pl/sql variables in the apex context. You can reference them using bind variable syntax and assign a value using the assignment operator :=

:P1_MYPAGEITEM := 'Foobar';

Alternatively, use APEX_UTIL.SET_SESSION_STATE.

For your case, it sounds like you need the 2nd option:

DECLARE
    l_field_name  VARCHAR2(32767);
    l_field_value VARCHAR2(32767);
BEGIN
    FOR rec IN (SELECT * FROM APEX_COLLECTIONS WHERE collection_name = 'POPULATE') LOOP
        l_field_name := rec.c001;  
        l_field_value := rec.c002; 
        APEX_UTIL.SET_SESSION_STATE(p_name => l_field_name,p_value => l_field_value);
    END LOOP;
END;

本文标签: Populating Form Items with Values from an Uploaded CSV File in Oracle APEXStack Overflow