Showing posts with label Oracle D2k/forms/reports/10g. Show all posts
Showing posts with label Oracle D2k/forms/reports/10g. Show all posts

Wednesday, December 7, 2011

CALLING A FORM TO ANOTHER FORM IN ORACLE D2K/FORMS/10G


CALLING FORMS AT RUN TIME (FORM TO FORM CALLING IN ORACLE D2K)
This  topic is related to how you can call another form from existing form. Very important topic in Oracle d2k.
1.       We can call forms at run times in  three ways.
2.       Call_form:- it opens the form in model window mode i.e unless and until we close the called form , we cannot go back to the calling form.
3.       Open_form:- this open the form in modeless mode i.e we can work on both calling form and called form at the same time without closing any them.
4.       New_form:- this always close the calling form (ex. On successful login , the login screen closed and the application open).

All these three methods take on mandatory parameter i.e the complete path of FMX file to be called.

General points needs to be remember.
We need to add parameter for passing the values to different form. Four thing we need to be remember always.
1.       Declare parameter.
2.       Create parameter.
3.       Add parameter.
4.       Call form/open form/new form
5.       Destroy parameter.

Example :- I am writing a code which will illustrate you how we can call a form from another form.
DECLARE
P PARAMETER;
BEGIN
P:= CREATE_PARAMETER_LIST(‘ABC’);
ADD_PARAMETER(P,’P_EMPDEPTNO’,TEXT_PARAMETER,:DEPT.DEPTNO);
CALL_FORM(‘C:\EMP.FMX’,NO_HIDE,NO_REPLACE,NO_QUERY_ONLY,P);
DESTROY_PARAMETER_LIST(P);
END;
PARAMETER PASSING BETWEEN FORMS
WE CAN PASS VALUES FROM ONE FORM TO ANOTHER FORM WITH THE HELP OF PARAMETER.
STEPS:
1.       CREATE A FORM MODULE(CALLED FORM).
2.       CREATE A BASE TABLE BLOCK.
3.       CREATE A PARAMETER IN THE FORM.
4.       IN THE PROPERTY AND PARAMETER MENTION NAME, DATATYPE.
5.       IN A WHENNEW BLOCK INSTANCE TRIGGER OF THE BLOCK MENTION THE FOLLOWING
SET_BLOCK_PROPERTY(‘EMP’,DEFAULT_WHERE,’DEPTNO:=’||:PARAMETER.P_EMP_DEPTNO);
EXECUTE_QUERY;
6.       SAVE, COMPILE AND COMPILE THE FORM.
7.       CREATE THE NEW FORM .


POPUP MENU IN ORACLE D2K,10G,FORMS


POPUP MENU IN ORACLE D2K
1.       IN THE FORM MODULE , WE CAN CREATE A POPUP MENU.
2.       RIGHT CLICK ON THE POP UP MENU AND SELECT ‘MENU EDITOR’.
3.       DESIGN YOUR MENU IN THE MENU EDITOR.\
4.       WRITE CODE,SAVE AND COMPILE.
5.       NOW IN THE PROPERTY OF ANY FORM OBJECT UNDER THE PROPERTY ‘POP UP MENU’, SELECT OUR POPUP MENU.
6.       RUN YOUR FORM MODULE, RIGHT CLICK AT THE REQUIRED OBJECT AND SEE THE POP UP MENU.
NOTE:-
1.       TO MAKE THE MENU ITEM VISIBLE ON HORIZONTAL/VERTICAL TOOLBAR IN THE PROPERTY , MENU ITEM MENTION VISIBLE ON HORIZONTAL/VERTICAL TOOLBAR(YES/NO).

Thursday, December 2, 2010

Triggle in Oracle 10g

Trigger in Pl-sql/oracle/Oracle 10g forms and reports

