1. Overview

This blog explains about, How to Use Webutil browse file from desktop to directory .

2. Technologies and Tools Used

The following technology has been used to achieve the same.

Ø Oracle FORMS

3. Use Case

  1. Create the form like the below.
  2. Use the below code In load file “button” using “when-button-pressed” trigger.

4. Architecture 

Oracle FORMS

  1. FORM Builder

5. Examples

Step 1: Create one form like below:

Step 2: using the below code In load file “button” using “when-button-pressed” trigger.

Code:

DECLARE

   l_userhome            VARCHAR2 (200)

         := webutil_clientinfo.get_system_property (‘user.home’)

            || ‘\Desktop’;

   l_filename            VARCHAR2 (200) := NULL;

   l_bare_filename       VARCHAR2 (200) := NULL;

   l_fileprefix          VARCHAR2 (200) := NULL;

   l_serverfilename      VARCHAR2 (200) := NULL;

   l_upload_path         VARCHAR2 (200) := NULL;

   l_version_path        VARCHAR2 (200) := NULL;

   l_option_grade_path   VARCHAR2 (200) := NULL;

   l_size_curve_path     VARCHAR2 (200) := NULL;

   l_filesize            NUMBER;

   al_con                alert;

   l_status              BOOLEAN;

   os_name               VARCHAR2 (100)

                           := UPPER (webutil_clientinfo.get_operating_system);

   l_mainbrand           VARCHAR2 (100);

   l_country             VARCHAR2 (100);

   l_jobid               NUMBER;

   CURSOR c_upload_dir

   IS

      SELECT t.VALUE AS directory_path

        FROM sys_directories t

       WHERE t.NAME = ‘TRACKING_FILE’;

BEGIN

   OPEN c_upload_dir;

   FETCH c_upload_dir

    INTO l_upload_path;

   CLOSE c_upload_dir;

   l_filename :=

      webutil_file.file_open_dialog

                                  (directory_name      => l_userhome,

                                   file_name           => NULL,

                                   file_filter         => ‘CSV files (*.csv) |*.csv’,

                                   title               => ‘File Upload’

                                  );

   IF l_filename IS NOT NULL

   THEN

      — to get the file size —

      l_filesize := webutil_file.file_size (file_name => l_filename);

      — to get the filename without the path —

      IF os_name LIKE ‘WINDOWS%’

      THEN

         l_bare_filename :=

                           SUBSTR (l_filename, INSTR (l_filename, ‘\’, -1)

                                    + 1);

      ELSE

         l_bare_filename :=

                           SUBSTR (l_filename, INSTR (l_filename, ‘/’, -1)

                                    + 1);

      END IF;

      IF webutil_file.file_exists (file_name => l_filename)

      THEN

         IF webutil_file.file_is_readable (file_name => l_filename)

         THEN

            IF l_filesize > 0

            THEN

               l_serverfilename :=

                     l_bare_filename

                  || ‘_’

                  || TO_CHAR (SYSDATE, ‘DDMMYYYYHH24MISS’);

               IF l_upload_path IS NOT NULL

               THEN

                  l_status :=

                     webutil_file_transfer.client_to_as_with_progress

                                 (clientfile            => l_filename,

                                  serverfile            =>    l_upload_path

                                                           || ‘/’

                                                           || REPLACE

                                                                 (l_serverfilename,

                                                                  ‘.csv’,

                                                                  ”

                                                                 )

                                                           || ‘.csv’,

                                  progresstitle         => ‘File Upload in progress’,

                                  progresssubtitle      => ‘Please wait’,

                                  asynchronous          => FALSE,

                                  callbacktrigger       => ”

                                 );

                  SYNCHRONIZE;

                  IF l_status = TRUE

                  THEN

                     MESSAGE (‘done transfer’);

                     MESSAGE (‘done transfer’);

                     l_status := FALSE;

                  ELSE

                     MESSAGE (‘Not transfer’);

                     MESSAGE (‘Not transfer’);

                  END IF;

               END IF;

            END IF;

         ELSE

            MESSAGE (‘File ‘ || l_bare_filename || ‘ is blank’);

         END IF;

      ELSE

         MESSAGE (   ‘Unable to read the file’

                  || CHR (10)

                  || ‘File Name=’

                  || l_bare_filename

                  || ‘, ‘

                  || CHR (10)

                  || ‘File Size=’

                  || l_filesize

                  || ‘ Byte’

                 );

      END IF;

   ELSE

      MESSAGE (‘File ‘ || l_bare_filename || ‘ is not found’);

   END IF;

EXCEPTION

   WHEN OTHERS

   THEN

      MESSAGE (SQLERRM);

END;

Step 2: Run the form in application.

It will move the file from local to oracle directories.

6. Conclusion

We can use the Oracle form and Webutil package file in our local system to Oracle Directories.

Recent Posts

Start typing and press Enter to search