Home » Developer & Programmer » Forms » Serial No. in Data Block
icon9.gif  Serial No. in Data Block [message #125842] Wed, 29 June 2005 08:24 Go to next message
master
Messages: 10
Registered: June 2005
Location: India
Junior Member
Hi,

I am having two table

1. T_VOUCHER

co_cd VARCHAR2(3) NOT NULL,
br_cd VARCHAR2(4) NOT NULL,
WORK_BLK VARCHAR2(9) NOT NULL,
VOU_TYPE_CD VARCHAR2(10) NOT NULL,
VOU_NO NUMBER(5) NOT NULL,
VOU_DATE DATE,
VOU_AMT NUMBER(10,2),
JOB_TYPE_CD VARCHAR2(3) NOT NULL,
JOB_NO NUMBER(5) NOT NULL,

Primary Key - co_cd,br_cd,work_blk,vou_type_cd,vou_no

2. T_VOUCHER_DTL

co_cd VARCHAR2(3) NOT NULL,
br_cd VARCHAR2(4) NOT NULL,
WORK_BLK VARCHAR2(9) NOT NULL,
VOU_TYPE_CD VARCHAR2(10) NOT NULL,
VOU_NO NUMBER(5) NOT NULL,
VOU_SRNO NUMBER(3) NOT NULL,
EXPENSE_CD VARCHAR2(10),
EXPENSE_AMT NUMBER(10,2),

Primary Key - co_cd,br_cd,work_blk,vou_type_cd,vou_no,vour_srno
Foriegn key - co_cd,br_cd,work_blk,vou_type_cd,vou_no on T_VOUCHER

In Oracle Forms, I have made two Blocks with Master Details Relationship.

Now the problem is - When user insert a new record in T_VOUCHER_DTL block, Vou_Srno should be generated and displayed on the screen. I am able to generate Sr. No. while saving the record.

Second - Sum(Expense_AMT) should equal to T_VOUCHER.VOU_AMT.

Re: Serial No. in Data Block [message #125913 is a reply to message #125842] Wed, 29 June 2005 21:28 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
1) Use a sequence number in the When-Create-Record trigger of the T_VOUCHER_DTL block.

2) Search this forum for 'sum'. See http://www.orafaq.com/forum/m/119034/67467/?srch=sum#msg_119034

David
Re: Serial No. in Data Block [message #125937 is a reply to message #125913] Thu, 30 June 2005 01:15 Go to previous messageGo to next message
master
Messages: 10
Registered: June 2005
Location: India
Junior Member
Hi David,

When-Create-Record trigger allows me a generate a serial no. from database.
I can generate Sr. No. by max(vou_srno) + 1 but in detail block there are more than one entry and you need to generate sr. no. based on previous record. I need to show generated Sr. no. to user.

Re: Serial No. in Data Block [message #125941 is a reply to message #125937] Thu, 30 June 2005 01:31 Go to previous message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Okay what we need to do is maintain our own counter.

In a non-data block (which I call 'control') have a non-canvas item called Max_Num (or something like that) ... in When-New-Form-Instance populate it with a 'select' statement like 'max(vou_srno) + 1' then in your When-Create-Record use that value to populate VOU_SRNO and then increment the Max_Num.

WHEN-CREATE-RECORD
begin
  :t_voucher_dtl.vou_srno := :control.max_num;
  :control.max_num := :control.max_num + 1
end;


David
Previous Topic: integrating query builder and forms 10g
Next Topic: installlation error
Goto Forum:
  


Current Time: Fri Sep 20 07:51:33 CDT 2024