Oracle9iAS Portal Developer Kit

file_download procedure

Contained in package wwa_app_module.

Call this procedure to display a form component item of type 'File Upload (Binary)/ File Upload (Intermedia)'.

If a form component is based on a table with column(s) such as BLOB/ ORDSYS.ORDIMAGE/ ORDSYS.ORDAUDIO/ORDSYS.ORDVIDEO, by default, the corresponding item types are File Upload (Binary) /File Upload (Intermedia). There would be procedures such as upload_x and download_x in the generated package (where x=1,2,3,4,5...depending on the number of BLOB/Intermedia columns) that uploads and downloads the Intermedia/BLOB content.

When a query operation is performed, the results display a download link (or an image if the mime type has been set to an image type). This procedure is invoked when you click the download link, which in turn invokes one of the download_x procedures to perform the actual download.

procedure file_download
(
    p_id in integer,
    p_block in varchar2,
    p_object in varchar2,
    p_source in varchar2
);

Version: Oracle Portal 3.0.9

Parameters:

p_id

The session ID.

Note: This parameter is available in Oracle9iAS Portal 9.0.2 or later.

Datatype: integer

p_block

The form block to which the form element of type File Upload (Binary)/File Upload (Intermedia) belongs.

Datatype: varchar2

p_object

The form element name of type File Upload (Binary)/ File Upload (Intermedia).

Datatype: varchar2

p_source

The ROWID of the row from which the BLOB/INTERMEDIA column is to be fetched.

Datatype: varchar2

Exceptions:

None.

Example:

Example applicable for Oracle9iAS Portal 9.0.2 or later. Consider a form component based on a table named table_of_songs (id number, audio ORDSYS.ORDAUDIO). This form component has an item named 'AUDIO' which when run, uploads a .wav or .mp3 file.
To generate hyperlinks that download these files (after a query), the following code is required in the 'Additional PL/SQL' section called 'after displaying the page':

declare
    l_block varchar2(200) := 'DEFAULT';
    l_OBJECT varchar2(200) := 'AUDIO';
    l_rowid varchar2(200);
    l_session_id integer;
    l_state varchar2(200);
begin
    l_state := p_session.get_value_as_varchar2(
        p_block_name => l_block,
        p_attribute_name => '_FORM_STATE'
      );
    if l_state = 'UPDATE_AND_DELETE' then
     l_session_id := p_session.get_id;
     l_rowid := p_session.get_value_as_varchar2(
          p_block_name => l_block,
          p_attribute_name => '_ROWID'
       );
     htp.anchor(curl=>'http://<host>:<port>/pls/<dad>/<portal_schema>.'||
          'wwa_app_module.file_download?p_id='||l_session_id||
           '&p_block='||l_block||
          '&p_object='||l_object||
          '&p_source='||<portal_schema>.wwv_htf.url_encode(l_rowid),
          ctext => 'my link');
    end if;
end;

Note: For this code example to work it must be written in the 'Additional PL/SQL' section named 'after displaying the page'.

Related topics

The PL/SQL API Reference is part of the Portal Developer Kit on Portal Studio