Hire me on UpWork

Sunday, September 23, 2012

How to Check Only One Item In a Check Box ?

Hello Redars, How are you ?

Here i will share a tricky PL/SQL code with you. If you want to use Check Box in oracle forms and want to restrict end user to select only one check box, how will you handle this ?

Just customize the following code and you will get the result.

declare
  l_current_record number;
  l_last_record    number;
begin
  l_current_record := :system.trigger_record;

  last_record;
  l_last_record := :system.cursor_record;
 
  first_record;
   
  for i in 1 .. l_last_record loop
    if :system.cursor_record <> l_current_record then
       :SM_ACT_FLAG := 0;
    end if;
    next_record;
  end loop;
 
  go_record(l_current_record);
end;

If you have any question regarding this..just leave comments and i will answer.

Monday, June 4, 2012

How to Calculate Average of Date Values ?

Do you getting trouble of calculating average time of a filed, where data type is date time ?
Don't worry. You are at right place to get right solution.

I'm calculation of average time of a filed. If there is two time value in a day, i will calculate the first one means minimum one.

SELECT TO_CHAR(TRUNC(SYSDATE)+AVG(VDATE-TRUNC(VDATE)),'HH24:MI:SS')
FROM (SELECT MIN(DDATE) VDATE
FROM DEPT
GROUP BY TRUNC(DDATE))

Make changes in the script as your need and try.

Hope this helps you in work. 

Leave comments if it helps you.

Friday, April 27, 2012

How to call a report in Forms 10g ?

Calling reports from forms isn't like forms version 6i, where you can call a report via RUN_PRODUCT.
I will talk another day if i think it's needed. Because Forms version 6i isn't supported by Oracle.com and it's uses is going to decreases.

Lets talk about version 10g Developer Suite. In development environment you need to run report server manually but at Application Server it's not needed.

How can we run report server manually ?
Just go to start menu >> run and type    
rwserver SERVER=myserver
Where myserver is the server name.
Now reports server runs.
 
In your form under Reports Node create an report object and give name MYREPORT
(Select Reports Node click on Create Icon(+), select Use Existing Report File then give
 a name in the box and click OK.
Re-name it to MYREPORT go to property and delete FILENAME property value.)  
  
Make changes(Report Name) on following code and  try this in a Button trigger 
 
DECLARE
 
v_repid REPORT_OBJECT;
v_rep VARCHAR2(100);
v_rep_status VARCHAR2(100);
v_param VARCHAR2(200) := NULL;
v_valor VARCHAR2(200);
v_url VARCHAR2(2000);
v_repserver varchar2(20) := 'myserver';
 
v_report varchar2(100) := 'D:\REPORT_NAME.REP';
v_PARAMETRO varchar2(100) := '';
 
BEGIN
 
v_repid := FIND_REPORT_OBJECT('MYREPORT'); -- report is an element from object navigator report
SET_REPORT_OBJECT_PROPERTY(v_repid, REPORT_FILENAME, v_report);
SET_REPORT_OBJECT_PROPERTY(v_repid, REPORT_EXECUTION_MODE, BATCH);
SET_REPORT_OBJECT_PROPERTY(v_repid, REPORT_COMM_MODE, SYNCHRONOUS);
SET_REPORT_OBJECT_PROPERTY(v_repid, REPORT_DESTYPE, cache);
SET_REPORT_OBJECT_PROPERTY(v_repid, REPORT_DESFORMAT, 'pdf' );
SET_REPORT_OBJECT_PROPERTY(v_repid, REPORT_DESNAME, v_report);
SET_REPORT_OBJECT_PROPERTY(v_repid, REPORT_SERVER, v_repserver);
SET_REPORT_OBJECT_PROPERTY(v_repid, REPORT_OTHER, 'paramform=no '||v_PARAMETRO);
v_rep := RUN_REPORT_OBJECT(v_repid);
v_rep_status := REPORT_OBJECT_STATUS(v_rep);
WHILE v_rep_status IN ('RUNNING','OPENING_REPORT','ENQUEUED') LOOP
v_rep_status := REPORT_OBJECT_STATUS(v_rep);
END LOOP;
IF v_rep_status = 'FINISHED' THEN
message(v_rep);
message(v_rep);
WEB.SHOW_DOCUMENT(v_url||'/reports/rwservlet/getjobid'||
SUBSTR(v_rep, INSTR(v_rep,'_', -1)+1)||'?'||'server='||v_repserver, '_blank');
END IF;
 
END;
 
Updated: 20/January/2013
  
For more Click Here
 
Hope this helps you all.