Search This Blog

Monday, February 26, 2018

GENERATE TRANSACTION / SERIAL / SEQUENCE NUMBER WITH A NICE FORMAT.

Generate a number with Year+Month+Day+APP_USER+TRANID    format.

Declare v_trid varchar2(20) := Null;
Begin
SELECT TO_CHAR (SYSDATE, 'RR')
       || TO_CHAR (SYSDATE, 'MM')
       || TO_CHAR (SYSDATE, 'DD')
       || :APP_USER
       ||
  LPAD (NVL  (MAX (SUBSTR(TRANID,10,length(TRANID)) ), 0)+1, 6, 0) trid
  INTO v_trid
  FROM TABLE_NAME;
:P80_TRANID := v_trid;
EXCEPTION WHEN OTHERS THEN
RAISE_APPLICATION_ERROR(-20001,'Failed to Generate Transaction ID...! '||SQLERRM);
End;

Saturday, February 24, 2018

Interactive Grid Manual Insert, Update, Delete Button process

1. Create 3 button named Insert , Update, Delete 
 and Enable Edit
2. Create a process On Submit-After Computation and validation.
Copy and Pest the code as PL/SQL 

begin
    case :APEX$ROW_STATUS
    when 'C' then
        insert into PRODUCT_STORE ( SERIAL, PRODUCT_SERIAL, PRODUCT_CODE )
        values ( :SERIAL, :PRODUCT_SERIAL, :PRODUCT_CODE )
        returning rowid into :ROWID;
    when 'U' then
        update PRODUCT_STORE
           set PRODUCT_SERIAL  = :PRODUCT_SERIAL
              
         where rowid  = :ROWID;
    when 'D' then
        delete PRODUCT_STORE
         where rowid = :ROWID;
    end case;
end;

This process is written respecting a table and form item. But you should wright it respecting your table and form item.



Wednesday, February 7, 2018

Serial Number In Tabular Form Automatically Using JavaScript in Oracle Apex 5.1

1.  Copy Pest this JavaScript Function to Page HTML Header.

<script>
function serial_num() {
    
  var highest=0;
  $(".serial").each(function(){
    if (this.value != "") {
      highest=Math.max(highest,parseFloat(this.value));
    }
  });
  $(".serial").last().val(highest+1);
}
</script>

2.  Tabular column -> Column Attributes-> Go to Serial Column Attributes -> Element CSS Class

->   serial

3.  Add serial_num() JavaScript function to Button URL Target .

javascript:{apex.widget.tabular.addRow();serial_num();}

Image Size Restriction Validation in Oracle Apex 5.1

You want to make a restriction that user can not upload less then 20KB size image or more then 200KB  size image.
Then you can use this validation code.



declare
 cursor c is 
 select doc_size
 from apex_application_files
 where name = :P87_SGNCRD; 
 v_size number := 0;
 v_msg varchar2(100);
begin

open c; 
fetch c into v_size; 
close c;
  
if (v_size < 20480) then 
  v_msg  := 'Image must be at least 20KB!';
  DELETE from APEX_APPLICATION_FILES WHERE name = :P87_SGNCRD;  
  return v_msg;
elsif (v_size > 204800) then 
  v_msg  := 'Image size cannot be more than 200kb!';
  DELETE from APEX_APPLICATION_FILES WHERE name = :P87_SGNCRD;

  return v_msg;
end if;

end;

Tuesday, February 6, 2018

How to get Column data type

SELECT  all_tab_columns.COLUMN_NAME,all_tab_columns.DATA_TYPE 
FROM 
all_tab_columns  
where 
all_tab_columns.TABLE_NAME='Table_NameAND COLUMN_NAME='Column_Name'

Monday, February 5, 2018

JavaScript Assign one item value to another item

JavaScript  Assign one item value to another item :
Daynamic Action -> JavaScript

apex.item("P151_SERVICE_ID").getValue()

Affected item ->

How to Make A Check Box and Check mark Individual or Multiple In Oracle Apex 5.1


1.
select  
column1, column2, column3,
APEX_ITEM.CHECKBOX(10,'#ROWNUM#') "CHKBOX" 
from  TABLE_NAME


Go to Report Attributes ->(Respective Check Box) Column Attributes->Display As -> Standard Report Column

Go to Report Attributes ->(Respective) Column Attributes->Display As -> Display as text

2.
declare
V_ROW NUMBER;
begin
FOR i IN 1..APEX_APPLICATION.G_F10.COUNT LOOP

V_ROW := APEX_APPLICATION.G_F10(i);

update TABLE_NAME
set 
Column3='Y' 
where column1=APEX_APPLICATION.G_F01(V_ROW);

--RAISE_APPLICATION_ERROR(-20001,APEX_APPLICATION.G_F08(v_row)||v_row);
--RAISE_APPLICATION_ERROR(-20001,APEX_APPLICATION.G_F01(V_ROW));
--APEX_APPLICATION.G_F01(V_ROW)||

END LOOP;

end;


3.  Do This JavaScript

$('#P106_CHCKALL').change(function() {
    var checkboxes = $(this).closest('form').find(':checkbox');
    if($(this).is(':checked')) {
        checkboxes.prop('checked', true);
    } else {
        checkboxes.prop('checked', false);
    }
});


Go to Report Attributes and   Copy Pest it on the  Report Attribute -> Heading

<input type="checkbox" id="P106_CHCKALL" />

OR

<input type="checkbox" onclick="$f_CheckFirstColumn(this)" />


Pass value from Apex from item to Tabular form column. Oracle Apex 5.1


1. wright this JavaScript Function on the page HTML Header.

<script>
function setNextSortOrder() {
  var highest=document.getElementById('P151_SERVICE_ID').value;
  $(".sortorder").each(function(){
    if (this.value != "") {
      highest=highest;
    }
  });
  $(".sortorder").last().val(highest);
}
</script>

2. Tabular column -> Column Attributes  -> Element CSS Classes -> sortorder

3.Go to Add button and call the funciton.
javascript:{apex.widget.tabular.addRow();setNextSortOrder();}

PDF to Text Covert by Oracle Apex

Here are the steps to convert and get the character into a region by Oracle Apex. Step1.  Create a page and Copy-Pest the below code into Pa...