Select LOV based on value in another table
Hi all,
I have an issue,
I have an item with Select list with dynamic query in the dropdown ListofValues.
but i want to use a condition like
select val1 display_value val2 return_value
from table2
where value_in_table1 = username AND table_id1=table_id2
in these two tables i have the id's common and table 1 is having the usernames.
Can somebody help me in solving this issue please.
Thanks in advance
As far as I know, you can't dump PL/SQL into the list of values definition. Try just having select distinct PJT_NAME display_value, PROJECT_ID return_value from EZS_PROJECTS WHERE EMP_ID = :P1_XYZ ORDER BY 1
Similar Messages
-
Inserting values in atable based on values in another table
Hi,
We receive data from our customers as follows AB784589456. This is the starting value for an serial number of a product. We also receive a quantity. I need to be able to populate rows in another table to start with AB784589456 and then add an additional
row to the value of the quantity. So the first row in the second table would be AB784589456, the second AB784589457, AB784589458, etc until the number has been incremented to the value of the quantity.
Order Number SerialNo
234 AB784589456
234 AB784589457
234 AB784589458
The datatype of the SerialNo is Varchar(14)
Any help would be appreciated
ThanksAssuming the serial value format is consistent ie alphabet followed by numeric you can use this
DECLARE @Serial varchar(14) = 'AB784589456', @Quantity int = 15
;With N1
AS
SELECT 1 N UNION ALL SELECT 1 UNION ALL SELECT 1
),N2
AS
SELECT 1 N FROM N1 t1 CROSS JOIN N1 t2
),N3
AS
SELECT 1 N FROM N2 t1 CROSS JOIN N2 t2 CROSS JOIN N2 t3
),N4
AS
(SELECT ROW_NUMBER() OVER (ORDER BY (SELECT 1)) AS Seq
FROM N3
INSERT INTO YourTable (OrderNumber,SerialNo)
SELECT OrderNumber,LEFT(@Serial,PATINDEX('%[0-9]%',@Serial)-1) + CAST(STUFF(@Serial,1,PATINDEX('%[0-9]%',@Serial)-1,'') + Seq -1 AS varchar(11))
FROM Table1 t
CROSS JOIN N4 n
WHERE n.Seq BETWEEN 1 AND @Quantity
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
Averaging selected range based on value of another channel
I have one channel, X, with a bunch of integer values from 0 to 90. I also have another channel with various corresponding data, lets call it Y. I would like to find the average and standard deviation for all of the values in Y that have a 0 in its corresponding X row, then the same for all values in Y that have a 1 in its corresponding row and etc, all the way up to 90. Is there an easy way to do this? Perhaps there is a way to sort the data and put all the Y values into new channels that are grouped according to their X values?
Hi Martin,
You have a couple of options. You could indeed use the FormulaCalc() command to split out various rows from your data channel that all have the same index into a new data channel and do this for each index. Alternatively, you could determine which rows contain a certain index, then use the StatBlockCalc() function to determine statistics from only these rows of your data channel:
Dim Channel, Msg
Channel = "[1]/Time"
For i = 1 To 22
StatSel(i) = "No"
Next
StatSel(4) = "Yes" ' Minimum
StatSel(5) = "Yes" ' Maximum
StatSel(6) = "Yes" ' Arith. mean
StatSel(14) = "Yes" ' Standard Deviation
Call StatBlockCalc("Channel", "1-13", Channel)
Msg = Msg & "Min = " & StatMin & vbCRLF
Msg = Msg & "Ave = " & StatArithMean & vbCRLF
Msg = Msg & "Max = " & StatMax & vbCRLF
Msg = Msg & "Dev = " & StatDeviation
MsgBox Msg
Note that if you have DIAdem 10.1 you should loop up to 23,
Brad Turpin
DIAdem Product Support Engineer
National Instruments -
How to select rows based on values from other table?
I need to select all rows from TABLE1 whose time column is NOT between fromTime and toTime from TABLE2.
For example, those table contain following rows:
TABLE1
|id |time |...
|1 | 10 |...
|2 | 20 |...
|... | ... |...
TABLE2
|fromTime|toTime|
| 3 | 6 |
| 10 | 16 |
| 20 | 25 |
So, in the case above the first and second rows shouldn't be returned by the query since 10<=10<=16 AND 20<=20<25.Try
-- code #1
SELECT id, time
from TABLE1 as T1
where not exists (SELECT * from TABLE2 as T2
where T1.time between T2.fromTime and T2.toTime);
José Diz Belo Horizonte, MG - Brasil -
How to create a new row for a VO based on values from another VO?
Hi, experts.
in jdev 11.1.2.3,
How to create a new row for VO1 based on values from another VO2 in the same page?
and in my use case it's preferable to do this from the UI rather than from business logic layer(EO).
Also I have read Frank Nimphius' following blog,but in his example the source VO and the destination VO are the same.
How-to declaratively create new table rows based on existing row content (20-NOV-2008)
http://www.oracle.com/technetwork/developer-tools/adf/learnmore/13-create-with-params-169140.pdf
I have tried:
1.VO1(id,amount,remark1) and VO2(id,amount,remark2) are based on different EO,but render in same page,
2.Drag and drop a Createwithparams button for VO1(id,amount,remark),
3.add: Create insertinside Createwithparams->Nameddata(amount),
4.set NDName:amount, NDValue:#{bindings.VO2.children.Amount}, NDtype:oracle.jbo.domain.Number.
On running,when press button Createwithparams, cannot create a new row for VO1, and get error msg:
<Utils> <buildFacesMessage> ADF: Adding the following JSF error message: For input string: "Amount"
java.lang.NumberFormatException: For input string: "Amount"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
Can anyone give some suggestions?
Thanks in advance.
bao
Edited by: user6715237 on 2013-4-19 下午9:29Hi,CM,
I'm really very appreciated for your quick reply! You know, today is Saturday, it's not a day for everyone at work.
My principal requirement is as follows:
1.select/check some rows from VO2, and for each selection create a new row with some attributes from VO2 as default values for VO1's corresponding attributes, and during this process the user may be cancel/uncheck or redo some of the selections.
--so it's better to implement it in UI rather than in EO.
2.it's better to implement this function with declarative way as in Frank Nimphius' blog.
--little Jave/JS coding, the better. I only have experience in ORACLE FORMS, little experience in JAVA/JS.
In order to get full information for the requirements of my use case, can take a check at:
How to set default value for a VO query bind variable in a jspx page?
(the end half of the thread: I have a more realworld requirement similar to the above requirement is:
Manage bank transactions for clients. and give invoices to clients according to their transaction records. One invoice can contain one or many transactions records. and one transaction records can be split into many invoices.
Regards
bao
Edited by: user6715237 on 2013-4-19 下午11:18
JAVE->JAVA -
Update table based on values from other table
Hi,
I am trying to update one table based on the values of another table. Since you can't use From in update statements, how do you execute this?
For example i have to tables, Table A and Table B. I want to update a column or columns in Table A based on another value in Table B:
So if the column in Table B was 1 then column in Table A would be Yes, if Table B was 2, then Table A would be Yes, if Table B was 3 then Table A would be N/A and so on...
Any help would be appreciated.
thanks,
scottSQL> select * from t1;
ID ST
1
2
3
SQL> select * from t2;
NO
1
2
3
4
SQL> update t1 set status=(select decode(no,1,'Y',2,'N','NA') from t2 where t1.id=t2.no);
3 rows updated.
SQL> select * from t1;
ID ST
1 Y
2 N
3 NA
Daljit Singh -
How to insert One table value to Another Table
Hi friends
Please have a look on this Code. Since i am new Java i am not able to findout the Solution for it
private void displayavailablity(String selecteditem1)
try
Vector columnNames = new Vector();
Vector data1 = new Vector();
String bname,bauthor,bcategory,bref1,bavail,bid;
int bref,mid,num;
rs = st.executeQuery("SELECT * FROM Books where BAuthorandPublisher='" + selecteditem1 +"'");
while(rs.next())
bname = rs.getString("BName");
bauthor = rs.getString("BAuthorandPublisher");
bcategory = rs.getString("BCat");
bref = rs.getInt("BRef");
if(bref==1)bref1="Yes";
else bref1 = "No";
mid = rs.getInt("Mid");
if(mid==0)bavail="Available";
else bavail="Issued To:"+mid;
bid = rs.getString("BId");
System.out.println("Book Name is::"+bname);
System.out.println("Book Availabilty::"+bavail);
num = st.executeUpdate("insert into BSearch Values('"+bid+"','"+bname+"','"+bcategory+"','"+bauthor+"','"+bavail+"','"+bref1+",')");
System.out.println("Inseted in the table");
/**ResultSetMetaData md= rs.getMetaData();
int columns =md.getColumnCount();
String booktblheading[]={"Book ID","Book NAME","BOOK AUTHOR/PUBLISHER","REFRENCE","CATEGORY"};
for(int i=1; i<= booktblheading.length;i++)
columnNames.addElement(booktblheading[i-1]);
while(rs.next())
Vector row = new Vector(columns);
for(int i=1;i<=columns;i++)
row.addElement(rs.getObject(i));
data1.addElement(row);
//System.out.println("data is:"+data);
((DefaultTableModel)table.getModel()).setDataVector(data1,columnNames);
//DefaultTableModel model = new DefaultTableModel(data1,columnNames);
//table.setModel(model);
rs.close();
//st.close(); */
catch(SQLException ex)
}I trigger this Method when a JComboBox Item is Selected.
For an example when i select an Item the select Query brings all the Record Equals to the Selected item. Now i want to insert the Selected items with some Modification to Another Table.
Now the Problem is My Program Inserts Only One Record (Though there are Many Records Equals to Selected Item)
Please give me a Better Solution
Thank youjolif,
If you're "new to java" then might I suggest you leave swing until you're "not so new to java"... it involves so many "advanced concepts" (unlike VB) that it constitutes a biohazard... i.e. it's fundamentally inimical to humanoid lifeforms.
Now... Having duly vented my spleen, try rs.updateRow(); -
How to change the values in an LOV based on values selected in another LOV
Hi,
I have a requirement in ADF where there are two LOVs. Based on the values that I select in the 1st LOV, the values in the second LOV should change dynamically.
Also, the 1st LOV accepts 3 values, for every value I select, a different query is executed to populate the 2nd LOV.
I have a rough thought that I can use 3 different read only view objects containing these 3 queries. And based on the value I select in the 1st LOV I can execute the corresponding View object from the backing bean. But my doubt is how to link the results of that query that is executed to populate the 2nd LOV.
Thanks in advance.
Edited by: 886591 on Sep 21, 2011 4:48 AMHi Brisk,
Thanks for your reply.
The link that you have provided explains how to disable and enable the other LOVs based on a parent LOV. But in my case there are two Select One Choice fields i.e. the dropdowns (sorry that I addressed it as LOV in my previous post which might be confusing). There are 3 static values in the parent dropdown where each of them are associated with a different query. for e.g if the three values in the drop down are A, B and C; if i select A, then query associated to A should be executed ; if i select B, then query associated to B should be executed and if I select C, query associated to C should be executed. Then the output attribute of that query should be populated in the child dropdown.
Please let me know about the solutions to this.
Thanks,
Kavitha -
Set Default Value based on Field from another table for a custom object
I'm trying to set the default value on a custom object field to the value of an account field. I have tried the syntax 50 different ways, and just am getting no where. The account field label displays as DBA, the integration tag is ltDBA_ACCT, and it shows up in reporting fx area as Account.Text_22.
The custom object field I'm triying to update is also called DBA, which was originally the "NAME" required field. Does the table name, Account, have to be included? Do I need a function in front of the field?
I have been updating the external ID using the row ID with syntex <ID> (Less than ID greater than) so I know it is possible to set the Default Value, but <DBA>, <ltDBA_ACCT>, "Account"."DBA", and so on just don't not work.
If anyone knows how to enter this I'd really appreciate the help.Ok, so if you want to default a field to the value from another object, you have to use the JoinFieldValue function. I think you understand that, based on your original post, but I want to be sure that you do.
Next, this will only work as a default if the record is created from the object that you wish to join on because a default works at record creation and the ID needs to be available for it to work properly. It will not work if you choose the related object record after the custom object record is created. You could set the value as a post-default, but that does not seem to meet your requirements.
The syntax for the Default Value would be as follows: JoinFieldValue(ref_record_type, foreign_key, field_name).
In your case, ref_record_type is '<Account>', foreign_key is [<AccountId>], and field_name is '<YourFieldName>'. The best way to determine what the field name is would be to create a new workflow for Account and use the Workflow Rule Condition expression builder to pick your field ("DBA") from the list. The value that is returned by the expression builder should be placed in the field_name variable in the JoinFieldValue function (minus the brackets and in single quotes).
Give this a shot and let me know how you do.
Thom -
How to make validation in Bean and select value from another table
I want to know how to select data from table in backing bean according to primary key i have
the problem is that
i have a table Employee_Salary contains Employee ids and their salary
Empoloyee_Salary table
Employee_ID Number
Employee_salary Number
And Another table Called Employees
Employees table
Employee_ID Number
IsManager Varchar2 its value is [*Yes or NO*]
and other columns that i don't care about this table
i have on a jsff page an <af:table> this table is editable this is the Empoloyee_Salary table
*i want to check before save or after insert if this employee is Manager [from Employees tabke(yes or no)] the salary*
cannot be less that 100
i want to know how to make this how to select the value from employees table according to the id i have in the employee_salary table how to make this and make this validation
i have to select IsManager from Employees Table to see if this manager or no
i want to know how to make this in a bean
i use jdeveloper 11g
and my project is ADF Fusion project
and the page that have the Emplpyee_Salary table is JSFF
thanks in advanceYou might want to write this code in a validator on the entity object if it should apply from every screen.
If you want to access view objects from a backing bean the basics are here: http://download.oracle.com/docs/cd/E15523_01/web.1111/b31974/bcservices.htm#sthref918 -
Conditional inclusion of column cells based on value in another column?
I was wondering if something like the following is possible -- I've looked through the forums and Numbers user guide but can't figure it out:
Suppose I have a column A of sales figures, and columns B and C which basically have different attributes (say, color (yellow or green), size (small or large), and material (cotton or polyester)).
I want to run basic statistics on various combinations: e.g. all yellow items regardless of size, all green cotton items regardless of size, all large yellow items regardless of material, etc.
I want to be able to specify something like this:
'Compute the average of every cell in column A where column B=="green" and column C=="large"'
Is there a good way to go about doing this? Would I want to attack the problem using categories, sorting, and multiple tables? Or is there a way to conditionally include cell values from a range based on the value of that row's cell in another column?
Thanks for any help.All I can think of to solve the quartile and median functions is to have another table of the same size as your original table that gets populated with just the items that match. Then you can do the quartile and median (and average) on that table. It's a one-at-a-time affair; you can only do one selection of size, color, and/or material at a time but you can get the median, mean, and quartiles of it. Of course, you could have multiple copies of this second table if you want to do more than one comparison at a time.
In the attached file, unhide the hidden rows in Table 2 to see the formulas that do all the work.
[files.me.com/pwb3/6hobt0.numbers.zip]
Message was edited by: Badunit
Message was edited by: Badunit -
Ain't getting it: insert into table by determing value from another table
I have a table (PERCENTILE_CHART) with percentiles and test scores for different tests:
Structure:
Percentile, Reading_Test, Writing_Test
Data:
30,400,520
31,450,560
97,630,750
98,630,780
99,640,800
The data is currently in ascending order by Percentile.
If a person took the Reading test and scored 630 he or she would be in the 98th (not 97th) percentile of the class taking that test.
I wrote a statement to return the percentile:
select Percentile
from ( select ROWNUM, PERCENTILE
from PERCENTILE_CHART
where READING_TEST <= '650'
order by READING_TEST desc)
where ROWNUM < 2 order by PERCENTILE desc;
This select works and is able to determine the highest percentile for a score.
Ok, now I want to process all the records in a STUDENT table which have
test scores and insert them in a new table along with the percents, normalizing the data in the process.
Have this:
STUDENT:
Student_Name,Student_ID,
John Smith,121,Reading,98,Writing,90
Maggie Smithe,122,Reading,95,Writing,96
And needs to be moved to into SCORES with the percentiles, so I get this:
SCORES:
Student_Name,Student_ID,Test_Name,Percentile
121,Reading,98
121,Writing,90
122,Reading,95
122,Writing,96
This is were I get confused. How do I insert the data into the SCORES table with the percentile? I think calling a function in package is the way to do it:
function oua_Test_Percentile_f (
p_Test_Name in char,
p_Test_Value in char)
return char as
-- Declare variables
c_Return_PTile char(2);
begin
select PERCENTILE into c_Return_PTile
from (select ROWNUM, PERCENTILE
from PERCENTILE_CHART
where p_Test_Name <= '&p_Value'
order by p_Test_Nmae desc)
where ROWNUM < 2 order by PERCENTILE desc;
return c_Return_PTile;
end;
But this function doesn't return the percentile even though it is based on my working select mentioned earlier. It returns a blank for all tests.
And even if it is working how do I then populate the SCORES table?You may want to use analytical functions so that you can determine the percentile across all of the different scores:
SQL> with
2 PERCENTILE_CHART as
3 (
4 select 30 PERCENTILE, 400 READING_TEST, 520 WRITING_TEST from dual union all
5 select 31 PERCENTILE, 450 READING_TEST, 560 WRITING_TEST from dual union all
6 select 97 PERCENTILE, 630 READING_TEST, 750 WRITING_TEST from dual union all
7 select 98 PERCENTILE, 630 READING_TEST, 780 WRITING_TEST from dual union all
8 select 99 PERCENTILE, 640 READING_TEST, 800 WRITING_TEST from dual
9 )
10 select
11 max(percentile) over (partition by reading_test) HIGHEST_READING,
12 max(percentile) over (partition by writing_test) HIGHEST_WRITING,
13 percentile_chart.*
14 from
15 percentile_chart
16 /
HIGHEST_READING HIGHEST_WRITING PERCENTILE READING_TEST WRITING_TEST
30 30 30 400 520
31 31 31 450 560
98 97 97 630 750
98 98 98 630 780
99 99 99 640 800
SQL>
I wasn't exactly sure how you wantd to coorelate this to the student records though; the student table had only two column name headings but there were four rows listed as examples and had fewer rows than in the percentile_chart table...
If you join the student table to the able query it might be what you are looking for.
You can create another table based on the output of your query by doing:
create table scores
as select * from
(insert your query here)
/ -
Default value from another table in dummy field on a portal form ..
A form based on a table :
id
name
xx_id
I created a dummyfield on the form in which i would like the
name corresponding to xx_id -> I would like to fetch a value
from another tabel into a dummy field.
thanx
Trine HindsholmI could do this task by creating the form manually - is there anyway I can modify the insert for a form created by the wizard?
-
Default value from another table - sql query
I'm trying to make the default value of a text item as the result from an sql or pl/sql statement. I keep getting errors when I try to use a pl/sql statement to do this. Has anyone else done this?
OK, here is what I tried to put in. I have a form and I wanted to add a text field that is derived from another table, such as:
select question from qa_main where seq=:quest_num
So, what I want is to have a form where questions on tests are answered, and I want the text of the question to be brought over from the question table. I'm not sure if I'm using the correct syntax, but the ":quest_num" would be a reference to a question number in the answer table that is linked to the sequence number (primary key) in the questions table.
Of course if there are better ideas, please let me know. :) -
Validating Tabular Form Column Against Value From Another Table
Hi,
I am brand new to this forum, so please bear with me a little! I only have a small amount of experience writing PL/SQL, and I've never written Javascript or JQuery before. I am an Oracle DBA, and I have coding experience in C and PERL, so I do have a solid technical background. But, I need some advice on the best way to approach a problem.
I have a database application in Oracle Apex (version 4.2) with a tabular form against a table: let's say Table #1 with cols 1A, 1B, and1C. I need to ensure that the value entered into col B isn't greater than the value of a column in another table (let's say Table #2 col 2A). Conceptually, the amount of money available is in Table #2, and the rows of my tabular form are an act of spending money (like orders or invoices), so I need to make sure we don't spend more than we have. Does that make sense?
Does anyone have any advice for the best way to do this? I'm figuring the biggest issue here might be that we have to account for people entering mutliple rows in the tabular form at one time, right? So, if a person entered 3 orders/invoices, I need a total to make sure they didn't spend more than we have in Table #2.
I greatly appreciate your help!
Best Regards,
Laurie BaublitzHi!
You need one process of type ajax callbacks like:
DECLARE
l_limit nubmer;
l_number1 number := apex_application.g_x02;
l_returnValue VARCHAR2(200);
BEGIN
select A2 into l_limit from table2;
if l_number1 > l_limit then
l_returnValue := 'LIMIT IS NOT SO BIG';
if l_returnValue is not null then
--this will write l_returnValue to the buffer, and the ajax callback will receive this
htp.p(l_returnValue);
end if;
end if;
END;
Then you need one javascript on page, code is something like:
$('input[name=your column in tabular which is change]').live('change', function(){
//if value of changed field differs from an empty string
if($(this).val()!=''){
//put target element in a var to reference it in the ajax success callback
var num = $('input[name=your column in tabular with value]');
$.post('wwv_flow.show',
{"p_request" : "APPLICATION_PROCESS=your ajax callback function",
"p_flow_id" : $v('pFlowId'),
"p_flow_step_id" : $v('pFlowStepId'),
"p_instance" : $v('pInstance'),
"x01" : $(this).val(),
"x02" : $(num).val()
function(data){
if(data !=''){
alert(data);
I can not guarante that code is 100% working, if not you need to do some changes or make an example on apex.oracle.com and provide credentials here.
Regards,
drama9346
Maybe you are looking for
-
I have a song that shows in my itunes but when I click to play it, it says file is lost?
I recently went to click on a song in my itunes and an error message came up and said file not found. I have searched everywhere for the song and have had no luck. Is there any way to re-download the song from itunes?
-
Advantages of BW SD reports over the SIS
Hello BI experts, Would like to present the advantages of BW SD reports over the SD SIS reports. 1) Please provide me three main advantages and benefits to clients implementing BW SD reports over the SIS reports. 2) Are there any reports in the SIS s
-
Hi , Want system should capture GRN Posting Date as Base Line date while doing the MIRO. ( If payment term is 30 Days , then system shoulld calculate the 30 Days from GRN posting date ) Any Badi will serve this purpose ( INVOICE_UPDATE ) Thanks in a
-
Hello, is it possible to store Objects like PDF-Files in a Database? If so,...how to? Thanks Peter
-
How do I view all my pictures in Photo Library View?
I have over 4,000 photos. They are all viewable in various libraries but NOT the Photos library. I can only see a few hundred in there. See a screen shot here http://dl.dropbox.com/u/978197/Aperture-03.jpg Thanks =)