2 columns working together to return one value
I'm creating an expense reimbursement form. I have 2 columns that need to "work together." There are approx. 10 rows. The first column is a drop down list of account numbers (12 #s). The second column is a dollar amount (user entered). I need 12 "fields" (one for each acct. #) that will look at all the fields in column 1 and add up the dollar amounts in column 2 if the column 1 data matches.
Example:
Column 1 Column 2
Acct. 12345 $10.00
Acct. 67890 $5.00
Acct. 12345 $20.00
Acct. 12345 Total: $30.00
Acct. 67890 Total: $5.00
Thanks for the help!
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class TwoOfAKind extends JFrame implements AdjustmentListener {
JScrollBar scrollBar1, scrollBar2;
public TwoOfAKind() {
JPanel panel1 = new JPanel();
panel1.setPreferredSize(new Dimension(150,600));
JPanel panel2 = new JPanel();
panel2.setPreferredSize(new Dimension(150,600));
JScrollPane scroll1 = new JScrollPane(panel1);
scrollBar1 = scroll1.getVerticalScrollBar();
scrollBar1.addAdjustmentListener(this);
JScrollPane scroll2 = new JScrollPane(panel2);
scrollBar2 = scroll2.getVerticalScrollBar();
scrollBar2.addAdjustmentListener(this);
getContentPane().setLayout(new GridLayout(1,2));
getContentPane().add(scroll1);
getContentPane().add(scroll2);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setSize(400,300);
setLocation(400,300);
setVisible(true);
public void adjustmentValueChanged(AdjustmentEvent e) {
JScrollBar scrollBar = (JScrollBar)e.getAdjustable();
int value = scrollBar.getValue();
if(scrollBar == scrollBar1)
scrollBar2.setValue(value);
if(scrollBar == scrollBar2)
scrollBar1.setValue(value);
public static void main(String[] args) {
new TwoOfAKind();
}
Similar Messages
-
Displaying a column in report which returns null value
Hi
I have a simple report with two column. The query is as below.
SELECT decode(caste,1,'SC/ST',2,'General','3','PWD') fcastepi, nvl(count(*),0) fcapi
FROM applicationformdtl
WHERE year = :p_year
AND selected = 1
AND PROGCD = 'PRM'
GROUP BY caste
This query returns values for SC/ST and General as there is no matching data for the PWD. But I want to display PWD with value 0 in the report. How to do this? Can anyone help me in this matter at the earliest?
Regards
Trushahello,
u r calculating the cast in ur detail table applicationformatdtl.
and also u have the table of caste in which caste description is given
so ur query like this
select nvl(decode(a.caste,1,'sc/st',2,'general'),'pwd')cast,
nvl(a.caste,40),decode(count(*),1,0,count(*),count(*)) total
from applicationformdtl a,caste c where c.caste = a.caste(+) group by a.caste
which gives the output
caste total
sc/st 3
general 5
pwd 0
bye
Chandan -
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> -
Subquery returned more than one value
Hi,
I have this statement which has been working fine - not I get a 'Subquery returned more than one value" error:
SELECT
'WAS3' AS 'Rec ID',
E.EecEEID AS 'Emp ID',
eepNameFirst AS 'First Name',
eepNameLast AS 'Last Name',
EecDateOfOriginalHire AS 'Service Date',
(SELECT DATEDIFF(YEAR, EecDateOfOriginalHire, getdate()) from empcomp EC WHERE EC.EecEEID = E.EECEEID) as 'Yrs of Serv'
FROM
EmpPers
JOIN EmpComp E
ON E.eecEEID = eepEEID
JOIN Company
ON eecCoID = cmpCoID
WHERE
EecDateOfTermination IS NOT NULL
AND EXISTS
(SELECT 1
FROM EmpComp e2
WHERE e2.EecEEID = E.EecEEID
--AND e2.eecEmplStatus <> 'A')-- changed to <> ...this WAS/is to filter out anyone that was termed then re-hired
--AND E.EecTermReason NOT IN ('I01','I02','I03','I14','I22','V05','V07','V09','V12','V22','V13', 'TRO')
AND E.eecDateOfTermination
IN (SELECT (EC.eecDateOfTermination)
FROM EMPCOMP EC
WHERE EC.EecEEID = E.EECEEID
AND EC.eecDateOfTermination IS NOT NULL
AND eC.eecDateOfTermination >= DATEADD(wk,DATEDIFF(wk,0,GETDATE()),0)
AND EC.eecDateOfTermination <=DATEADD(wk,DATEDIFF(wk,0,GETDATE()),6)
AND e.eecDateOfTermination >= DATEADD(wk,DATEDIFF(wk,0,GETDATE()),0)
AND E.eecDateOfTermination <= DATEADD(wk,DATEDIFF(wk,0,GETDATE()),6)))
--AND eC.eecDateOfTermination >= DATEADD(wk,DATEDIFF(wk,0,('12/30/2007')),0)
-- AND EC.eecDateOfTermination <=DATEADD(wk,DATEDIFF(wk,0,('12/30/2007')),6)
-- AND e.eecDateOfTermination >= DATEADD(wk,DATEDIFF(wk,0,('12/30/2007')),0)
-- AND E.eecDateOfTermination <= DATEADD(wk,DATEDIFF(wk,0,('12/30/2007')),6)
-- AND E.eecDateOfTermination IS NOT NULL ))
--added below per Paul Cottle to exclude employeess less than four years
AND E.eecdateoforiginalhire >=dateadd(year,-4, CURRENT_TIMESTAMP)
qeqwCheck this, if it works:
SELECT
'WAS3' AS 'Rec ID',
E.EecEEID AS 'Emp ID',
eepNameFirst AS 'First Name',
eepNameLast AS 'Last Name',
EecDateOfOriginalHire AS 'Service Date',
DATEDIFF(YEAR, EecDateOfOriginalHire, getdate()) as 'Yrs of Serv'
FROM EmpPers
JOIN EmpComp E ON E.eecEEID = eepEEID
JOIN Company ON eecCoID = cmpCoID
WHERE EecDateOfTermination IS NOT NULL
AND EXISTS
(SELECT 1
FROM EmpComp e2
WHERE e2.EecEEID = E.EecEEID
AND E.eecDateOfTermination
IN (SELECT (EC.eecDateOfTermination)
FROM EMPCOMP EC
WHERE EC.EecEEID = E.EECEEID
AND EC.eecDateOfTermination IS NOT NULL
AND eC.eecDateOfTermination >= DATEADD(wk,DATEDIFF(wk,0,GETDATE()),0)
AND EC.eecDateOfTermination <=DATEADD(wk,DATEDIFF(wk,0,GETDATE()),6)
AND e.eecDateOfTermination >= DATEADD(wk,DATEDIFF(wk,0,GETDATE()),0)
AND E.eecDateOfTermination <= DATEADD(wk,DATEDIFF(wk,0,GETDATE()),6)))
AND E.eecdateoforiginalhire >=dateadd(year,-4, CURRENT_TIMESTAMP)
If this post answers your query, please click "Mark As Answer" or "Vote as Helpful". -
How to return more than one value from a function
hello everybody,
Can anyone tell me how to return more than a single value from a function, the problem is i have 4 points,
2 points form one line ,another 2 points form 2nd line ,each point is 3 dimensional(x,y,z coorinates) so i will pass these values to func(x1,y1,z1,x2,y2,z2,x3,y3,z3,x4,y4,z4), i will find the point of intersecton of two lines and i will get it as x,y,z , now how to return these 3 coordinates,usually the function returns only one value, please help me to solve it out.
Thanks.I think the easiest way or trick here is (easiest isn't always the best as we know, but atleast this one will work) to create simple data array. and pass that. Create an array with:
<code>
class justArray {
int x=0
int y=0;
int z= 0;
...somewhere
justArray[] points= new justArray[4];
points[0].x= ..
points[0].y= ..
points[0].z= ..
points[1].x= ..
return points[]
</code> -
3.1 EA3 - Column value filter dropdown returns duplicate values
Hello,
SQL Developer 3.1 EA3 introduces a regression: the column value filter in the table data editor dropdown (filter column) now shows duplicate values. Previous versions (at least 3.0) returned unique values to select from.
Since this is EA3 and not yet production, should I file a bug for this?
Best Regards and many thanks for this tool,
Olivier.
Edited by: user9378013 on Jan 9, 2012 1:08 PMYes it's a regression. Fixed it recently. In the next released build it should work properly.
-Raghu -
How do I return a value from a column based on info from neighboring columns?
I have a table of data that looks similar to this:
Weight
Name
School
Division
106
Name1
School1
1
106
Name2
School2
2
106
Name3
School3
3
106
Name4
School4
4
113
Name5
School5
1
113
Name6
School6
2
113
Name7
School1
3
113
Name8
School3
4
It's a very large table, so there will be multiple matches for Schools, and occasionally a few matches for Names, but there will always be only one match for a given Weight and Division.
In a separate table, how can I get the name of the person associated with the unique weight and division?
In my head, the formula goes" "Look in the Weight column to find 106, then look in the Division column to find 4, then return the value from the Name column." But I can't figure out the formula that will do that.
Any thoughts?Hi momogabi,
This can be easily done with an index column.
The formula I used in your original table for the index column is:
=A2&"-"&D2. This was filled down. The column can be hidden.
You can see the formula in the search table. If I wanted to eliminate the index column in that table the formula would look something like:
=INDEX('Table 1-1'::B,MATCH(A2&"-"&B2,'Table 1-1'::E,0),1)
Hope this helps.
quinn -
Can Function Return more than One Values ??
Hi Experts,
I would like to ask you Can Function Return more than one values. I Used Function with Out and In out parameter and its working Fine..
1. what is harm using Out and In out parameter in function
2. if we can use Out and In out parameter in Function so what is deffernce between procedure and Function.
3. Is there any Other Way Though which we can return more the One values in Function.
Please advice me...
Thanks
Umesh GoelYes/No.
You can return multiple value from function. But, in PL/SQL and not in a SQL.
The following examples demonstrate that -
SQL*Plus: Release 9.2.0.1.0 - Production on Wed Mar 28 17:41:15 2007
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> create or replace package glob
2 as
3 b varchar2(20);
4 c varchar2(20);
5 end;
6 /
Package created.
SQL>
SQL> create or replace function test_mul_out(a in number)
2 return number
3 is
4 cursor c1(eno in number)
5 is
6 select ename,job,sal
7 from emp
8 where empno = eno;
9
10 rec c1%rowtype;
11 d number(10);
12 begin
13 open c1(a);
14 loop
15 fetch c1 into rec;
16 exit when c1%notfound;
17 glob.b:= rec.ename;
18 glob.c:= rec.job;
19 d:= rec.sal;
20 end loop;
21 close c1;
22 return d;
23 end;
24 /
Function created.
SQL> set serveroutput on
SQL>
SQL> declare
2 zz number(10);
3 begin
4 select test_mul_out(7777)
5 into zz
6 from dual;
7
8 dbms_output.put_line('Ename: '||glob.b);
9 dbms_output.put_line('Job: '||glob.c);
10 dbms_output.put_line('Sal: '||zz);
11 end;
12 /
Ename: Avik
Job: CLERK
Sal: 3456
PL/SQL procedure successfully completed.
SQL> Regards.
Satyaki De. -
TableView - Filter more than one value in same column
Hi folks,
I faced a problem on <b>filtering a field more than one value</b>.
Does it possible solution for us to bring out filtering function while user try to enter few values in the SAME filter field?
Thank you.
First, i need to clarify my exact problem.
--> I have created one tableView with filter = "server". Then i want to allow my user to enter few filter values in same field column.
Example 1:
Before
COL1 COL2 COL3 COL4
l--II--
l-filter1I--I--
*filter1 = AAA, BBB
AAA AAA AAA AAA
BBB BBB BBB BBB
CCC CCC CCC CCC
DDD DDD DDD DDD
EEE EEE EEE EEE
After
COL1 COL2 COL3 COL4
l--II--
l-filter1I--I--
*filter1 = AAA, BBB
AAA AAA AAA AAA
BBB BBB BBB BBB
Is that any good suggestions to solve my doubt?
Message was edited by:
GP Pohcheck out this work around. in this sample currency column supports multiple values and multiple values in the filter column should be enter with comma as separater.
<u><b>page attribute:</b></u>
filtertab TYPE RSELOPTION
filter_wa TYPE RSDSSELOPT
itab TYPE FLIGHTTAB
<u><b>layout</b></u>
<%@page language="abap" %>
<%@extension name="htmlb" prefix="htmlb" %>
<htmlb:content design="design2003" >
<htmlb:page title=" " >
<htmlb:form>
<htmlb:textView id ="tex"
text = "Filter on Currency Column support multiple values, they can be entered with comma as separater like 'usd,DEM'"/>
<htmlb:tableView id = "tv1"
design = "ALTERNATING"
table = "<%= itab %>"
filter = "APPLICATION"
columnHeaderVisible = "true"
sort = "SERVER" />
</htmlb:form>
</htmlb:page>
</htmlb:content>
<u><b>oninitialization</b></u>
select * from sflight into table itab where currency in filtertab .
<u><b>oninputprocessing</b></u>
* event handler for checking and processing user input and
* for defining navigation
DATA: table TYPE REF TO cl_htmlb_tableview .
DATA: tv_data TYPE REF TO cl_htmlb_event_tableview.
DATA: filter_value TYPE string .
DATA: fil_val TYPE STANDARD TABLE OF string ,
fil_val_wa TYPE string .
REFRESH filtertab .
table ?= cl_htmlb_manager=>get_data( request = request
name = 'tableView'
id = 'tv1' ).
IF table IS NOT INITIAL .
tv_data = table->data .
IF NOT tv_data IS INITIAL .
CALL METHOD tv_data->get_row_filter_value
EXPORTING
column_index = 6
RECEIVING
value = filter_value.
IF NOT filter_value IS INITIAL .
TRANSLATE filter_value TO UPPER CASE .
REFRESH fil_val .
SPLIT filter_value AT ',' INTO TABLE fil_val .
CLEAR fil_val_wa .
LOOP AT fil_val INTO fil_val_wa .
filter_wa-sign = 'I' .
filter_wa-option = 'EQ' .
filter_wa-low = fil_val_wa .
APPEND filter_wa TO filtertab .
ENDLOOP .
ELSE .
REFRESH filtertab .
ENDIF .
ENDIF .
ENDIF .
Regards
Raja -
How to return Parameters values as a column in a query?
Hi All,
I have number of parameters in a report.
I need to return its interred values as a column in a query to use this column in a chart.
I want this column to be the second one in this query:
SELECT ROWNUM
FROM ALL_OBJECTS
WHERE ROWNUM <= 10
That is if there is any way to use these parameters directly as a column in the chart no need for the previous statement.
Note: I am using Reports 6iDear sir
You can enter parameter as column in query like
select :parameter p1, &hexadecima_paramataer p2, empcode
from emps;
that query make parameter as query column .
&hexadecimal paramater can refer to database column of table emps
and :paramater can refer to static string -
Can a method return more than one value?
I was studying for my biology exam and I got bored and I started thinking and then I wandered if a method can return more than one value...?
For example, if I want a method to return a row a column, I make a method that returns an int. But what if I want to return two ints? Or what If I want to return an integer and a string? Is it possible or do I have make two methods, each returning one thing?
What I always did until now is is I want for example to return a few integers, I would store them in a String and then when I return the string, I parse the numbers out using stringtokenizer... but it doesn't look like the best way... and it's pretty annoying...I'm weak on terminology, hence I don't even know what
AFAIK means...As Far As I Know
This doesn't really make sense for me. It's more
efficient to make a whole class just for two
integers, than having two methods? Efficiency is not the point. The flow is.
If you have two methods, the caller must be aware of both of them. The other way it's up to the callee.
Just because the
two integers are related to each other? Doesn't
making a class require more memory usage than just
making two one-line methods?The memory usage is not wholly irrelevant, but there are ways to handle that (caching, inlining, etc.).
It's a bit hard to counter your point for me, but if you had done a lot of GUI painting stuff, you'd see all those Points, Dimensions, Rectangles, you name it, are quite invaluable. -
How do you return more than one value from a method?
say I have this:
public static int myFunc(String inString)
// I want to return two values from this method
}yeah so how would i do that?If the two values are somehow related--like a person's name and his age--define a class that has those two values as member variables--for example, Person. But only if that class and the assocation of those two quantities makes sense as an entity in your program. Don't do it just to jam to quantities into one return.
Or, if the two values are two of the same thing--person A's age and person B's age--then you can return an array or Collection.
If it doesn't fit either of those two scenarios, then your method is trying to do too much unrelated stuff and you should break it into multiple methods. For example, calculating a Person's age based on his birthdate and today's date and calculating his Body Mass Index based on his height and weight. Those two quantities should NOT be returned together. -
Is that posible: return a value and AFTER THAT calculate next one?
I would like for better performance have a functionality to, first, return a value (prepared already), after that calculate a next one for next call.
Is that any way to perform it some how in PL/SQL?
After some time I have guess the next way:
Have a table with current and next value
On request read and return next.
To update have a trigger on select to move the next value to the current and calculate the next-to-current into the 'next' column.
Thus, I would need to have 'init'-procedure to set: table, if not exist; trigger, if not exist; set current (the first one) and next one into that table.
It just a plan; I am not sure if all doable.
But it seems kind of heavy.
Is it possible to have it simpler?- I do not ask you to judg my task, processing, reasonability or an idea of sequence implementation.
That's the beauty of the forums - you get that extra help without having to ask!
Also I am not asking to help me in anything!
I do not have any assignment and do not need to anyone resolve my requirements!
Of course you are asking for help when you post on the forums; that is what they are here for.
And to get the best help you need to respond to the questions of the people that are trying to help you. You never responded to what both ramin and gaverill ask you above:
What is your objective? What problem are you trying to solve? Why is it not 'acceptable' to simply calculate the 'next' value when you need it?
For some reason you think using the DBMS_SCHEDULER is 'helpful' but you don't seem to realize that a job is going to be asynchronous to whatever else you are doing. Your code may need a value before the job is finished computing it.
Without knowing the PROBLEM you are trying to solve no one can help you find the most appropriate solution. And using a custom table to roll your own sequence generator is almost ALWAYS the wrong thing to do for both performance and scalability reasons. -
Request.getParameter("checkbox") Returns only one value
Hello Friends,
I have a very urgent problem on live site. I moved my project from jrun2.3.3 to Jrun 3.1 and I was using multiple select and checkboxes.
With Jrun3.1 if you select multiple select or multiple checkboxes it returns only one value instead of all the values.
Any help is hightly appreciated.If multiple checkboxes have the same name, when selected and submitted, it will pass all values. But you will need to access those using getParameterValues("checkboxname") not getParameter("checkboxname"). The same goes for select elements.
Perhaps it was a bug in JRun 2.3.3 that allowed you to reference all parameter values using just the getParameter("xxx") method. -
How to pass more than one value for one column in procedure
hi
select id, name from col_tab where dept_name in ('ECE','CIVIL');
when i was running this it is working well.
CREATE OR REPLACE PACKAGE pack_str
AS
TYPE type_refcur IS REF CURSOR;
PROCEDURE str(char_in VARCHAR2,ans OUT type_refcur);
END pack_str;
CREATE OR REPLACE PACKAGE BODY pack_str
AS
PROCEDURE str(char_in VARCHAR2,ans OUT type_refcur)
IS
BEGIN
OPEN ans FOR
select id,name from col_tab where dept_name in char_in ;
END str;
END pack_str;
the package was created.
my doubt is
1.how to pass more than one value for char_in (e.g ('ECE','CIVIL'))
2. when i was storing the value in string like val = 'ECE,CIVIL' ,
how to get the id,name for ECE and CIVIL.
plz help meHi Rebekh ,
I am recreating your packages for the desired output.
CREATE OR REPLACE PACKAGE pack_str
AS
TYPE type_refcur IS REF CURSOR;
PROCEDURE str(char_in VARCHAR2,ans OUT type_refcur);
END pack_str;
CREATE OR REPLACE PACKAGE BODY pack_str
AS
PROCEDURE str(char_in VARCHAR2,ans OUT type_refcur)
IS
lv_t varchar2(200);
BEGIN
lv_t := REPLACE(char_in,',',''',''');
lv_t := 'select id,name from col_tab where dept_name in (''' || lv_t || ''')' ;
OPEN ans FOR lv_t;
END str;
END pack_str;
Note:-
Input Parameter char_in is a comma seperated value for dept_name
-Debamalya
Maybe you are looking for
-
MPB mid-2010 very slow after Yosemite upgrade from Snow Leopard
I updated my MPP (mid-2010) from Snow Leopard to Yosemite some weeks back. It is painfully slow since, particularly when Mail is open. I attach the etrecheck output below, but would really appreciate any help in recovering what was not-so-long-ago a
-
Need suggestion on how to extract data from a table
Many years ago, I wrote many Perl scripts to increase my work productivity. Now I am starting learning Java, Javascript and PHP for some purposes. Just wrote a simple html2txt java program. Now I need experts' suggestion for one specific purpose - ex
-
hi As of my requirement i want to pick data from VBAK,BKPF,BSEG according to customer number(KUNNR),I didn't find common field in VBAK and BKPF and one more If i take the loop for header data(VBAK) shell i take/read/loop the another header data(BKPF)
-
How come iphone 5 are not shipping to stores?
For two weeks now every Apple or AT&T store i have been to been sold out. A women working at AT&T even told me they had not recieve iphone since launch date. Whats going on??
-
When trying to print I get error code 30892 and authentication required how do I fix this?
I am new to my Mac and am having trouble printing. I keep getting error code -30892 and authentication required and it can't print. I have sharing features open on both my PC and my Mac. Any suggestions?