Home » Developer & Programmer » Forms » Forms error
Forms error [message #191629] |
Thu, 07 September 2006 06:26 |
orafan2003
Messages: 122 Registered: February 2006
|
Senior Member |
|
|
Hi,
I have a function called getTaskLength to get the length of a string. I pass a value called 'user1' into the webservice and the webservice has to return a value ie a number which is the length.
declare
jo ora_java.jobject;
rv ora_java.jobject;
begin
jo:=TasksModuleServiceStub.new;
rv:=TasksModuleServiceStub.getTaskLength(jo,'user1');
--:tasklist.text_item41:=rv; --> This is where I am getting the error
end;
The error is: "Expression is of wrong type"
How can I fix this error?
[Updated on: Mon, 11 September 2006 02:51] by Moderator Report message to a moderator
|
|
|
|
Re: Forms error [message #191834 is a reply to message #191755] |
Fri, 08 September 2006 05:28 |
orafan2003
Messages: 122 Registered: February 2006
|
Senior Member |
|
|
Hi,
This is the code in when-button-pressed
DECLARE
jo ora_java.jobject;
applicationlist ORA_JAVA.JARRAY;
ex ora_java.jobject;
listLength NUMBER;
loanString VARCHAR2(30000);
delimiterPos NUMBER;
BEGIN
jo:=TasksModuleServiceStub.new;
applicationlist := TasksModuleServiceStub.getTasks(jo,'user1');
-- How many strings did the Java return?
listLength := ORA_JAVA.GET_ARRAY_LENGTH(applicationlist);
-- For each string, extract the details
for i in 1..listLength loop
-- Get element i from the array of strings.
loanString := ORA_JAVA.GET_STRING_ARRAY_ELEMENT(applicationlist, i);
-- Parse the string looking for the '@' character to get each field.
delimiterPos := instr(loanString, '@');
:ssn := substr(loanString, 1, delimiterPos-1);
loanString := substr(loanString, delimiterPos+1);
delimiterPos := instr(loanString, '@');
:taskid := substr(loanString, 1, delimiterPos-1);
end loop;
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));
WHEN others then
ex := ORA_JAVA.LAST_EXCEPTION;
message('Exception2: '||Exception_.toString(ex));
end;
I am getting an error at runtime.
java.lang.ArrayIndexOutOfBoundsException
Why does this error occur and what should I do to fix it?
Kindly guide me.
[Updated on: Mon, 11 September 2006 02:55] by Moderator Report message to a moderator
|
|
|
Re: Forms error [message #191853 is a reply to message #191834] |
Fri, 08 September 2006 06:54 |
orafan2003
Messages: 122 Registered: February 2006
|
Senior Member |
|
|
Hi I just fixed this error
by making small changes in the code
for i in 0..listLength-1 loop
I am using the above code to send a value called "user1" from my form and trying to retrieve array of values of this format from the webservice.
12341234@@@paul@@@loan@@@34
12341235@@@jones@@@loan@@@45
12341236@@@peter@@@loan@@@98
My code seems to be right but none of the values are getting retrieved.
So I wrote another code to find out how many records are coming from the webservice.
It is like this
declare
jo ora_java.jobject;
rv ora_java.jobject;
ex ora_java.jobject;
numberOfApplications number;
begin
jo:=TasksModuleServiceStub.new;
rv:=TasksModuleServiceStub.getTaskLength(jo,'user1');
numberOfApplications := ORA_JAVA.GET_ARRAY_LENGTH(rv);
:tasklist.text_item41:=numberOfApplications;
end;
This code works and I am able to get the value "3".
What is the problem with my previous code that I am not able to retrieve values? I am only able to get the number of records but not able to retrieve the records.
Kindly help.
[Updated on: Mon, 11 September 2006 02:56] by Moderator Report message to a moderator
|
|
|
|
Re: Forms error [message #192156 is a reply to message #192134] |
Mon, 11 September 2006 05:24 |
orafan2003
Messages: 122 Registered: February 2006
|
Senior Member |
|
|
Sir,
I haven't solved my problem.
Now I am able to get the entire string like this when I send "user1".
"bpel://localhost/default/BANK_804~1.0/14637-BpInv1-BpSeq1.6-2@@@USER1_THEBANK@@@LOAN@@@12341234@@@Robert Jones"
"bpel://localhost/default/BANK_804~1.0/14642-BpInv1-BpSeq1.6-2@@@USER1_THEBANK@@@LOAN@@@11112222@@@Shyla James"
From the above string, I have to get values like this in text items.
1) 12341234,11112222
2) Robert Jones,Shyla James
3) LOAN,LOAN
4) USER1_THEBANK,USER1_THEBANK
I am able to get only one set of values(only 2 values though..I am still writing the code) though I used a loop. Sir, what is the problem with my code that I am not able to get array of values?
This is the code.
DECLARE
jo ora_java.jobject;
applicationlist ORA_JAVA.JARRAY;
ex ora_java.jobject;
listLength NUMBER;
loanString VARCHAR2(30000);
delimiterPos NUMBER;
BEGIN
jo:=TasksModuleServiceStub.new;
-- Call out to Java to get the list of loan applications to be approved.
applicationlist := TasksModuleServiceStub.getTasks(jo,'user1');
-- How many strings did the Java return?
listLength := ORA_JAVA.GET_ARRAY_LENGTH(applicationlist);
-- For each string, extract the details of the loan.
for i in 0..listLength-1 loop
-- Get element i from the array of strings.
loanString := ORA_JAVA.GET_STRING_ARRAY_ELEMENT(applicationlist, i);
-- Parse the string looking for the '@' character to get each field.
delimiterPos := instr(loanString, '@');
:tasklist.ssn := substr(loanString, 1, delimiterPos-1);
loanString := substr(loanString, delimiterPos+1);
delimiterPos := instr(loanString, '@');
:tasklist.cname := substr(loanString, 1, delimiterPos-1);
loanString := substr(loanString, delimiterPos+1);
delimiterPos := instr(loanString, '@');
:tasklist.ptype := substr(loanString, 1, delimiterPos-1);
loanString := substr(loanString, delimiterPos+1);
delimiterPos := instr(loanString, '@');
:tasklist.taskid := substr(loanString, 1, delimiterPos-1);
end loop;
Thank you.
[Updated on: Tue, 12 September 2006 02:52] by Moderator Report message to a moderator
|
|
|
Re: Forms error [message #192412 is a reply to message #192156] |
Tue, 12 September 2006 04:17 |
orafan2003
Messages: 122 Registered: February 2006
|
Senior Member |
|
|
Hi, I just simplified my code to find out of I am able to retrieve both the strings or not.
DECLARE
jo Ora_java.Jobject;
ApplicationList Ora_java.JarRay;
ex Ora_java.Jobject;
ListLength NUMBER;
LoanString VARCHAR2(30000);
Delimiterpos NUMBER;
BEGIN
jo := TasksModuleServiceStub.New;
ApplicationList := TasksModuleServiceStub.GetTasks(jo,'user1');
ListLength := Ora_java.Get_Array_Length(ApplicationList); ---returning 2 ie the number of records
FOR i IN 0.. ListLength LOOP
LoanString := Ora_java.Get_String_Array_Element(ApplicationList,i); ---the string that I get from webservice
:text_item43 := LoanString;
END LOOP;
END;
For the text_item43 I set Number of records displayed to 4.
But I am able to view only the second string and not the first one.
Is there any error in my code?
Upd-Mod: You haven't got the hint about formatting your text have you?
[Updated on: Tue, 12 September 2006 21:29] by Moderator Report message to a moderator
|
|
|
|
Re: Forms error [message #192746 is a reply to message #192572] |
Wed, 13 September 2006 07:45 |
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; Upd-Mod: Please only post formatted code and IN CODE TABS!!
[Updated on: Thu, 14 September 2006 20:17] by Moderator Report message to a moderator
|
|
|
Re: Forms error [message #193087 is a reply to message #192746] |
Thu, 14 September 2006 20:24 |
|
djmartin
Messages: 10181 Registered: March 2005 Location: Surges Bay TAS Australia
|
Senior Member Account Moderator |
|
|
You have a 'loop' statement. You have to do the work INSIDE the loop. That means either doing an assignment to the block items in the loop and using a 'next_record' to go to the next record OR doing the 'insert' command. The 'commit' can be either inside or outside the loop. Try the following and tell me whether it works.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);
insert into test_bank
values (TASKID,
ASSIGNEE,
PTYPE,
SSN,
CNAME);
end loop;
standard.commit;
end if;
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;
By the way, do you want the records from the previous time that the form was run to still be in the table or should you truncate the table before loading the new records?
David
|
|
|
Re: Forms error [message #193157 is a reply to message #193087] |
Fri, 15 September 2006 01:55 |
orafan2003
Messages: 122 Registered: February 2006
|
Senior Member |
|
|
Sir,
Thanks a lot!! My form is working fine.It is getting values from the webservice and also sending values into it. I put my insert statement in the loop as you said.
I also included a delete statement with commit so that the old values are deleted. My task is successfully completed!! Sir..Thank you for your guidance.
Regards, Suj
|
|
|
Goto Forum:
Current Time: Sun Feb 02 03:49:35 CST 2025
|