Dani3lSun / apex-plugin-dropzone

Oracle APEX Region Plugin - Dropzone
MIT License
72 stars 19 forks source link

How to insert others fields in my custom table #43

Closed dpccrt87 closed 6 years ago

dpccrt87 commented 6 years ago

Hi Mr Dani3lSun, I created custom table to use your plugin, the structure of my table looks like, str But when i insert the file, the pdf files are insered , except my others custom fields are filled with null values, as below str_cc_piece My query is:

DECLARE
v_adr       VARCHAR2(200);
  -- get files data from saved apex_collection
  CURSOR l_cur_files IS
    SELECT c001    AS filename,
           c002    AS mime_type,
           d001    AS date_created,
           n001    AS file_id,
           blob001 AS file_content
      FROM apex_collections
     WHERE collection_name = 'DROPZONE_UPLOAD';
BEGIN
  -- loop over files cursor
  FOR l_rec_files IN l_cur_files LOOP
    -- do whatever processing is required prior to the insert into your own table

    INSERT INTO TSL_CC_PIECES (
        UTI_CODE_USER,
        FILENAME,
        MIMETYPE,
        UPLOAD_DATE,
        FILE_CONTENT,
        FK_ID,
        DOS_NUMERO_DOSSIER
    ) VALUES (
        :GLOBAL_CODE_USER,
        l_rec_files.filename,
        l_rec_files.mime_type,
        l_rec_files.date_created,
        l_rec_files.file_content,
        :P10_FK_ID,
        :P10_ID_DOS
    );
  END LOOP;

  -- clear original apex collection (only if exist)
  IF apex_collection.collection_exists(p_collection_name => 'DROPZONE_UPLOAD') THEN
    apex_collection.delete_collection(p_collection_name => 'DROPZONE_UPLOAD');
  END IF;
EXCEPTION
  WHEN OTHERS THEN
    -- clear original apex collection (only if exist)
  IF apex_collection.collection_exists(p_collection_name => 'DROPZONE_UPLOAD') THEN
    apex_collection.delete_collection(p_collection_name => 'DROPZONE_UPLOAD');
  END IF;
END;

items

Thank you for help.

APEX version (5.1) Used web server & version and platform (Apache 9 / win x64) Used web browser (Chrome )

Dani3lSun commented 6 years ago

Hi @dpccrt87 seems correct can you show me a screen shot of the dropzone region attributes?

dpccrt87 commented 6 years ago

ok dz_1 ds_2

Dani3lSun commented 6 years ago

Ok, here´s the mistake. Your PL/SQL Code from the first post selects the files from a APEX collection and loops over it to insert into your own table. But you never fill that Collection with data because you choose "Custom table" in the plugin settings. Only use "Custom Table" if your table structure is exactly how the plugin expects it, if you have additional columns like FK always use APEX collection + your PL/SQL Code.

So the only thing you have to do is to change Storage Type from "Custom table" to "APEX Collection". Collection Name would be "DROPZONE_UPLOAD"

dpccrt87 commented 6 years ago

Thank you so much for help :D