1.    it is a db object which is a collection of pl/sql codes and it automatically get executed whenever any dml event happens provided trigger has been written for that DML event.
2.    Trigger has three section i.e. events, restrictions and when condition (optional.
3.    Pl sql trigger is divided into two parts. 1. Row level 2. Statement level.


Row Level Statement Trigger.
1.    Row level trigger is executed for each and every row affected by DML stmt.
2.    we need to use for each row for row level trigger.
3.    used in those cases where we need to depend on the values of every record of any column of any table.
4.    eg. Any name begin inserted must be in letter capital.

Statement Level Trigger.

1.    Statement level trigger is executed only once irrespective of No. of records affected by the dml statement.
2.    Every trigger is by default STMT level trigger.
3.    Used for restrictions like No Deletion allowed on Sunday on emp table.

Syntax.

CREATE [ OR REPLACE]
TRIGGER

BEFORE | AFTER 
INSERT  [ OR DELETE]
OF (OPTIONAL) 
ON FOR EACH ROW (OPTIONAL) REFRENCING NEW AS  OLD AS WHEN () (OPTIONAL) Note. 1.    to follow any value of any col. Of any record of any table within the execution section of a trigger always used :old.and :new.2.    Theses two can be followed only with in a row level trigger. :new. Refers to new values or that col for that row (Applicable for updated and insert) :old.Refers to old values for that col for that record (Applicable for both delete and update) Example:- Create or replace  Trigger tr_ex Before delete On  insert or update On emp For each row Declare  V_msg varchar2(200) Begin If inserting then  V_msg := ‘inserting….’ Elsif deleting then  V_msg := ‘deleting………….’; Elsif updating then V_msg := ‘deleting…’; End if; Dbms_output.put_line(V_msg); End; Q.    Create a trigger which will automatic make the first letter of  every name inserted | updated into capital letter irrespective of any case enter by user. Create or replace trigger Tr_name Before update or insert Of ename On emp For each row Begin Dbms_output.put_line(‘before change name = ‘ ||.new.ename); End; / Example of Statement level trigger. CREATE OR REPLACE TRIGGER TR_DELETE BEFORE DELTE ON EMP BEGIN IF TRIM(TO_CHAR(SYSDATE,’DAY’)) = ‘SUNDAY’ THEN RAISE _APPLICATION_ERROR  ( -20001,’NO DELTETION ALLOW ON SUNDAY); END IF; END; INSTEAD OF TRIGGER. This is used to perform DML operation on base table through join view. Create or replace trigger tr_instead  Instead of  Insert or update or delete On v_join Referencing new as N old as O For each row Declare V_count number; Begin  If inserting then Select count(*) into v_count from dept Where deptno = :n.deptno; If v_count = 0 then  Insert into dept values(:n.deptno,:n.dname,:n.loc); End if; Insert into emp (empno,ename,sal) values (:n.empno,:n.ename,:n.sal); Elsif updating then Update emp Set sal = :n.sal where empno = :o.empno; Update dept Set dname = :n.dname where deptno = :o.deptno; Elsif deleting then  Delete from emp where empno = :o.empno; Delete from dept where deptno = :o.deptno; End if; End; / 

Friday, October 22, 2010

COde for Report calling from Oracle d2k

declare
p paramlist;
appid pls_integer;
curtimer timer;
begin
p := create_parameter_list('abc');
add_parameter(p,'dno',text_parameter,:block2.deptno);
add_parameter(p,'DESTYPE',TEXT_PARAMETER,'file');
ADD_PARAMETER(P,'DESNAME',TEXT_PARAMETER,'c:\'||:block2.deptno||'.PDF');
ADD_PARAMETER(P,'DESFORMAT',TEXT_PARAMETER,'pdf');
ADD_PARAMETER(P,'PARAMFORM',TEXT_PARAMETER,'NO');

run_product(REPORTS,'c:\6i\emp.rdf',asynchronous,runtime,filesystem,p);
-- host('cmd /C START C:\'||:block2.deptno||'.pdf',NO_SCREEN );
host('cmd /C START iexplore C:\'||:block2.deptno||'.pdf',NO_SCREEN);


/*host('C:\Program Files\Internet Explorer\iexplore.exe');
appid := dde.app_begin(' C:\ankur2.pdf',DDE.APP_MODE_MINIMIZED); */


destroy_parameter_list(p);


end;

Thursday, October 21, 2010

Diffrence between two date, Pl-sql program result in Years - Month-format

Helo frnds

I am uploading this code.
work in pl-sql
DECLARE
DATE1 DATE;
DATE2 DATE;
V_NO NUMBER;
V_YEAR NUMBER;
V_MONTH NUMBER;
BEGIN
DATE1 := TO_DATE('&DATE1');
DATE2 := TO_DATE('&DATE2');
V_NO := DATE1 - DATE2;
IF (v_NO<0) THEN v_NO := V_NO * (-1);
END IF;
V_YEAR := TRUNC(V_NO/365);
V_NO := MOD(V_NO , 365);
V_MONTH := TRUNC(v_NO/30);
V_NO := MOD(V_NO,30);
DBMS_OUTPUT.PUT_LINE(V_YEAR ||' YEARS ' || V_MONTH ||' MONTH ' || V_NO || ' DAYS');
END;
/

Wednesday, October 20, 2010

PL-SQL program for calculating wheather a number is amstron or not

DECLARE
A NUMBER := &ENTER_THE_NUMBER;
B NUMBER := 0;
C NUMBER;
D NUMBER;
BEGIN
c := A;
WHILE(a!=0)
LOOP
D := MOD(A,10);
DBMS_OUTPUT.PUT_LINE(D);
B := B + (D*D*D);
DBMS_OUTPUT.PUT_LINE(B);
A := FLOOR(A/10);
DBMS_OUTPUT.PUT_LINE(A);
END LOOP;
IF (B = C) THEN DBMS_OUTPUT.PUT_LINE(' THIS IS A AMSTRON NUMBER');
ELSE
DBMS_OUTPUT.PUT_LINE('THIS IS NOT A AMSTRONG NUMBER' || B);
END IF;
END;
/
Please Comment on this

Wednesday, October 13, 2010

Editor in Oracle Developer 2000/d2k/forms



Oracle forms/Oracle Reports/Oracle /Oracle D2k/Oracle 2000 /Oracle 10G
Editor :- (Cnt+e)

1. this is used to show an editor user to enter information in a more comfortable way, used for fields like, address, comments, name etc
2. there are 3 type of editor
• default editor
• system defined editor
• user defined editor


DEFAULT EDITOR :- every text box is by default associated with a default editor

SYSTEM EDITOR :- in the property of text item we can use ‘system editor’ to show system editor at run time.
( who notepad/textpat/wordpad depending on what is editor that is associated with oracle in the file init.ora)

User defined editor :-

1. we can create our own editor and show it to user as per our requirement using a built in procedure i.e show_editor

Syntax

Show editor (‘name of editor’,message_in,x_pos,y-pos,message_out,Boolean_val,out parameter);

Out parameter will return true if user clicked ok on editor and false if user cancelled the
Editor.

Various ways to used editor at run time.

1. on the text itme.
2. edit menu :- edit on the text item.
3. Built in procedure:- ‘edit –texttem’ in the triggers
4. show_editor

Steps for create an editor.
1. create an editor
2. Make changes in the property of editor as per requirement.
3. Show editor using show editor/others ways at run time.





Code for editor button (when-button-pressed) of job field of emp block :-

Declare
B Boolean;
V_job varchar2(4000);
Begin
Show_editor
(‘ed_job’,:emp.job,100,100,v_job,b);
If b then
If length(v_job)>9 then
Message(‘you can enter 9 letter only’);
Message(‘’);
Raise form_trigger_failure;
Else
:emp.job := v_job;
End if;
Else
Message(‘cancelled’);
Message(‘’);
End if ;
End;