Can java method return multiple values
hey , I need big favor can i return two arrays in a single function
Not directly no.
But there are ways around it.
You can create a "result object" which has attributes being the two arrays, and return that object (ie wrap the arrays in another object)
You could put the arrays into a collection (eg ArrayList/Vector) and then return that object. You can then retrieve the two arrays as the first two items in that list.
Either of those should work, even if they are hacks ;-)
Cheers,
evnafets
Similar Messages
-
Can a method return multiple items
Can a method return more than one thing?
I want to have a method return a boolean and a String. My method is saying if something is right or wrong, then its saying the reason why.
help, please.
ThanxAfternoon_Delight wrote:
My question is:
Is there a way so that it can be more like this:
public boolean, String checkValidity (){
To expand on the previous posts, one way (not saying it's the best one!) is to create an object that combines the information that you want returned:
public class MyValid
private boolean valid;
private String text;
public MyValid(boolean valid, String text)
this.valid = valid;
this.text = text;
public boolean isValid()
return valid;
public String getText()
return text;
class DoFoo
public MyValid checkValidity()
return new MyValid(false, "Because I said so!");
} -
Can a method return a class ?
hi,
i have a simple question.
can a method return class value ?
in the below script i did'nt understand the commented line.
package com.google.gwt.sample.stockwatcher.client;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
@RemoteServiceRelativePath("login")
public interface LoginService extends RemoteService {
public LoginInfo login(String requestUri); //What is this ? is this a sample of what i asked ?
}The answer to your question is yes.
The idea is that an object calls a function of another object (passing in objects to the function as arguments) in which that object returns an object (note the arguments or returned value of the function may alternately be primitive types). Each object typically encapsulates data and provides a rich set of functions to the calling object so that calling object doesn't have to deal with the raw data directly. Therefore, not only does the calling object get the data it wants, but also a rich set of functions that can manipulate that data.
Example:
Book book = new Book();
int characterCount = book.getChapter(3).getParagraph(4).getSentence(12).getWord(8).getCharacterCount();
In the above, each object (Book, Chapter,Paragraph,Sentence,Word) has a rich set of functions it provides to its caller.
Example: the Sentence Object has a collection of word objects (raw data). Functions it provides to Paragraph object are:
Word getWord(int index), Words getWords(), int getWordCount().
If you haven't already done so, I suggest reading a book on Java from cover to cover to pick up such Object Oriented concepts. -
Return multiple values from a web method??
Hi,
I am wondering if it's possible for a web method to return multiple values to a client. I know each web method can return only one value of a given data type. I am looking for something like ref or out keyword in C#. If it's not available, is there any workaround? Thanks.
RegardsJava web service endpoints can return multiple values by using the javax.xml.rpc.holders classes. The following post might help:
http://forum.java.sun.com/thread.jspa?threadID=684916
If you'll be returning lots of values, it might be worth considering a document-style implementation rather than RPC-style. -
SSAS- DAX expression : Is there any DAX function that can return multiple values ?
Hi,
Iam in search of a DAX function that can return multiple values as result. please find below scenario where i want to implement the same.
I have three Tables: Table A (typeid, Cost, Qty ) ,Table B (typeid, Cost, Qty ) , Table C ( typeid,Typename ) .
Table A Table B
Table C
type id cost Qty type id Cost Qty
typeid typename
1 100 100 3 300
300 1 aa
2 200 200 4 400
400 2 bb
3 cc
4
dd
i have to club cost and Qty of two tables(four measures) as two measures in the UI report. There are more columns in these tables that restrict the UNION of the tables.(for the sake
of understanding , i have not mentioned the othr columns). In the UI report(Execl 2013-power pivot) iam plotting these measures against the
Table C.Typeid. Hence the measures drill down against each
Table C. Typeid as shown below:
Typeid Table A.cost Table A.Qty TableB.cost TableB.Qty
1 100 100
2 200 200
3
300 300
4
400 400
My requirement is to club these measures so that the report will be as below
Type id cost Qty
1 100 100
2 200 200
3 300 300
4 400 400
Since i cannot club these in model,as a work around, i created a calculated measure in excel(Analyze tab->Calculations->olap tools->calculated measure) with the condition as below:
new cost = IIF (ISEMPTY(TableA.cost)="TRUE",TableB.cost,TableA.cost)
new Qty = IIF(ISEMPTY(TableA.Qty)="TRUE",TableB.Qty,TableA.Qty) and dragged these new measures into the report. It was working fine as expected.
But this functionality of Creating calculatedmeasure in excel report is possible only in 2013 excel version.
Now the requirement is to get the same result in 2010 excel. Can you please help me in implementing the same in 2010 excel? or any other alternative method to bring the columns in model itself. I tried to create a measure in table A with DAX expression as
: new cost :=CALCULATE(SUM(Table B.cost),ISBLANK(TableA.cost)) -> but this will return only 1 result .i need Sum(Table A.cost) also if it is not blank.
Thanks in advanceYou can use SUMX ( 'Table A', 'Table A'[Cost] + 'Table B'[cost] )
However, if you install the latest version of Power Pivot in Excel 2010, it supports the ISEMPTY function, too.
http://support.microsoft.com/kb/2954099/en-us
Marco Russo http://www.sqlbi.com http://www.powerpivotworkshop.com http://sqlblog.com/blogs/marco_russo -
How can IWD_VALUE_HELP return multiple values, instead of one
Hello expert,
I have requirement to use F4 help to return multiple values to the using WD component. Basically in my main WD component, I have a View where I have a list box, this list box has a F4 assigned to it, clicking on the F4 brings up hte F4 help, in the F4 help, user can select multiple values which should be returned to my main component / view to be displayed in the list box.
I'd implement IWD_VALUE_HELP to create my own F4 help component. However I have difficulty to return multiple values. As I understand there is only way to return data from F4 help to the calling Main WD component / view:
Item_LISTENER->F4_CONTEXT_ELEMENT->set_attribute( name = 'MYATTRName' value = myvalue).
Do you guys know how to archive what is required here?
Thanks
JaysonHello Jayson,
the element reference that is passed into the IWD_VALUE_HELP implementing component is the element of the calling application's context.
Therefore you can use methods like
IF_WD_CONTEXT_ELEMENT->GET_NODE
(to get the parent node of the element) and
IF_WD_CONTEXT_ELEMENT->GET_CHILD_NODE
to get access to other parts of the context.
say for example your value help should populate a pop-in table with multiple entries.
your application allows you to choose a type of ice-cream cone and then to choose the flavour of ice-cream (multi selection)has a structure like:
Context_root
--> List_of_ice_creams (0..n)
>Ice_cream_flavours(1..n)
In the element of list_of_ice_creams you have an attribute "flavour" which links to your value help.
Choosing this value-help should allow you to select multiple flavours, return these and populate them into the sub-node Ice_cream_flavours.
Within your custom value help you can get a reference to the node Ice_cream_flavours by calling the method
lo_flavour_node = IItem_LISTENER->F4_CONTEXT_ELEMENT->GET_CHILD_NODE("ICE_CREAM_FLAVOURS"). You could then populate this in you value help component.
As I mentioned - this isn't great as it means the value help cannot really be used elsewhere as it has a dependency on the structure of the calling context. But that may not be an issue for you.
Hope that helps,
Chris -
How can I return multiple values with PL/SQL Web Services
Hi,
I'm new to developping Web Services. I'm doing some tests with JDeveloper and OC4J on my local machine with a Web Services based on a PL/SQL function within a package. Right now that function only returns one value. So the xml response only has one output.
I'd like to know how can I return multiple values with my PL/SQL Web Service. For example, if I want to return an employee's name and id? And that the xml contains two output : <employee>, <empid>?
Reginald
ps : I have searched the forum and I couldn't find an answer to this question, if that has been discussed AND answered before, can you please post the link? ThanksAlright, I actually found my answer. Since this was asked I think as a followup somewhere else I'll give my answer.
It is very simple, all you have to do is create an Object Type and then Return that object type. After that, JDeveloper will take care of everything and you will have an xml response with multiple values. Here
{color:#ff0000}
create or replace TYPE person AS OBJECT
( id_interv number,
first_name VARCHAR2(50),
last_name VARCHAR2(50),
date_birth date
);{color}
Then your function used in your Web Service should look something like this :
{color:#ff0000}
function info_emp (p_empno IN VARCHAR2) RETURN person AS
l_emp person := person(-1,'','','');
BEGIN
SELECT first_name
,last_name
,emp_no
INTO l_emp.first_name
,l_emp.last_name
,l_emp.emp_no
FROM emp
WHERE upper(emp_no) = upper (emp_no);
{color}
{color:#ff0000}
RETURN l_emp;
EXCEPTION WHEN NO_DATA_FOUND THEN
l_emp := person (-1,'n/a','n/a','n/a');
RETURN l_emp ;
END info_emp;{color}
{color:#ff0000}{color:#000000}After that, this is what the xml response looks like :{color}{color}
<first_name xsi:type="xsd:string">John</first_name>
<last_name xsi:type="xsd:string">Doe</last_name>
<emp_no xsi:type="xsd:string">0250193</emp_no> -
Function which returns multiple values that can then be used in an SQL Sele
I'd like to create a function which returns multiple values that can then be used in an SQL Select statement's IN( ) clause
Currently, the select statement is like (well, this is a very simplified version):
select application, clientid
from tbl_apps, tbl_status
where tbl_apps.statusid = tbl_status.statusid
and tbl_status.approved > 0;
I'd like to pull the checking of the tbl_status into a PL/SQL function so my select would look something like :
select application, clientid
from tbl_apps
where tbl_apps.statusid in (myfunction);
So my function would be running this sql:
select statusid from tbl_status where approved > 0;
... will return values 1, 5, 15, 32 (and more)
... but I haven't been able to figure out how to return the results so they can be used in SQL.
Thanks for any help you can give me!!
Trisha GorrPerhaps take a look at pipelined functions:
Single column example:
SQL> CREATE OR REPLACE TYPE split_tbl IS TABLE OF VARCHAR2(32767);
2 /
Type created.
SQL> CREATE OR REPLACE FUNCTION split (p_list VARCHAR2, p_delim VARCHAR2:=' ') RETURN SPLIT_TBL PIPELINED IS
2 l_idx PLS_INTEGER;
3 l_list VARCHAR2(32767) := p_list;
4 l_value VARCHAR2(32767);
5 BEGIN
6 LOOP
7 l_idx := INSTR(l_list, p_delim);
8 IF l_idx > 0 THEN
9 PIPE ROW(SUBSTR(l_list, 1, l_idx-1));
10 l_list := SUBSTR(l_list, l_idx+LENGTH(p_delim));
11 ELSE
12 PIPE ROW(l_list);
13 EXIT;
14 END IF;
15 END LOOP;
16 RETURN;
17 END SPLIT;
18 /
Function created.
SQL> SELECT column_value
2 FROM TABLE(split('FRED,JIM,BOB,TED,MARK',','));
COLUMN_VALUE
FRED
JIM
BOB
TED
MARK
SQL> create table mytable (val VARCHAR2(20));
Table created.
SQL> insert into mytable
2 select column_value
3 from TABLE(split('FRED,JIM,BOB,TED,MARK',','));
5 rows created.
SQL> select * from mytable;
VAL
FRED
JIM
BOB
TED
MARK
SQL>Multiple column example:
SQL> CREATE OR REPLACE TYPE myrec AS OBJECT
2 ( col1 VARCHAR2(10),
3 col2 VARCHAR2(10)
4 )
5 /
Type created.
SQL>
SQL> CREATE OR REPLACE TYPE myrectable AS TABLE OF myrec
2 /
Type created.
SQL>
SQL> CREATE OR REPLACE FUNCTION pipedata(p_str IN VARCHAR2) RETURN myrectable PIPELINED IS
2 v_str VARCHAR2(4000) := REPLACE(REPLACE(p_str, '('),')');
3 v_obj myrec := myrec(NULL,NULL);
4 BEGIN
5 LOOP
6 EXIT WHEN v_str IS NULL;
7 v_obj.col1 := SUBSTR(v_str,1,INSTR(v_str,',')-1);
8 v_str := SUBSTR(v_str,INSTR(v_str,',')+1);
9 IF INSTR(v_str,',')>0 THEN
10 v_obj.col2 := SUBSTR(v_str,1,INSTR(v_str,',')-1);
11 v_str := SUBSTR(v_str,INSTR(v_str,',')+1);
12 ELSE
13 v_obj.col2 := v_str;
14 v_str := NULL;
15 END IF;
16 PIPE ROW (v_obj);
17 END LOOP;
18 RETURN;
19 END;
20 /
Function created.
SQL>
SQL> create table mytab (col1 varchar2(10), col2 varchar2(10));
Table created.
SQL>
SQL> insert into mytab (col1, col2) select col1, col2 from table(pipedata('(1,2),(2,3),(4,5)'));
3 rows created.
SQL>
SQL> select * from mytab;
COL1 COL2
1 2
2 3
4 5 -
How to return multiple values from dialog popup
hi all
I'm using ADF 10g. I have a requirement that I have to return multiple values from a dialog.
I have a page containing a table with a button which calls the dialog. The dialog contains a multi-select table where i want to select multiple records and add them to the table in the calling page.
In the backing bean of the calling page, I have the returnListener method.
I am thinking that I have to store the selected rows from dialog in an array and return that array to the returnListener...but I don't know how to go about it with the code.
Can someone help me out with it?
thanksHi Frank,
I'm trying to implement your suggestion but getting comfused.
AdfFacesContext.getCurrentInstance().returnFromDialog(null, hashMap) is called in ActionListener method, from what I understood.
ReturnListener method already calls it, so no need to call explicitly.
Okay here's what i'm doing.
command button launches the dialog on the calling page.
In the dialog page, there is a button "select", which when i click, closes the dialog and returns to calling page. I put a af:returnActionListener on this button, which logically should have a corresponding ReturnListener() in the calling page backing bean.
Now I have 3 questions:
1. do i have to use ActionListener or ReturnListener?
2. where do I create the hashMap? Is it in the backing bean of the dialog or in the one of calling page?
3. how do I retrieve the keys n values from hashmap?
please help! thanks
This is found in the backing bean of calling page:
package mu.gcc.dms.view.bean.backing;
import com.sun.java.util.collections.ArrayList;
import com.sun.java.util.collections.HashMap;
import com.sun.java.util.collections.List;
import java.io.IOException;
import java.util.Map;
import javax.faces.application.Application;
import javax.faces.application.ViewHandler;
import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;
import javax.faces.el.ValueBinding;
import javax.faces.event.ActionEvent;
import mu.gcc.dms.model.services.DMSServiceImpl;
import mu.gcc.dms.model.views.SiteCompaniesImpl;
import mu.gcc.dms.model.views.SiteCompaniesRowImpl;
import mu.gcc.dms.model.views.lookup.LkpGlobalCompaniesImpl;
import mu.gcc.util.ADFUtils;
import mu.gcc.util.JSFUtils;
import oracle.adf.model.BindingContext;
import oracle.adf.model.binding.DCBindingContainer;
import oracle.adf.model.binding.DCIteratorBinding;
import oracle.adf.view.faces.context.AdfFacesContext;
import oracle.adf.view.faces.event.ReturnEvent;
import oracle.adf.view.faces.model.RowKeySet;
import oracle.binding.AttributeBinding;
import oracle.binding.BindingContainer;
import oracle.binding.OperationBinding;
import oracle.jbo.AttributeDef;
import oracle.jbo.Key;
import oracle.jbo.Row;
import oracle.jbo.RowIterator;
import oracle.jbo.RowSetIterator;
import oracle.jbo.domain.Number;
import oracle.jbo.server.java.util.Iterator;
public class CompanyList {
private BindingContainer bindings;
private Map hashMap;
DMSServiceImpl service =(DMSServiceImpl)ADFUtils.getDataControlApplicationModule("DMSServiceDataControl");
SiteCompaniesImpl siteCompanyList = service.getSiteCompanies();
LkpGlobalCompaniesImpl globalCompanyList = service.getLkpGlobalCompanies();
public CompanyList() {
public BindingContainer getBindings() {
return this.bindings;
public void setBindings(BindingContainer bindings) {
this.bindings = bindings;
*public void setHashMap(Map hashMap) {*
*// hashMap = (Map)new HashMap();*
this.hashMap = hashMap;
*public Map getHashMap() {*
return hashMap;
public String searchCompanyButton_action() {
BindingContainer bindings = getBindings();
OperationBinding operationBinding =
bindings.getOperationBinding("Execute");
Object result = operationBinding.execute();
if (!operationBinding.getErrors().isEmpty()) {
return null;
return null;
*public void addCompanyActionListener(ActionEvent actionEvent){*
AdfFacesContext.getCurrentInstance().returnFromDialog(null, hashMap);
public void addCompanyReturnListener(ReturnEvent returnEvent){
//how to get hashmap from here??
public String addCompanyButton_action() {
return "dialog:globalLovCompanies";
} -
[UIX] How To: Return multiple values from a LOV
Hi gang
I've been receiving a number of queries via email on how to return multiple items from a LOV using UIX thanks to earlier posts of mine on OTN. I'm unfortunately aware my previous posts on this are not that clear thanks to the nature of the forums Q&A type approach. So I thought I'd write one clear post, and then direct any queries to it from now on to save me time.
Following is my solution to this problem. Please note it's just one method of many in skinning a cat. It's my understanding via chatting to Oracle employees that LOVs are to be changed in a future release of JDeveloper to be more like Oracle Forms LOVs, so my skinning skills may be rather bloody & crude very soon (already?).
I'll base my example on the hr schema supplied with the standard RDBMS install.
Say we have an UIX input-form screen to modify an employees record. The employees record has a department_id field and a fk to the departments table. Our requirement is to build a LOV for the department_id field such that we can link the employees record to any department_id in the database. In turn we want the department_name shown on the employees input form, so this must be returned via the LOV too.
To meet this requirement follow these steps:
1) In your ADF BC model project, create 2 EOs for employees and departments.
2) Also in your model, create 2 VOs for the same EOs.
3) Open your employees VO and create a new attribute DepartmentName. Check selected in query. In expressions type (SELECT dept.department_name FROM departments dept WHERE dept.department_id = employees.department_id). Check Updateable always.
4) Create a new empty UIX page in your ViewController project called editEmployees.uix.
5) From the data control palette, drag and drop EmployeesView1 as an input-form. Notice that the new field DepartmentName is also included in the input-form.
6) As the DepartmentName will be populated either from querying existing employees records, or via the LOV, disable the field as the user should not have the ability to edit it.
7) Select the DepartmentId field and delete it. In the UI Model window delete the DepartmentId binding.
8) From the data controls palette, drag and drop the DepartmentId field as a messageLovInput onto your page. Note in your application navigator a new UIX page lovWindow0.uix (or similar) has been created for you.
9) While the lovWindow0.uix is still in italics (before you save it), rename the file to departmentsLov.uix.
10) Back in your editEmployees.uix page, your messageLovInput source will look like the following:
<messageLovInput
model="${bindings.DepartmentId}"
id="${bindings.DepartmentId.path}"
destination="lovWindow0.uix"/>Change it to be:
<messageLovInput
model="${bindings.DepartmentId}"
id="DepartmentId"
destination="departmentsLov.uix"
partialRenderMode="multiple"
partialTargets="_uixState DepartmentName"/>11) Also change your DepartmentName source to look like the following:
<messageTextInput
id=DepartmentName
model="${bindings.DepartmentName}"
columns="10"
disabled="true"/>12) Open your departmentsLov.uix page.
13) In the data control palette, drag and drop the DepartmentId field of the DepartmentView1 as a LovTable into the Results area on your page.
14) Notice in the UI Model window that the 3 binding controls have been created for you, an iterator, a range and a binding for DepartmentId.
15) Right click on the DepartmentsLovUIModel node in the UI Model window, then create binding, display, and finally attribute. The attribute binding editor will pop up. In the select-an-iterator drop down select the DepartmentsView1Iterator. Now select DepartmentName in the attribute list and then the ok button.
16) Note in the UI Model you now have a new binding called DCDefaultControl. Select this, and in the property palette change the Id to DepartmentName.
17) View the LOV pages source, and change the lovUpdate event as follows:
<event name="lovSelect">
<compound>
<set value="${bindings.DepartmentId.inputValue}" target="${sessionScope}" property="MyAppDepartmentId" />
<set value="${bindings.DepartmentName.inputValue}" target="${sessionScope}" property="MyAppDepartmentName" />
</compound>
</event>18) Return to editEmployees.uix source, and modify the lovUpdate event to look as follows:
<event name="lovUpdate">
<compound>
<set value="${sessionScope.MyAppDepartmentId}" target="${bindings.DepartmentId}" property="inputValue"/>
<set value="${sessionScope.MyAppDepartmentName}" target="${bindings.DepartmentName}" property="inputValue"/>
</compound>
</event>Thats it. Now when you select a value in your LOV, it will return 2 (multiple!) values.
A couple things to note:
1) In the messageLovInput id field we dont use the .path notation. This is mechanism for returning 1 value from the LOV and is useless for us.
2) Again in the messageLovInput we supply _uixState as an entry in the partialTargets.
3) We are relying on partial-page-refresh functionality to update multiple items on the screen.
Im not going to take the time out to explain these 3 points, but its worthwhile you learning more about them, especially the last 2, as a separate exercise.
One other useful thing to do is, in your messageLovInput, include as a last entry in the partialTargets list MessageBox. In turn locate the messageBox control on your page (if any), and supply an id=MessageBox. This will allow the LOV to place any errors raised in the MessageBox and show them to the user.
I hope this works for you :)
Cheers,
CM.Thanks Chris,
It took me some time to find the information I needed, how to use return multiple values from a LOV popup window, then I found your post and all problems were solved. Its working perfectly, well, almost perfectly.
Im always fighting with ADF-UIX, it never does the thing that I expect it to do, I guess its because I have a hard time letting go of the total control you have as a developer and let the framework take care of a few things.
Anyway, I'm using your example to fill 5 fields at once, one of the fields being a messageChoice (a list with countries) with a LOV to a lookup table (id , country).
I return the countryId from the popup LOV window, that works great, but it doesn't set the correct value in my messageChoice . I think its because its using the CountryId for the listbox index.
So how can I select the correct value inside my messageChoice? Come to think of it, I dont realy think its LOV related...
Can someone help me out out here?
Kind regards
Ido -
Returning multiple values from a table
Hi there i am working on a bit of sql which will return values when they exist in a table.
The code I have returns the correct value when there is only one entry in the tbl_studentmodules table, as soon as there is more than one entry in this table it displays no rows at all :(.
Can anyone point out how I go about returning multiple values?
select modulename from tbl_modulefeedback
where 1 = (select count(*) from tbl_studentmodules
where upper(:APP_USER) = upper(student_id))
and 1 = (select count(*) from tbl_modulefeedback, tbl_studentmodules
where tbl_modulefeedback.modulecode = tbl_studentmodules.modulecode)Thanks in advance!
AshleighI'm not quite sure I understand what you are looking for, but I think a simple join may be what you need. something like:
select modulename
from tbl_modulefeedback mfb
join tbl_studentmodules sm
on mfb.modulecode = sm.modulecode
where upper(sm.student_id) = upper(:APP_USER)This will return the module name for all modules that the given student has provided feeedback for. If there is a possibility that a student/module combination could appear in tbl_studentmodules more than once, something like this might be better to show the modulename only once.
select modulename
from tbl_modulefeedback mfb
where mfb.modulecode in (select sm.modulecode
from tbl_studentmodules sm
where mfb.modulecode = sm.modulecode and
upper(sm.student_id) = upper(:APP_USER))If this is not what you want, then post some sample data (preferrable in the form of insert statements or a with clause) and the results you expect rom that sample data.
John -
Return multiple values from a function to a SELECT statement
I hope I've provided enough information here. If not, just let me know what I'm missing.
I am creating a view that will combine information from a few tables. Most of it is fairly straightforward, but there are a couple of columns in the view that I need to get by running a function within a package. Even this is fairly straightforward (I have a function named action_date in a package called rp, for instance, which I can use to return the date I need via SELECT rp.action_date(sequence_number).
Here's the issue: I actually need to return several bits of information from the same record (not just action_date, but also action_office, action_value, etc.) - a join of the tables won't work here as I'll explain below. I can, of course, run a separate function for each statement but that is obviously inefficient. Within the confines of the view select statement however, I'm not sure how to return each of the values I need.
For instance, right now, I have:
Table1:
sequence_number NUMBER(10),
name VARCHAR(30),
Table2:
Table1_seq NUMBER(10),
action_seq NUMBER(10),
action_date DATE,
action_office VARCHAR(3),
action_value VARCHAR(60),
I can't simply join Table1 and Table2 because I have to do some processing in order to determine which of the matching returned rows I actually need to select. So the package opens a cursor and processes each row until it finds the one that I need.
The following works but is inefficient since all of the calls to the package will return columns from the same record. I just don't know how to return all the values I need into the SELECT statement.
CREATE VIEW all_this_stuff AS
SELECT sequence_number, name,
rp.action_date(sequence_number) action_date,
rp.action_office(sequence_number) action_office,
rp.action_value(sequence_number) action_value
FROM table1
Is there a way to return multiple values into my SELECT statement or am I going about this all wrong?
Any suggestions?
Thanks so much!Hi,
What you want is a Top-N Query , which you can do using the analytic ROW_NUMBER function in a sub-query, like this:
WITH got_rnum AS
SELECT action_seq, action_dt, action_office, action_type, action_value
, ROW_NUMBER () OVER ( ORDER BY action_date
, action_seq
, action_serial
) AS rnum
FROM table2
WHERE action_code = 'AB'
AND action_office LIKE 'E' -- Is this right?
SELECT action_seq, action_dt, action_office, action_type, action_value
FROM got_rnum
WHERE rnum = 1
;As written, this will return (at most) one row.
I suspect you'll really want to get one row for each group , where a group is defined by some value in a table to which you're joining.
In that case, add a PARTITION BY clause to the ROW_NUMBER function.
If you'd post a little sample data (CREATE TABLE and INSERT statements), I could show you exactly how.
Since I don't have your tables, I'll show you using tables in the scott schema.
Here's a view that has data from the scott.dept table and also from scott.emp, but only for the most senior employee in each department (that is, the employee with the earliest hiredate). If there happens to be a tie for the earliest hiredate, then the contender with the lowest empno is chosen.
CREATE OR REPLACE VIEW senior_emp
AS
WITH got_rnum AS
SELECT d.deptno
, d.dname
, e.empno
, e.ename
, e.hiredate
, ROW_NUMBER () OVER ( PARTITION BY d.deptno
ORDER BY e.hiredate
, e.empno
) AS rnum
FROM scott.dept d
JOIN scott.emp e ON d.deptno = e.deptno
SELECT deptno
, dname
, empno
, ename
, hiredate
FROM got_rnum
WHERE rnum = 1
SELECT *
FROM senior_emp
;Output:
. DEPTNO DNAME EMPNO ENAME HIREDATE
10 ACCOUNTING 7782 CLARK 09-JUN-81
20 RESEARCH 7369 SMITH 17-DEC-80
30 SALES 7499 ALLEN 20-FEB-81
By the way, one of the conditions in the query you posted was
action_office LIKE 'E'which is equivalent to
action_office = 'E'(LIKE is always equivalent to = if the string after LIKE doesn't contain any wildcards.)
Did you mean to say that, or did you mean something like this:
action_office LIKE 'E%'instead? -
Return multiple values from dynamic lov in apex 3.2.1
Hi
I need to create a dynamic lov that displays multiple values from a table and RETURNS multiple values into display only fields in a form page to be saved to the database
For example
dynamic list of value name SERVER
select name || ',' || life_cycle d, name r
from sserver
order by 1
This SERVER LOV is attached to the P4_SSERVER_NAME field in the form.
However this only returns sserver. name into the P4_SSERVER_NAME field in the form. I would need to capture the life_cycle field as well and populate the P4_LIFE_CYCLE field in the form as well. How does one do this?
I have searched this forum however could not find a thread that fit my situation. i saw that in 4.2 there is dynamic action however unable to upgrade at this moment.
any suggestions are greatly appreciated.
thank youHi CRL,
One method is to set the value of your P4_LIFE_CYCLE item via APEX_UTIL.set_session_state
To do this you need to create a Page Process
Type PL/SQL anonymous block
Process Point On Load - Before Header
The source for the Process might look like this: DECLARE
l_life_cycle VARCHAR2 (50);
BEGIN
SELECT life_cycle
INTO l_life_cycle
FROM sserver
WHERE :p4_sserver_name = sserver.name;
APEX_UTIL.set_session_state ('P4_LIFE_CYCLE', l_life_cycle);
END;Jeff -
Updating a table with a query that return multiple values
Hi,
I'm trying to update a table which contain these fields : ItemID, InventoryID, total amounts
with a query that return these values itemId, inventoryid and total amounts for each items
Mind you, not all the rows in the table need to be updated. only a few.
This what i wrote but doesn't work since the query return multiple values so i can't assign it to journalAmounts.
UPDATE [bmssa].[etshortagetemp]
SET JournalAmounts = (SELECT sum(b.BomQty) FROM [bmssa].[Bom] b
JOIN [bmssa].[SalesLine] sl ON sl.ItemBomId = b.BomId
JOIN [bmssa].[SalesTable] st ON st.SalesId = sl.SalesId
WHERE st.SalesType = 0 AND (st.SalesStatus IN (0,1,8,12,13)) AND st.DataAreaId = 'sdi'
GROUP BY b.itemid, b.inventdimid)
Any advise how to do this task?Remember that link to the documentation posted above that explains exactly how to do this. When you read it which part exactly were you having trouble with?
-
Do I need to extend any of classes from AXIS to return multiple values?
Do I need to extend any of classes from AXIS to return multiple values? I'm exposing the following method as web service through AXIS to return multiple values.
public ContactAddress testService()
ContactAddress cAddr = new ContactAddress();
cAddr.setAddresses1("AAAAAAAAAAAAA");
cAddr.setAddresses2("BBBBBBBBBBBBB");
cAddr.setAddresses3("CCCCCCCCCCCCC");
return cAddr;
and the code for ContactAddress is
public class ContactAddress {
// member variables
private String addresses1;
private String addresses2;
private String addresses3;
public String getAddresses1() {
return addresses1;
public void setAddresses1(String addresses1) {
this.addresses1 = addresses1;
public String getAddresses2() {
return addresses2;
public void setAddresses2(String addresses2) {
this.addresses2 = addresses2;
public String getAddresses3() {
return addresses3;
public void setAddresses3(String addresses3) {
this.addresses3 = addresses3;
}when I'm exposing the method in following way...I'm gettting this error.
org.xml.sax.SAXParseException: Premature end of file.
The wsdl for this is .......
<?xml version="1.0" encoding="UTF-8" ?>
- <wsdl:definitions targetNamespace="http://v:9090/services/Test" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://v:9090/services/Test" xmlns:intf="http://v:9090/services/Test" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
- <!--
WSDL created by Apache Axis version: 1.4
Built on Apr 22, 2006 (06:55:48 PDT)
-->
- <wsdl:types>
- <schema targetNamespace="http://v:9090/services/Test" xmlns="http://www.w3.org/2001/XMLSchema">
<import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
- <complexType name="ContactAddress">
- <sequence>
<element name="addresses1" nillable="true" type="soapenc:string" />
<element name="addresses2" nillable="true" type="soapenc:string" />
<element name="addresses3" nillable="true" type="soapenc:string" />
</sequence>
</complexType>
</schema>
</wsdl:types>
- <wsdl:message name="addRequest">
<wsdl:part name="x" type="soapenc:string" />
</wsdl:message>
- <wsdl:message name="testServiceResponse">
<wsdl:part name="testServiceReturn" type="impl:ContactAddress" />
</wsdl:message>
- <wsdl:message name="addResponse">
<wsdl:part name="addReturn" type="soapenc:string" />
</wsdl:message>
<wsdl:message name="testServiceRequest" />
- <wsdl:portType name="TestService">
- <wsdl:operation name="testService">
<wsdl:input message="impl:testServiceRequest" name="testServiceRequest" />
<wsdl:output message="impl:testServiceResponse" name="testServiceResponse" />
</wsdl:operation>
- <wsdl:operation name="add" parameterOrder="x">
<wsdl:input message="impl:addRequest" name="addRequest" />
<wsdl:output message="impl:addResponse" name="addResponse" />
</wsdl:operation>
</wsdl:portType>
- <wsdl:binding name="TestSoapBinding" type="impl:TestService">
<wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
- <wsdl:operation name="testService">
<wsdlsoap:operation soapAction="" />
- <wsdl:input name="testServiceRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://services.avon.com" use="encoded" />
</wsdl:input>
- <wsdl:output name="testServiceResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://v:9090/services/Test" use="encoded" />
</wsdl:output>
</wsdl:operation>
- <wsdl:operation name="add">
<wsdlsoap:operation soapAction="" />
- <wsdl:input name="addRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://services.avon.com" use="encoded" />
</wsdl:input>
- <wsdl:output name="addResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://v:9090/services/Test" use="encoded" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:service name="TestServiceService">
- <wsdl:port binding="impl:TestSoapBinding" name="Test">
<wsdlsoap:address location="http://v:9090/services/Test" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>1. The export button is only for use with Single Edition publications, for customers who are not using Creative Cloud.
2. All DPS issues are hosted by Adobe, you cannot host them on your own server.
3. The DPS pricing model is based around a per-issue download charge. There is no way to distribute content with DPS and avoid that charge.
Neil
Maybe you are looking for
-
I'm trying to look at my past photos in my camera roll but all that's there is a block and when I try to click on it the photo says "Loading" but nothing ever shows up. I can't click edit or anything. When I plug my phone in to my computer and open t
-
Problem with 711 movement using MB11
Hi All. I am trying to decrease stock using 711 movement via MB11 transaction. When I try to take out stock from a Bulk storage type, I get an error: "Storage type 200 is not suitable as an interface because of capacity check" Diagnosis A capacity ch
-
AQ Adapter Not Returning Fault Message even if the Enqueue is disabled
Hi.... i am using Oracle SOA 10.1.3.5 and we are trying to catch the error/fault returned by the AQ Adapter... to create the scenario i have disabled the Enqueue on the Adapter and put the message...but the we are not receiving the fault message (the
-
Creating a Full-Path Hyperlink in Adobe 9
I need to create hyperlinks to files stored on our network. Our network automatically maps this location to a mapped drive on my computer, but maps other locations to the same mapped drives on other people's computers (I have to put it in this folder
-
Sales order Creation error -- COPA error
Hi, We are trying to create Sales order and getting error as below; Inconsistency between a document field and the prof. segment number Message no. KE396 Diagnosis A line item was assigned to a profitability segment (number 046xxxxxx) which has the v