Solved

Using more than one value for list item

Posted on 2014-09-17
9
204 Views
Last Modified: 2014-09-24
hi
i have form , there is trigger to fill items in the list box like this
 ADD_LIST_ELEMENT('LST_ALPHA',1,RPAD(RTRIM(bs.QTY),10,' ')||'- ' ||RPAD(RTRIM( to_char(bs.tr_date, 'dd-mm-yyyy')),15,' ')||'- ' ||RPAD(RTRIM(bs.av_cost),10,' ')||'- ' ||RPAD(RTRIM(bs.tr_no1),10,' ')||'- ' ||RPAD(RTRIM(bs.sup_name),20,' '),bs.tr_no1);
  	  

Open in new window


now the value of each item in the list box is equal to bs.tr_no1
i have another button in same form will call a database procedure to perform some codes required  additional values from this list item such as :
qty , tr-date , av-cost , sup_name
how i can get all those values in one time
0
Comment
Question by:NiceMan331
[X]
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
  • 6
  • 2
9 Comments
 

Author Comment

by:NiceMan331
ID: 40327962
I forget to explain that  table provided the items of list item don't have uniqu item , I mean I cannot select from it the related record depend of tran_no1 , it will not solve , only need all those values which cursor return it in the list item
0
 
LVL 35

Expert Comment

by:Mark Geerlings
ID: 40329134
We don't have enough information from you to answer your question.  

My first question is: is this type of Form item the best way to solve this business problem in Oracle Forms?  The easiest way to populate items in an Oracle Form is to use "text" items in a database block and have Forms populate them via a query of a table or view.  If you choose to use other item types, and/or have the items *NOT* be database items, that makes the programming you have to do in Forms *MUCH* more complex!

My second question is: since you say that the table you need to retrieve these values from doesn't have a unique key, how do you plan to retrieve these items?  We don't know your database table structure or your application.  What criteria can be used to retrieve these items from the database?
0
 

Author Comment

by:NiceMan331
ID: 40334076
ok , i got think about one solution , but i need the code
i will concatenate the value of list item, like this

bs.tr_no1|| '-' ||qty|| '-' || tr-date|| '-' || av-cost || '-' || sup_name

Open in new window


now when i used value of the list item in the procedure , how i can split that string and sliced it by 5 values considering '-' between each one , i think instr & susbtr ?
but how ?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 22

Expert Comment

by:Helena Marková
ID: 40338719
There are many better examples than this one is:
declare
s_var VARCHAR2(200);
s_var_1 VARCHAR2(200);
n_length  PLS_INTEGER;
n_pos  PLS_INTEGER;
n_pos_1   PLS_INTEGER;
BEGIN
s_var:='a111b-a22222b-a5555b-a6666666666b-a888888888888888888b';
dbms_output.put_line(s_var);
n_pos_1:=1;
for i in 1 .. 4 loop
  n_pos:=instr(s_var,'-',1,i);
  n_length:= n_pos- n_pos_1;
  s_var_1:=substr(s_var,n_pos_1,n_length);
  dbms_output.put_line(s_var_1);
  n_pos_1:=n_pos + 1;
  IF i=4 THEN
    s_var_1:=substr(s_var,n_pos_1);
    dbms_output.put_line(s_var_1);  
  END IF;
end loop;
end;

This is an idea, you can write your own function.
0
 

Author Comment

by:NiceMan331
ID: 40338725
Thanx , let me try it
0
 

Author Comment

by:NiceMan331
ID: 40338941
yes correct
final question
your code answered my question if i know that i have 4 variables , ok , but in general , if i don't know how many variables , how can replace instead of 4 by x ?
0
 
LVL 22

Accepted Solution

by:
Helena Marková earned 500 total points
ID: 40339003
Here are some modifications:
declare
 s_var VARCHAR2(200);
 s_var_1 VARCHAR2(200);
 n_length  PLS_INTEGER;
 n_pos  PLS_INTEGER;
 n_pos_1   PLS_INTEGER;
 n_occurance  PLS_INTEGER;
 n_length_var  PLS_INTEGER;
 BEGIN
 s_var:='a111b-a22222b-a5555b-a6666666666b-a888888888888888888b-a44444b';
 dbms_output.put_line(s_var);
 n_length_var:=length(s_var);
 n_occurance:=0;
 FOR j in 1 .. n_length_var loop
  IF instr(s_var,'-',1,j)>0 THEN
    n_occurance:=n_occurance + 1;
  END IF;
 end loop;
 dbms_output.put_line(n_occurance);
 n_pos_1:=1;
 for i in 1 .. n_occurance loop
   n_pos:=instr(s_var,'-',1,i);
   n_length:= n_pos- n_pos_1;
   s_var_1:=substr(s_var,n_pos_1,n_length);
   dbms_output.put_line(s_var_1);
   n_pos_1:=n_pos + 1;
   IF i=n_occurance THEN
     s_var_1:=substr(s_var,n_pos_1);
     dbms_output.put_line(s_var_1);  
   END IF;
 end loop;
 end;
0
 

Author Comment

by:NiceMan331
ID: 40340880
sorry henka
the output not working with me
so please give me small time to solve this issue
http://www.experts-exchange.com/Software/Misc/Q_28524421.html
thanx alot
0
 

Author Comment

by:NiceMan331
ID: 40341190
yes henka
it is correct\
thanx
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
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.

690 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