Showing posts with label oracle plsql. Show all posts
Showing posts with label oracle plsql. 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; /