Home » Developer & Programmer » Forms » Populate values in form fields
Populate values in form fields [message #192463] Tue, 12 September 2006 08:46 Go to next message
orafan2003
Messages: 122
Registered: February 2006
Senior Member
Hi,
I want my form fields to be populated from a database table.
The table has 10 records. In my form I wrote in "when-new-form-instance"

select taskid,ptype,assignee into :text_item43,:ptype,:assignee from test_bank where ...
I am actually getting confused here.How should my "where" condition be?
As I have to get multi-records, I have to use a loop. I am not very clear on how to do..Can anyone guide me?
Re: Populate values in form fields [message #192504 is a reply to message #192463] Tue, 12 September 2006 12:01 Go to previous messageGo to next message
gopi_ora
Messages: 13
Registered: August 2006
Location: Bangalore
Junior Member
Hi,
You can try this out.
Begin
for i in (select taskid,ptype,assignee from test_bank where <your where condition>)
loop
:text_item43 := i.taskid;
:ptype := i.ptype;
:assignee := i.assignee;
next_record;
end loop;

Hope this help.

Thanks
Re: Populate values in form fields [message #192604 is a reply to message #192504] Tue, 12 September 2006 23:44 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Aahh! Just base the block on the table and do an 'execute_query' in the WNFI trigger. That's all you have to do!!

David
Re: Populate values in form fields [message #192725 is a reply to message #192504] Wed, 13 September 2006 06:25 Go to previous messageGo to next message
orafan2003
Messages: 122
Registered: February 2006
Senior Member
Hi ,
I used the code but it is returning me 96 values instead of 2 values.
What can be done now?

>>Aahh! Just base the block on the table and do >>an 'execute_query' in the WNFI trigger. That's all you have to >>do!!


Sir..Actually the block is not based on the table. It is getting some values from the test_bank table.
Regards,
Suj
Re: Populate values in form fields [message #192747 is a reply to message #192725] Wed, 13 September 2006 07:45 Go to previous messageGo to next message
orafan2003
Messages: 122
Registered: February 2006
Senior Member
Hi,
This is my actual query in when-new-form-instance. My form is like this. I am sending a value called "user1" into the webservice and the webservice is returning me an array of values. I put those 5 values in 5 text items but when I run my form, I am able to view only the last row of 5 values. May be the values are getting over-writte. So I am sending these returned values to a table called test_bank. From this table, I want to retrieve the multiple records.
As of now the webservice is returning only 2 values but I am getting 100 values all repetetions. Can u plz correct my code?
Now I based the block on the test_bank table.
DECLARE
jo ora_java.jobject;
applicationlist ORA_JAVA.JARRAY;
ex ora_java.jobject;
numberOfApplications NUMBER;
order_string VARCHAR2(30000);
delimiter_Pos NUMBER;

TASKID varchar2(2000);
ASSIGNEE varchar2(300);
PTYPE varchar2(100);
SSN number;
CNAME varchar2(1000);

BEGIN
jo:=TasksModuleServiceStub.new;
applicationlist := TasksModuleServiceStub.getTasks(jo,'user1');

numberOfApplications := ORA_JAVA.GET_ARRAY_LENGTH(applicationlist);

if numberOfApplications > 0 then
for i in 0..numberOfApplications-1 loop
order_string := ORA_JAVA.GET_STRING_ARRAY_ELEMENT(applicationList,i);

delimiter_Pos := instr(order_string, '@');
taskid := substr(order_string, 1, delimiter_Pos-1);

order_string := substr( order_string, delimiter_Pos+1);
delimiter_Pos := instr( order_string, '@');
ssn := substr( order_string, 1, delimiter_Pos-1);

order_string := substr( order_string, delimiter_Pos+1);
delimiter_Pos := instr( order_string, '@');
cname := substr( order_string, 1, delimiter_Pos-1);

order_string := substr( order_string, delimiter_Pos+1);
delimiter_Pos := instr( order_string, '@');
assignee := substr( order_string, 1, delimiter_Pos-1);

order_string := substr( order_string, delimiter_Pos+3);
delimiter_Pos := instr( order_string, '@');
ptype := substr( order_string, 1, delimiter_Pos-1);

end loop;
end if;
insert into test_bank values(TASKID,ASSIGNEE,PTYPE,SSN,CNAME);
next_record;
standard.commit;

go_block('test_bank');
execute_query;

EXCEPTION
WHEN ORA_JAVA.JAVA_ERROR then
message('Unable to call out to Java, ' ||ORA_JAVA.LAST_ERROR);
WHEN ORA_JAVA.EXCEPTION_THROWN then
ex := ORA_JAVA.LAST_EXCEPTION;
message(Exception_.toString(ex));
END;
Re: Populate values in form fields [message #192883 is a reply to message #192747] Thu, 14 September 2006 01:30 Go to previous messageGo to next message
orafan2003
Messages: 122
Registered: February 2006
Senior Member
Hi,
Can anyone please guide me....I am inserting only one/two values into my table but while retrieving I am getting duplicate values...totally 70 values.
What is the error in my code?
Re: Populate values in form fields [message #193102 is a reply to message #192883] Thu, 14 September 2006 21:29 Go to previous message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
This question is active in another thread.

David
Previous Topic: Synonym do not support on forms 6i using 10g database
Next Topic: Show and hide frame with a button.
Goto Forum:
  


Current Time: Fri Sep 20 12:37:23 CDT 2024