Home » Developer & Programmer » Forms » Combo Box Problem
icon5.gif  Combo Box Problem [message #140611] Tue, 04 October 2005 23:34 Go to next message
bhoite_amol83
Messages: 110
Registered: June 2005
Location: Pune
Senior Member
Hi Friends,
I have one table.
CREATE TABLE TEMP (ID NUMBER, NAME VARCHAR2 (10));

Records are ;

Insert into temp values (1,’aaa’);
Insert into temp values (2,’bbb’);
Insert into temp values (3,’ccc’);

And I want to get values of id in my ComboBox/ListBox


What can I do for it?
Plz Send me code to get values in combobox;

Thanx for any help .

Amol.
Re: Combo Box Problem [message #140612 is a reply to message #140611] Tue, 04 October 2005 23:50 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
To have the ID in your database table but the NAME to only exist in the code table do the following.

Create a record group based on the two fields, associate it with an LOV, define the ID as having a width of zero, create a non-database field in your block and on the canvas, associate the LOV with this field, also for this field 'return' the ID to your database field which is not on the canvas and 'return' the NAME to your non-database field which IS on the canvas. Remember to populate your non-database field in the Post-Query trigger of your block.

David
Re: Combo Box Problem [message #140614 is a reply to message #140611] Wed, 05 October 2005 00:00 Go to previous messageGo to next message
bhoite_amol83
Messages: 110
Registered: June 2005
Location: Pune
Senior Member
Thanx for ur reply,
Plz tell me how to populate non-database field in the Post-Query trigger of block.


Amol.

[Updated on: Wed, 05 October 2005 00:17]

Report message to a moderator

Re: Combo Box Problem [message #140627 is a reply to message #140614] Wed, 05 October 2005 00:33 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
select NAME
  into :blk.fld
  from temp
 where ID = :blk.id;

David
Re: Combo Box Problem [message #141147 is a reply to message #140611] Fri, 07 October 2005 03:50 Go to previous messageGo to next message
bhoite_amol83
Messages: 110
Registered: June 2005
Location: Pune
Senior Member
Hello David Sir,
I tried with it many times can you plz tell me all coding detail because i am a fresher with oracle forms.

Thanx in advance for any kind of help.

Amol.
Re: Combo Box Problem [message #141361 is a reply to message #141147] Sun, 09 October 2005 18:55 Go to previous message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Create a new form. Create record_group using 'Query Text', "select id, name from temp order by 1". It is called record_group3. Create an LOV using the wizard. Use an existing record group, 'record_group3'. Use 'Modify existing Record Group', then 'next', press 'double arrow', 'next', set width of ID to zero, 'next', set title to 'my_lov', press 'next' three times and then finish. Create block using wizard. Don't display the ID field on the canvas, and create a non-database field which is displayed. Create a Post-Query trigger for this block. Add this code
begin
  select NAME
    into :table_2.item9
    from temp
   where ID = :table_2.field_3;
exception
  when no_data_found then
    :table_2.item9 := 'code missing';
  when others then
    :table_2.item9 := null;
end;

Now go back to the non-database field and add the LOV (it IS simpler to create the block before the Record_group and LOV but I have written it this way so you see the form from a maintenance versus build point of view). Go back to the LOV, click on the 'Column Mapping Porperties', for 'ID' define the 'Return Item' by using the 'Browse' button and select the database item that is NOT on the canvas and which you want populated (leave the display width as zero), select the 'NAME' column and set its 'Return Item' to the non-database field which is on the canvas. Click okay, save, and run. The non-database field displays the 'NAME' data. The LOV shows the 'NAME' data and returns the 'ID' data.

Hope this helps. I have attached the form in Forms 6. Below is the script to create the two tables and to populate them.

David

CREATE TABLE TABLE_2
(
  FIELD_1  VARCHAR2(5 BYTE),
  FIELD_2  VARCHAR2(5 BYTE),
  FIELD_3  NUMBER(5)
)
LOGGING 
NOCACHE
NOPARALLEL;

CREATE TABLE TEMP
(
  ID    NUMBER(3)                               NOT NULL,
  NAME  VARCHAR2(30 BYTE)                       NOT NULL
)
LOGGING 
NOCACHE
NOPARALLEL;

INSERT INTO TABLE_2 ( FIELD_1, FIELD_2, FIELD_3 ) VALUES ( 'A', 'AA', 1); 
INSERT INTO TABLE_2 ( FIELD_1, FIELD_2, FIELD_3 ) VALUES ( 'B', 'BB', 2); 
INSERT INTO TABLE_2 ( FIELD_1, FIELD_2, FIELD_3 ) VALUES ( 'C', 'CC', 3); 
INSERT INTO TABLE_2 ( FIELD_1, FIELD_2, FIELD_3 ) VALUES ( 'A', 'AA', 2); 
INSERT INTO TABLE_2 ( FIELD_1, FIELD_2, FIELD_3 ) VALUES ( 'B', 'BB', 1); 
INSERT INTO TABLE_2 ( FIELD_1, FIELD_2, FIELD_3 ) VALUES ( 'C', 'CC', 4); 
COMMIT;

CREATE UNIQUE INDEX PK_TEMP ON TEMP
(ID)
LOGGING
NOPARALLEL;

ALTER TABLE TEMP ADD (
  CONSTRAINT PK_TEMP PRIMARY KEY (ID));

INSERT INTO TEMP ( ID, NAME ) VALUES ( 1, 'aaa'); 
INSERT INTO TEMP ( ID, NAME ) VALUES ( 2, 'bbb'); 
INSERT INTO TEMP ( ID, NAME ) VALUES ( 3, 'ccc'); 
COMMIT;
  • Attachment: djm_t3.fmb
    (Size: 48.00KB, Downloaded 1052 times)

[Updated on: Sun, 09 October 2005 18:56]

Report message to a moderator

Previous Topic: animated timer in d2k forms
Next Topic: needed Coding
Goto Forum:
  


Current Time: Fri Sep 20 14:32:43 CDT 2024