Home » Developer & Programmer » Forms » Need help while inserting record in forms
Need help while inserting record in forms [message #606133] Mon, 20 January 2014 04:52 Go to next message
nkumar0130
Messages: 55
Registered: August 2013
Location: Bangalore
Member
Hi,
In my form I am having a Id column.
In form there are two blocks. each block is based on a table. And in both the table Id column is the key
The first block contain a button, so on pressing a button in first block it will open the second block.
My concern is that, after filling all the record in first block and on pressing the button it will open second block so on inserting the value in second block the value of Id column should get inserted automatically from the first block.

Any suggestion i highly appreciated

Thanks
Re: Need help while inserting record in forms [message #606134 is a reply to message #606133] Mon, 20 January 2014 04:58 Go to previous messageGo to next message
Littlefoot
Messages: 21808
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Create a master-detail form, using Data Block Wizard. It will set everything up for you, you don't have to do anything.

Or, if you insist on your own solution, see what second block's ID item "Copy value from item" property does. Or, do that manually (try WHEN-CREATE-RECORD or WHEN-NEW-RECORD-INSTANCE (test whether ID is null before (re)setting it!) or WHEN-NEW-ITEM-INSTANCE or, possibly, some other trigger). on the second block).
Re: Need help while inserting record in forms [message #606136 is a reply to message #606133] Mon, 20 January 2014 05:11 Go to previous messageGo to next message
nkumar0130
Messages: 55
Registered: August 2013
Location: Bangalore
Member
Hi Tittlefoot,

Thanks for your reply.
I cant able to do master -detail relation ship in this form.
I have to go through the second option suggested by you.
But I am not sure how to proceed with it.

It will be great helpful if you will elaborate the solution.

Thanks
Re: Need help while inserting record in forms [message #606142 is a reply to message #606136] Mon, 20 January 2014 06:03 Go to previous messageGo to next message
Littlefoot
Messages: 21808
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
So, did you
LF

see what second block's ID item "Copy value from item" property does

What did you find out?
Re: Need help while inserting record in forms [message #606148 is a reply to message #606142] Mon, 20 January 2014 06:53 Go to previous messageGo to next message
nkumar0130
Messages: 55
Registered: August 2013
Location: Bangalore
Member
Hi,

I cant able to use copy value from item.
Because In first window there are three blocks(A1,A2,A3) and each block contain a button.All the three block is based on a same table
So on pressing the button it will open another block(B).
Due to this I cant able to use the "Copy value from item" property
Re: Need help while inserting record in forms [message #606149 is a reply to message #606133] Mon, 20 January 2014 06:59 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
nkumar0130 wrote on Mon, 20 January 2014 12:53

Because In first window there are three blocks(A1,A2,A3) and each block contain a button.All the three block is based on a same table

Really? Then why did you say this:

nkumar0130 wrote on Mon, 20 January 2014 10:52

In form there are two blocks. each block is based on a table.


If you want any useful help then you need to accurately describe your problem.
How many blocks do you really have?
What is the relationship between them?
What precisely do you want to happen when you press on the button?

At the moment I have no idea what you're trying to do.
Re: Need help while inserting record in forms [message #606150 is a reply to message #606149] Mon, 20 January 2014 07:20 Go to previous messageGo to next message
nkumar0130
Messages: 55
Registered: August 2013
Location: Bangalore
Member
Sorry for the miss communication.

I am having two window.
In one window there is three block(A1,A2,A3) all three are based on a single table suppose employee table(empid is the primary key)
Another window contains one block(B) based on a table suppose person table(here empid is the foreign key)
on inserting in block B(i.e. second window) i want that empid to be inserted automayically.
I hope this will help you.

Thanks
Re: Need help while inserting record in forms [message #606151 is a reply to message #606148] Mon, 20 January 2014 07:29 Go to previous messageGo to next message
Littlefoot
Messages: 21808
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
nkumar0130 wrote on Mon, 20 January 2014 13:53

on pressing the button it will open another block(B).


OK then, put
:b.empid := :a1.empid;
into the WHEN-BUTTON-PRESSED trigger (of course, you'll have 3 buttons with 3 triggers so you'll change a1 -> a2 -> a3, depending on a block.
Re: Need help while inserting record in forms [message #606153 is a reply to message #606133] Mon, 20 January 2014 07:55 Go to previous messageGo to next message
nkumar0130
Messages: 55
Registered: August 2013
Location: Bangalore
Member
Hi Littlefoot,

I tried your suggestion but still i can't able to insert the empid in the person table(in BLOCK B)
Below is my when-button-pressed trigger code:-

DECLARE
v_WHERE VARCHAR2(1000);

BEGIN
v_WHERE := 'empid in (select empid from person where empid = '''||:a1.empid||''' and ......other conditions........)';
Set_Block_Property('B', ONETIME_WHERE,v_WHERE);
Go_block('B');
Execute_Query();
:B.empid := :a1.empid;

END;

On inserting record in B block I am getting error that empid cannot be null.
As i mentioned earlier empid is the foreign key and a not null column.
Re: Need help while inserting record in forms [message #606154 is a reply to message #606153] Mon, 20 January 2014 08:00 Go to previous messageGo to next message
Littlefoot
Messages: 21808
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
That doesn't make sense. First you execute a query which says "fill block B with records from the PERSON table where EMPID = :A1.EMPID". Then you say ":B.EMPID = :A1.EMPID". But, you already have those records so - why do you do that?
Re: Need help while inserting record in forms [message #606155 is a reply to message #606154] Mon, 20 January 2014 08:17 Go to previous messageGo to next message
nkumar0130
Messages: 55
Registered: August 2013
Location: Bangalore
Member
There are three condition why I need empid.
1) suppose block A1 is having record and i need to insert a record in person table using block B.
2) I need to insert a new record in employee table so i will go to A1 block and insert, so on inserting new record empid is generated through a sequence, and then i want to insert a record in block B1, for this i need a empid value.
3) Block A1 and block B contain data, but i need to insert one more row in block B(as block B is a tabular block), that time i need empid.
Re: Need help while inserting record in forms [message #606157 is a reply to message #606155] Mon, 20 January 2014 08:45 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
and how do a2 and a3 fit into this?
Re: Need help while inserting record in forms [message #606158 is a reply to message #606157] Mon, 20 January 2014 09:21 Go to previous messageGo to next message
nkumar0130
Messages: 55
Registered: August 2013
Location: Bangalore
Member
Same thing for A2 and A3 also. both the three block i shaving a button.
So if i am able to get the solution for A! then the same thing can be applied for A2 and A3 too.

It will be grateful if you help me for this.

Thanks
Re: Need help while inserting record in forms [message #606160 is a reply to message #606158] Mon, 20 January 2014 09:48 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
why do you have three a blocks? what's the difference between them?
Re: Need help while inserting record in forms [message #606166 is a reply to message #606133] Mon, 20 January 2014 11:29 Go to previous messageGo to next message
nkumar0130
Messages: 55
Registered: August 2013
Location: Bangalore
Member
there are three level, so according to the three level customer want the record in three blocks.
Thats why we need to create three block.
All the level of record is stored in a single level that's y all the three block is based on single table.
I hope this information will help you.
Re: Need help while inserting record in forms [message #606170 is a reply to message #606166] Mon, 20 January 2014 14:36 Go to previous messageGo to next message
Littlefoot
Messages: 21808
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Unfortunately, I have no idea what "three levels" mean. 3 levels of employees? Why do you need 3 blocks? Why not one block with two items: one defining level, another being the EMPID?

I re-read 3 conditions you mentioned in a message #606155 and I still think that
:B.EMPID = :A1.EMPID;
*should* work. Whatever you do, :Ax.EMPID (x being 1, 2 or 3) must have a value before you navigate to block B. Therefore, it is just a matter of IF-THEN-ELSE to decipher which "Ax" will be used to provide a value for B.EMPID.
Re: Need help while inserting record in forms [message #606204 is a reply to message #606170] Tue, 21 January 2014 03:40 Go to previous message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
As LF says your answer doesn't really help us understand why there are three blocks. What are the differences between the levels?
Because the simplest solution is to have 1 a block instead of 3.

Failing that try the following.
1) Create another datablock as a control block and give it an item empid, the item doesn't need to go on a canvas.
2) In each of the three buttons write code to assign :control.empid to :a<whichever>.empid
3) in the pre-insert trigger of b block assign :b.empid to :control.empid
Previous Topic: How to store multiple values in a variable & display it in its field in Forms 6i??
Next Topic: on-insert trigger
Goto Forum:
  


Current Time: Thu Apr 25 01:54:05 CDT 2024