How to populate this non db block please ? [message #581334] |
Thu, 04 April 2013 11:35 ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
![](//www.gravatar.com/avatar/2df5c6ebd3e53c4fceb381a509dac221?s=64&d=mm&r=g) |
somegirl
Messages: 19 Registered: March 2013
|
Junior Member |
|
|
![http://i1059.photobucket.com/albums/t423/enchanted38/form.jpg](http://i1059.photobucket.com/albums/t423/enchanted38/form.jpg)
Record 1 with label A fetches fields name1 & address1 from table 'emp'
and Record 2 with label B fetched fields name2 & address2 from same table 'emp'
I want to use a non db block to populate these records. Any help please how to write such a procedure to do so ?
Thanks.
[Updated on: Thu, 04 April 2013 11:37] Report message to a moderator
|
|
|
|
|
Re: How to populate this non db block please ? [message #581339 is a reply to message #581338] |
Thu, 04 April 2013 15:11 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
joy_division
Messages: 4963 Registered: February 2005 Location: East Coast USA
|
Senior Member |
|
|
Don't use a repeating block and rename the fields to unique identifiers.
However, this is a poor design to being with and I am only making it worse, but it does indeed fit your request.
select name1, name2, addess1, address2, etc.
into :name_1, :name_2, :address_1, :address_2, etc.
from table
where clause
Where clause must of course only return one row.
I'll repeat it again, this is a poor design and I see no reason why you would want to do something like this. Your table seems to be denormalized and you are just trying to hide/bandage it up with method.
|
|
|
Re: How to populate this non db block please ? [message #581340 is a reply to message #581339] |
Thu, 04 April 2013 15:42 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
![](/forum/images/custom_avatars/72104.gif) |
Littlefoot
Messages: 21823 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
How about a loop, for example
begin
for cur_r in (select name, address from emp) loop
:block.name := cur_r.name;
:block.address := cur_r.address;
next_record;
end loop;
end;
That *might* work if you want to retrieve records from a table that has NAME and ADDRESS columns. However, if Quote:
Record 1 with label A fetches fields name1 & address1 from table 'emp'
and Record 2 with label B fetched fields name2 & address2 from same table 'emp'
means that this table contains all these columns (NAME1, ADDRESS1, NAME2, ADDRESS2, ...), then it, of course, won't work.
|
|
|
|
|
|