Thursday, 28 September 2023

Save Images in Database AND Download Images From Database to Directory

 Save Images in Database


Declare

  FileName Varchar2(256);

Begin 

FileName := Get_FILE_NAME(File_Filter=> 'JPEG Files (*.JPG)|*.JPG|');

  Read_Image_File(FileName, 'JPG', 'distribution_logo');

End; 



Download Images From Database to Directory


CREATE OR REPLACE PROCEDURE HR0216.DOWNLOAD_IMAGES (

   p_directory       IN VARCHAR2,

   empid_from        IN NUMBER,

   empid_to          IN NUMBER

)

IS

   v_blob        BLOB;

   v_start       NUMBER             := 1;

   v_bytelen     NUMBER             := 2000;

   v_len         NUMBER;

   v_raw         RAW (2000);

   v_x           NUMBER;

   v_output      SYS.UTL_FILE.file_type;

   v_file_name   VARCHAR2 (200);

BEGIN


   FOR i IN (SELECT DBMS_LOB.getlength (PICTURE) v_len, EMPLOYEE_ID v_file_name,

                    PICTURE v_blob

               FROM smfimages.HRIMAGES WHERE employee_id between empid_from and empid_to  --114735

               )

 

   LOOP

      v_output := SYS.UTL_FILE.fopen (p_directory, i.v_file_name || '.TIFF', 'wb', 32760);

      v_x := i.v_len;

      v_start := 1;

      v_bytelen := 2000;


      WHILE v_start < i.v_len AND v_bytelen > 0

      LOOP

         DBMS_LOB.READ (i.v_blob, v_bytelen, v_start, v_raw);

         SYS.UTL_FILE.put_raw (v_output, v_raw);

         SYS.UTL_FILE.fflush (v_output);

         v_start := v_start + v_bytelen;

         v_x := v_x - v_bytelen;


         IF v_x < 2000

         THEN

            v_bytelen := v_x;

         END IF;

      END LOOP;


      SYS.UTL_FILE.fclose (v_output);

   END LOOP;

END DOWNLOAD_IMAGES;

/

Wednesday, 13 September 2023

Solve Devisor is equal to zero in Oracle SQL

 

Solve Devisor is equal to zero in Oracle SQL

DECODE(COLUMN2,0,0,((COLUMN1/COLUMN2)*100))

Sunday, 10 September 2023

How to Add Oracle Apex Checkbox Select /Un-Select All in Intrective Report

HOW to Add Check Box In Intrective Report for Select /Un-Select All

Step 1.

Add Checkbox as Apex Item in Report Query

(
select txn_ide,
APEX_ITEM.CHECKBOX(1,txn_ide)chk,
(select employee_name from v_employees_master where employee_id = plv.employee_id)emp_name,
(SELECT EMPLOYEE_CARD_NO FROM v_employees_master where employee_id = plv.employee_id)emp_card_no,
(SELECT ORGANIZATION_NAME FROM SMF_ORGANIZATIONS WHERE organization_id = PLV.ORGANIZATION_ID)ORGNAME,
(SELECT UNIT_NAME FROM SMF_UNITS WHERE unit_id = PLV.UNIT_ID)UNIT_NAME,
leave_date,
leave_from,
leave_to,
(select leave_name from hr_leaves where leave_code = plv.leave_code)Leave_Type ,
leave_days,
EMPLOYEE_ID,UNIT_ID,lev_rem
from per_leave plv
where approver = :EMPLOYEE_ID
and unit_id = :UNIT_ID
and organization_id = :ORGANIZATION_ID
and posted is null
and apr_sts is null 
)


Step 2.

Set Heading Property for the CHK like as per Follow
<input type = "checkbox" ID ="selectunselectall" title = "Select/Un-Select">
set Identification /type for CHK Percentgraph

Step 3.

Set Report Region Static ID as myreport

Step 4.

Click on Dynamic Action Tab and chose Change

Then 

Set the Property of Dynamic Action as per Follow

Execution:

Event Scope : Dynamic

Static Container Jqueryselector : #myreport


WHEN Event Change : 

Selection type : jquery selector

JQuerySelector : #selectunselectall

Step 5.

Now add the following java script code in true action 

if ($('#myreport #selectunselectall' ).is(':checked') ) {
  $('#myreport input[type=checkbox][name=f01]').prop('checked',true);
} else {
  $('#myreport input[type=checkbox][name=f01]').prop('checked',false);
}

Step 6.

Create a Process for the selected record as per Your Requirement

in my case I want to update the records in database

BEGIN
for i in 1..apex_application.g_f01.count
loop
update per_leave set apr_sts = 'Approved'
where txn_ide = apex_application.g_f01(i);
commit;
end loop;
END; 

When Button Presss Property set Your Button Name.


Thats It..

Check Internet Connectivity on Local System

if (!navigator.onLine) {     showOfflineAlert(); } else {     // Set a strict 3-second network timeout threshold     const controller = new ...