Home » Developer & Programmer » Forms » multi values for one single record (student_id)
multi values for one single record (student_id) [message #473990] Wed, 01 September 2010 19:23 Go to next message
ramboil3arab
Messages: 4
Registered: July 2010
Location: Palestine
Junior Member
Hello All,

I really need your help in this form issue...

I am using forms 10g...

I have 2 blocks,in one i insert student_id and when i click on the button i should get all his courses in the other block...

BUT.. when the student has more than 1 course I get this:

when button pressed trigger raised unhandled exception ORA-01422

Here is the button code:

begin

select TEST_STUDENT_INFO.stud_name,TEST_STUD_CRSE_DETAIL.crse_no,
TEST_COURSES.crse_name,TEST_STUD_CRSE_DETAIL.crse_type,TEST_STUD_CRSE_DETAIL.crse_type_desc,
TEST_COURSES.crse_time
INTO :stud_name,:crse_no1,:crse_name,:crse_type1,:crse_type_desc1,:crse_time
from TEST_STUDENT_INFO,TEST_COURSES,TEST_STUD_CRSE_DETAIL
where (TEST_STUD_CRSE_DETAIL.STUD_ID =:TEST_STUD_CRSE_REG.STUD_ID)
and (TEST_STUDENT_INFO.STUD_ID =:TEST_STUD_CRSE_REG.STUD_ID)
and (TEST_COURSES.CRSE_NO = TEST_STUD_CRSE_DETAIL.CRSE_NO)
and (TEST_STUD_CRSE_DETAIL.CRSE_TYPE = TEST_COURSES.CRSE_TYPE);

end;

but if the student has ONLY ONE course it WORKS FINE!!!

please help guys, i really appreciate your help in advance
Re: multi values for one single record (student_id) [message #474018 is a reply to message #473990] Thu, 02 September 2010 01:49 Go to previous messageGo to next message
cookiemonster
Messages: 13938
Registered: September 2008
Location: Rainy Manchester
Senior Member
1) Why aren't you using the default query functionality of forms?
2) If you have a query that returns multiple rows you need to loop over it with a FOR LOOP.
Re: multi values for one single record (student_id) [message #474031 is a reply to message #474018] Thu, 02 September 2010 02:30 Go to previous messageGo to next message
ramboil3arab
Messages: 4
Registered: July 2010
Location: Palestine
Junior Member
Thank you for your response... can you please clarify number 1? I am quite a fresher to oracle and forms

I don't think I need a loop!

is there anyway I can show my form to everyone for their help?!

Thanks Smile
Re: multi values for one single record (student_id) [message #474039 is a reply to message #474031] Thu, 02 September 2010 03:51 Go to previous messageGo to next message
cookiemonster
Messages: 13938
Registered: September 2008
Location: Rainy Manchester
Senior Member
ramboil3arab wrote on Thu, 02 September 2010 08:30
Thank you for your response... can you please clarify number 1? I am quite a fresher to oracle and forms

Base the block on a table or view (view in your case) and use execute_query to populate.

ramboil3arab wrote on Thu, 02 September 2010 08:30

I don't think I need a loop!

Of course you do. Unless you use execute query.
SELECT INTO is designed to get one row - if it finds more than one matching row you get that error.
Even if it didn't do that you're assigning the values to a single record in the detail block.
To do it this way you need to do something like this:
FOR rec IN cursor LOOP

  :stud_name := rec.stud_name;
  :crse_no1 := rec.crse_no;
  ........

  next_record;

END LOOP;

next_record makes sure that each record retrieved from the query goes in a different record in the datablock.
It's easier to use execute_query.

ramboil3arab wrote on Thu, 02 September 2010 08:30

is there anyway I can show my form to everyone for their help?!


Rack up a few more posts and you'll be able to attach it. I'm not sure there's any point mind. I think you need to spend some time reading the docs.
Re: multi values for one single record (student_id) [message #475822 is a reply to message #474039] Fri, 17 September 2010 19:08 Go to previous message
ramboil3arab
Messages: 4
Registered: July 2010
Location: Palestine
Junior Member
Thank you Sir,

This is very helpful

I found out that the Detail items were non-database items and i changed their type from text item to Dispmay items...the post query works fine now Smile THANK YOU
Previous Topic: Compile form show error :PDE-PER001 INTERNAL ERROR (deucx 9 8)
Next Topic: ORA-01446 on-update
Goto Forum:
  


Current Time: Thu Sep 19 17:29:22 CDT 2024