Solved

Populate a list item with data stored in a table

Posted on 2004-08-28
5
2,876 Views
Last Modified: 2010-05-18
Hi,

I have a form (created using the "book" table) which has a list item(poplist) called "year_book".
I have created a table "year_list" with only one column "year_book". In this "year_list" i have inserted years from 1900-2000.
At this point i want to populate the "year_book" list item(poplist) from the "book" form, using the table "year_list".

Can anyone help me??

Thank you in advance,
 krisz
0
Comment
Question by:krisztina1981
  • 2
  • 2
5 Comments
 
LVL 8

Expert Comment

by:annamalai77
Comment Utility
my dear friend,

u cannot populate year details from a detail, when u have a list item.
for ur condition, u should go a List Of Values only.

regards
annamalai
0
 

Accepted Solution

by:
djbaliotti earned 50 total points
Comment Utility
Krisz,
What version of Oracle Forms are you using?  Are you running in client-server or webforms mode?  The code belows worked in client-server versions and I am pretty sure it would work in a webform too.

A list item expects two values - the display value and the actual value.  In your case they are the same (for example, 1990 and 1990).  You should be able to create a record group(rg_years) that reads "year_book" twice (Select year_book YEAR_DISPLAY, year_book YEAR_VALUE from yearlist order by YEAR_DISPLAY).  The format has to match what the list item is expecting.

You then create a List Item(poplist) and set it with some default value - it will get replaced at runtime.  I usually use a default value that would alert me that the record group has failed at runtime - like X when X is not allowed so that the form does not allow the person to enter bad data. Your error handling should catch that but seeing

At Runtime, in the WHEN_NEW_FORM_INSTANCE trigger, the following code would execute:
-- gets rid of the bogus default value
   Clear_List('poplist');
-- populates the record group.  the return code will be zero if it is successful.  You can add your -- own error checking to handle it when it is not zero
   RG_RETURN_CODE := Populate_Group('rg_years'');
-- puts the record group values into the poplist
   POPULATE_LIST('poplist','rg_year');

You can get more information from the HELP in your Oracle Forms Builder software.

You can also use a List of Values (as annamalai suggested) but you will not get the list item drop down effect, if that is required by your user.

I hope I understood your problem correctly.

Good luck,
dj
 
0
 

Author Comment

by:krisztina1981
Comment Utility
Hi Dj,

Sorry for my late response but i couldn't answer earlier. Thanks for your detailed answer, but I have a problem with a line of the sample code:  RG_RETURN_CODE := Populate_Group('rg_years''); it tells me that i have to declare the identifier RG_RETURN_CODE. I don't know what to do. :(

Can you help me one more time? :)
I'm using oracle forms 6i, in client-server.

Thanks,

Krisz
0
 

Expert Comment

by:djbaliotti
Comment Utility
Krisz,

You just have to declare it like this at the top of the trigger:

DECLARE
   RG_RETURN_CODE   Number;

You can use it after the function call to check how successful the Populate_group was - the Populate_Group help screen in Forms says that 0 is good and other values are actual Oracle Error values.  Since we have a generic On Error trigger to trap all errors and log them to a table, I don't bother doing the error handling here but you may want to for your application.

Hope this does it for you.

DJ

0
 

Author Comment

by:krisztina1981
Comment Utility
Hi DJ

It's working now :).
Thanks again for your answer, it really helped me.

Thanks,

krisz
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Subquery in Oracle: Sub queries are one of advance queries in oracle. Types of advance queries: •      Sub Queries •      Hierarchical Queries •      Set Operators Sub queries are know as the query called from another query or another subquery. It can …
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now