Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to link a function with jsp code  RSS feed

 
venkatram reddy
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Sir,
I have a jsp code with slope field. This slope field is a list box with values as follows:
0-2%
10-15%
15-25%
2-6%
25-50%
6-10%
greater than 50%
Now I have to sort the values in the following order:
0-2%
2-6%
6-10%
10-15%
15-25%
25-50%
So at the back end I have the following code:
create or replace function length_numeric(p_string varchar2)
return number
is
numeric_error exception;
pragma exception_init(numeric_error, -6502);
v_var number;
begin
for i in 1..length(p_string) loop
begin
v_var:=to_number(substr(p_string,1,i));
exception when numeric_error then return i-1;
end;
end loop;
return length(p_string);
exception when others then return -1;
end;

with code_slope as
(select '0-2%' from dual union all
select '10-15%' from dual union all
select '15-25%' from dual union all
select '2-6%' from dual union all
select '25-60%' from dual union all
select '6-10%' from dual union all
select 'greater than 50%' c1 from dual)
select c1
from
(select c1,format_numeric(c1,max(length(c1)) over ()) as c2 from code_slope)order by c2 asc;

When I execute both of them at the database end I could sort the values. But in the jsp for that particular field, I have the following code:
//look up Slope List
strSQL ="select Slope_code value, item display from code_Slope order by 2" ;
//out.println(strSQL);
db.setSQL( strSQL ) ;
db.query() ;
SlopeVector = db.getSelectionList() ;

Now I want to replace this code with the result obtained from the above written code, so that I can find the sorted values in the list box of slope field on the form.
Could any one let me know how to call these two functions within the jsp so that I can see the sorted values in the list box?
Waiting for reply!
Venkatram reddy
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Although, You can use CallableStatement. But I think you need to re-think your design.

You can use id to sort the values in your java code, I believe.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!