Home » Developer & Programmer » Forms » query multiple rows from one
query multiple rows from one [message #604338] Sat, 28 December 2013 23:16 Go to next message
alhanashi
Messages: 7
Registered: December 2013
Junior Member
hi
as the image
/forum/fa/11509/0/

there is to block in my form first one BLK_LPO when i press F9 in LPO_NO query LPO details it will get from table
LPO ( LPO_ID , LPO_NO , LPO_DT, COMPANY_ID, INVOICE_NO,INVOICE_DT, DELIVERY_NO, DELIVERY_DT )

now i want details to come to second block MODELS from table
MPDELS ( M_ID, NAME, RAM, HDD, PROCESS, LPO_ID, WARRANTY, D_TYPE)

where MODELS.LPO_ID = :BLK_LPO.LPO_ID

can any one help me
thanks
  • Attachment: ORACLE.png
    (Size: 106.12KB, Downloaded 1226 times)
Re: query multiple rows from one [message #604346 is a reply to message #604338] Sun, 29 December 2013 02:23 Go to previous messageGo to next message
shahzad-ul-hasan
Messages: 615
Registered: August 2002
Senior Member
Creat a button and put that code in when_button_pressed
declare
v_a number;
v_b varchar2(300);
cursor xyz is select (M_ID, NAME, RAM, HDD, PROCESS, LPO_ID, WARRANTY, D_TYPE)
from Models
where MODELS.LPO_ID = :BLK_LPO.LPO_ID
order by m_id;
begin
open xyz;
loop
fetch xyz into v_a,v_b;
exit when xyz%notfound;
:TEST1.TSTUID:= v_a;
:TEST1.TN := v_b;
NEXT_RECORD;
end loop;
close xyz;
end;

replace some code with your exact fields.
Re: query multiple rows from one [message #604348 is a reply to message #604346] Sun, 29 December 2013 04:10 Go to previous messageGo to next message
Littlefoot
Messages: 21807
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
I wouldn't do it that way. @alhanashi's situation is a classic example of master-detail relationship. Therefore, all that should be done is to follow Data Block Wizard's instructions and let it do the job. If foreign key constraint exists between these two tables, Forms will know how to create a join condition. Otherwise, create it manually.

Doing that, querying master (LPO) block will automatically retrieve detail records (MODELS); you don't have to write a single line of code.
Re: query multiple rows from one [message #604393 is a reply to message #604348] Mon, 30 December 2013 02:03 Go to previous messageGo to next message
alhanashi
Messages: 7
Registered: December 2013
Junior Member
thanks shahzad-ul-hasan ,
thanks Littlefoot,

i try it, now how i can add button for save , update and Query
Re: query multiple rows from one [message #604396 is a reply to message #604393] Mon, 30 December 2013 02:20 Go to previous messageGo to next message
Littlefoot
Messages: 21807
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Why would you do that? Forms runtime already contains a toolbar which fits most of your needs (at least, "save" and "query"; what do you mean by "update", anyway?).
Re: query multiple rows from one [message #604403 is a reply to message #604396] Mon, 30 December 2013 04:01 Go to previous messageGo to next message
alhanashi
Messages: 7
Registered: December 2013
Junior Member
ya I saw that toolbar but i do want to use it all
just i want some , like what i ask before.

sorry I'm new in that.
Re: query multiple rows from one [message #604417 is a reply to message #604403] Mon, 30 December 2013 07:31 Go to previous messageGo to next message
shahzad-ul-hasan
Messages: 615
Registered: August 2002
Senior Member
Create three Button
1. Save
Issue this command:
declare
begin
commit_form;
next_record;
end;

2. Search(Enter Query) (When Button Pressed)
Deaclare
Begin
Enter_query;
end;

3. Update Button
Re: query multiple rows from one [message #604446 is a reply to message #604417] Mon, 30 December 2013 12:18 Go to previous message
Littlefoot
Messages: 21807
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Too much typing for nothing. If you insist, what's wrong with just
commit;

enter_query;

in the first two triggers?

Also, I'm curious what would that "update" button do.
Previous Topic: Forms Cannot Connect
Next Topic: timer related problem /form cursor keep refreshing
Goto Forum:
  


Current Time: Tue Apr 16 06:52:05 CDT 2024