Home » Developer & Programmer » Forms » fetching records from one table and populating to multi record block
fetching records from one table and populating to multi record block [message #154120] Thu, 05 January 2006 15:35 Go to next message
vinodkumarn
Messages: 60
Registered: March 2005
Member
I have a table A and now i am trying to fetch records from table A and populating into a multi record block based on table B. i have the following code. here i have to use all the block column names(almost 50) to assign values.

Is there any way where we can populate without naming the each block column names.

only difference between table A and table B is table A have one extra column called template_id and rest are same

PROCEDURE POPULATE_DETAILS IS
cursor cur_fetch is
select *
from A
where template_id=:parameter.template_id;
c cur_fetch%rowtype;
begin
go_block('procurement_action');
if :parameter.template_id is not null then
last_record;
next_record;
open cur_fetch;
loop
fetch cur_fetch into c;
exit when cur_fetch%notfound;

:B.fy := c.fy;
:B.code := c.code;
:B.nbr := c.nbr;
---
---
(like this i have around 50 columns.........)

next_record;
end loop;
first_record;
end if;
end;

Thanks
Vinod
Re: fetching records from one table and populating to multi record block [message #154138 is a reply to message #154120] Thu, 05 January 2006 20:41 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Populate block using cursor http://www.orafaq.com/forum/m/605/67467/?srch=populate+block+cursor+create_record#msg_605
and my feelings about it http://www.orafaq.com/forum/m/134237/67467/?srch=populate+block+cursor+create_record#msg_134237

David
Re: fetching records from one table and populating to multi record block [message #154301 is a reply to message #154138] Fri, 06 January 2006 11:51 Go to previous messageGo to next message
vinodkumarn
Messages: 60
Registered: March 2005
Member
I think i did not write my question properly

The code i have written above is working perfectly fine. my question is there any other methods to do the same work, without assigning cursor values to each block.item name, bcos i have 50 columns to be populated and so i need to write this assignment statement from cursor value to block.item_name 50 times

is there anything where i can populate the entire row at a time and put it in the multi record block. all the column names from the table from where i am populating and the block.item names are same.

i hope i have told my question properly

Thanks
Vinod
Re: fetching records from one table and populating to multi record block [message #154386 is a reply to message #154301] Sat, 07 January 2006 15:20 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Perhaps just another idea: do not use cursor at all, but insert data like this:

INSERT INTO table_b (col1, col2, ..., col50)
SELECT col1, col2, ..., col50
FROM table_a WHERE
template_id = :parameter.template_id;

Unfortunatelly, table_a <> table_b UNLESS you do the following (of course, if it is possible and won't cost you much later):

ALTER TABLE table_b ADD template_id datatype;

Then the first query is even easier to write:

INSERT INTO table_b SELECT * FROM table_a;

Now, having desired records in table_b, perform EXECUTE_QUERY in the form.
Re: fetching records from one table and populating to multi record block [message #154467 is a reply to message #154301] Sun, 08 January 2006 18:05 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Quote:

my question is there any other methods to do the same work
YES, base your block on the table and let Oracle Forms do the work for you.

David
Re: fetching records from one table and populating to multi record block [message #154608 is a reply to message #154120] Mon, 09 January 2006 13:25 Go to previous messageGo to next message
vinodkumarn
Messages: 60
Registered: March 2005
Member
no the whole problem is i do not want to base the block on table B, but i want to base it on table A itself but only populate records from table B and when i save it should save in table A.

Vinod
Re: fetching records from one table and populating to multi record block [message #154620 is a reply to message #154608] Mon, 09 January 2006 14:45 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
May I ask, WHY don't you want to have a block based on 'table_b'? Is there a valid reason to do so? Or are you trying to reinvent a wheel?
Re: fetching records from one table and populating to multi record block [message #154627 is a reply to message #154620] Mon, 09 January 2006 16:31 Go to previous messageGo to next message
vinodkumarn
Messages: 60
Registered: March 2005
Member
yes i have a very valid reason to do this.

I have this block based on table A and i always do all the transactions based on table A, but however in some cases apart from this operation i also have to populate records from table B(pre populate so that user can avoid entering) and insert into table A.

Vinod
Re: fetching records from one table and populating to multi record block [message #154637 is a reply to message #154627] Mon, 09 January 2006 21:15 Go to previous message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Consider using non-database fields on Block A and populate them in the Post-Query by a select on Table B. Then use these values when you do something to a field in the Record A.

David

Previous Topic: multibyte character in LOV
Next Topic: Synchronise Timing
Goto Forum:
  


Current Time: Fri Sep 20 02:18:02 CDT 2024