Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Populate a list item with data stored in a table

Posted on 2004-08-28
5
2,881 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
ID: 11928663
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
ID: 11931894
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
ID: 11976829
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
ID: 11977605
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
ID: 11986334
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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Query Records that don't match 8 50
Oracle - SQL Parse String 5 45
ORA-04071: missing BEFORE, AFTER or INSTEAD OF keyword 2 62
Error in creating a view. 8 22
Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

856 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