Relationship Between Master and Detail Forms

To discuss Oracle Forms & Reports related technical issues.
Post Reply
musman
Posts: 31
Joined: Thu Apr 26, 2007 10:35 am
Location: Pakistan

Relationship Between Master and Detail Forms

Post by musman »

I have created two forms one is master and other is detail .I have called detail form from master from .I want to create relationship between both forms.
Please make me solution.
ahmadbilal
Posts: 615
Joined: Mon Sep 18, 2006 1:32 am
Location: United Arab Emirates
Contact:

Post by ahmadbilal »

Dear Usman,

If tables used on back end of these forms have primary - foreign relation ship then you can simply create relation ship by using Data Blocks relations.You can also handle this by using different canvases(i would like to suggest "use multi canvas instead of New form".

If they don't have any relation ship but have one common (like id) then write a cursor on button trigger when_button_pressed and call form and fetch data in detail form.

Example Code
Declare
CURSOR C IS
SELECT * FROM Table_name
WHERE APPID = :Fieledname;

VAR_CUR C%ROWTYPE;
VAR_INAME VARCHAR2(100);
VAR_UNAME VARCHAR2(100);
VAR_TAX NUMBER;
VAR_DISC NUMBER;
VAR_TOT NUMBER;

BEGIN
--Open Form and Go_block
call_form(Form_name)
GO_BLOCK('Block Name');
FIRST_RECORD;
CLEAR_BLOCK;

OPEN C;
LOOP

FETCH C INTO VAR_CUR;
IF C%NOTFOUND THEN
EXIT;
END IF;

:SR := VAR_CUR.SRNO;
:INST := VAR_CUR.INSTNO;
:DUEDATE := VAR_CUR.DUEDATE;
:DUEAMT := VAR_CUR.DUEAMT;
NEXT_RECORD;
END LOOP;

CLOSE C;

FIRST_RECORD;

GO_BLOCK('Block Name');

END;




Let us Know if still have confusion / issue
musman
Posts: 31
Joined: Thu Apr 26, 2007 10:35 am
Location: Pakistan

Post by musman »

My requirement is that Master form is based on Dept Table and Detail form is based on Emp Table.I have two seperate forms one for Master and other for Detail.When i execute query on Master form suppose on executing query deptno 10 is displayed .When i click button to call Detail Form information should display on Detail form only against Dept No 10.I mean only against that Department which is on Master Form.
ahmadbilal
Posts: 615
Joined: Mon Sep 18, 2006 1:32 am
Location: United Arab Emirates
Contact:

Post by ahmadbilal »

then you should use second option (cursor)

any confusion
musman
Posts: 31
Joined: Thu Apr 26, 2007 10:35 am
Location: Pakistan

Post by musman »

No confusion Thanks a lot.
musman
Posts: 31
Joined: Thu Apr 26, 2007 10:35 am
Location: Pakistan

Post by musman »

Please check it out.I am doing like that

i have master form name DTEST that contains Dept Table Columns.
Second form is DTEST1 that contains Emp Table Columns and is in tabular form.I have a button on DTEST form and when_button_pressed
trigger i have written this code

Declare
CURSOR C IS
SELECT * FROM emp
WHERE deptno = :deptno;

VAR_CUR C%ROWTYPE;


BEGIN
call_form('e:\test\dtest1.fmx');
GO_BLOCK('emp');
FIRST_RECORD;
CLEAR_BLOCK;

OPEN C;
LOOP

FETCH C INTO VAR_CUR;
IF C%NOTFOUND THEN
EXIT;
END IF;

:EMP.EMPNO := VAR_CUR.empno;
:EMP.name := VAR_CUR.ename;
:EMP.v_job := VAR_CUR.job;
:EMP.mgr := VAR_CUR.mgr;
:EMP.hiredate:=VAR_CUR.hiredate;
:EMP.sal:=VAR_CUR.sal;
:EMP.comm:=VAR_CUR.comm;
:EMP.deptno:=VAR_CUR.deptno;

NEXT_RECORD;
END LOOP;

CLOSE C;

FIRST_RECORD;

GO_BLOCK('emp');

END;

First i execute query on master form and deptno 10 and its name and other information displays on this form.
Then I press button on master form.The error is that bad bind variable :emp.empno,:emp.name and like that.
Detail Form opens but no data is fetched on it against deptno 10

What is the problem here.

Both forms are seperate.
ahmadbilal
Posts: 615
Joined: Mon Sep 18, 2006 1:32 am
Location: United Arab Emirates
Contact:

Post by ahmadbilal »

Dear Usman,

First You need to get current Dept no(for Current Record where cursor and store into global variable)

you need to write this Code on when_new_form_instance trigger by passing Global variable dept no at that time of form opening

On Button you just get dept no and store it into global variable call form and pass all code on when_new_form_instance

Let Me Know in case of any issue
musman
Posts: 31
Joined: Thu Apr 26, 2007 10:35 am
Location: Pakistan

Post by musman »

Dear Bilal,
Thanks a lot. Sorry for too much discussion on a little topic.
But i was confused.Now i have tried like that.I have done it very well and have found my results according to my requirements.
Now i have no confusion.


Again i am very thankful to you
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests