Render a column based on other column value in the same table
JDev 11.1.1.6.0
This may be a silly question but I am stuck
I need to conditionally render a column say A. Condition is like if the value in the other column B of same table is equal to F. I should render column A only when this condition is satisfied. I have tried the following code:
<af:column sortProperty="PhoneNumber1"
sortable="false"
headerText="#{bindings.A.hints.PhoneNumber1.label}"
id="c146"
rendered="#{row.PhoneNumber1ResponseFlag eq 'F'}">
<af:outputText value="#{row.PhoneNumber1}"
id="ot130"/>
</af:column>
<af:column sortProperty="PhoneNumber1ResponseFlag"
sortable="false"
headerText="#{bindings.B.hints.PhoneNumber1ResponseFlag.label}"
id="c80" rendered="true">
<af:outputText value="#{row.PhoneNumber1ResponseFlag}"
id="ot129"/>
</af:column>
The data shown in the table for column PhoneNumber1ResponseFlag is F. Still my condition is not working.
Timo was saying that it is not possible to render the column in some situations and not in anothers, you will always have to render the column.
The best way to do this is instead of showing a column with the text ' ', show something meaningfull to the user. This is a DataWarehouse advice to you and may be usefull since you're using ADF in a area that uses DataWarehouse..
So the code could be something like this (based on Timo's code):
<af:column sortProperty="PhoneNumber1"
sortable="false"
headerText="#{bindings.A.hints.PhoneNumber1.label}"
id="c146">
<af:outputText value="#{row.PhoneNumber1ResponseFlag eq 'False.' ? row.PhoneNumber1 : 'No value applied.'"
id="ot130"/>
</af:column>
<af:column sortProperty="PhoneNumber1ResponseFlag"
sortable="false"
headerText="#{bindings.B.hints.PhoneNumber1ResponseFlag.label}"
id="c80">
<af:outputText value="#{row.PhoneNumber1ResponseFlag}"
id="ot129"/>
</af:column>
Hope that helps,
Frederico.
Similar Messages
-
Please Help, I want to change field value in a table, based on another field value in the same row (for each added row)
I am using this code :
<HTML>
<HEAD>
<SCRIPT>
function addRow(tableID) {
var table = document.getElementById(tableID);
var rowCount = table.rows.length;
var row = table.insertRow(rowCount);
var colCount = table.rows[0].cells.length;
for(var i=0; i<colCount; i++ ) {
var newcell = row.insertCell(i);
newcell.innerHTML = table.rows[1].cells[i].innerHTML;
switch(newcell.childNodes[0].type) {
case "text":
newcell.childNodes[0].value = "";
break;
case "checkbox":
newcell.childNodes[0].checked = false;
break;
case "select-one":
newcell.childNodes[0].selectedIndex = 0;
break;}}}
function deleteRow(tableID) {
try {var table = document.getElementById(tableID);
var rowCount = table.rows.length;
for(var i=0; i<rowCount; i++) {
var row = table.rows[i];
var chkbox = row.cells[0].childNodes[0];
if(null != chkbox && true == chkbox.checked) {
if(rowCount <= 2) {
alert("Cannot delete all the rows.");
break;}
table.deleteRow(i);
rowCount--;
i--;}}}catch(e) {alert(e);}}
</SCRIPT>
</HEAD>
<BODY>
<INPUT type="button" value="Add Row" onClick="addRow('dataTable')" />
<INPUT type="button" value="Delete Row" onClick="deleteRow('dataTable')" />
<TABLE id="dataTable" width="350px" border="1">
<TR>
<TD width="32"></TD>
<TD width="119" align="center"><strong>Activity</strong></TD>
<TD width="177" align="center"><strong>Cost</strong></TD>
</TR>
<TR>
<TD><INPUT type="checkbox" name="chk"/></TD>
<TD>
<select name="s1" id="s1">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
</TD>
<TD><input type="text" name="txt1" id="txt1"></TD>
</TR>
</TABLE>
</BODY>
</HTML>Hi,
Let me make sure u r working with table control.
First u have to create a event(VALIDATE) to do the validation.
Inside the event,
1. First get the current index where user has pointed the curson
2. Once u get the index read the internal table with index value.
3. Now u can compare the col1 and col2 values and populate the error message.
1. DATA : lo_elt TYPE REF TO if_wd_context_element,
l_index type i.
lo_elt = wdevent->get_context_element( name = 'CONTEXT_ELEMENT' ).
CALL METHOD LO_ELT->GET_INDEX( RECEIVING MY_INDEX = l_index.
above code should be written inside the event.
Thanks, -
How to insert into date column based on other columns?
Hi
I have four columns in a table called game named as
R_Day - Type - Number
R_Month - Type - Number
R_Year - Type - Number
R_Date - Type - Date
I have around 1000 records and i want to fill R_Date column based on the data in the R_Day,R_Month,R_Year.
How to write a query to fill the R_Date column based on other three columns.
Thanks
srinivasselect
to_date(R_Day||'-'||R_Month||'-'||R_Year,'DD-MM-YYYY')
dt from (select 23 R_Day,07 R_Month,2007 R_Year from
dual);
Hi,
Update <Table Name> set R_Date=select
to_date(R_Day||'-'||R_Month||'-'||R_Year,'DD-MM-YYYY')
from <Table Name>
Regds.
Nirmal
SQL> select * from test;
R_DAY R_MONTH R_YEAR R_DATE
1 1 2007
21 11 2007
SQL> update test
2 set r_date = select to_date(R_Day||'-'||R_Month||'-'||R_Year,'DD-MM-YYYY')
3 from test;
set r_date = select to_date(R_Day||'-'||R_Month||'-'||R_Year,'DD-MM-YYYY')
ERROR at line 2:
ORA-00936: missing expression
SQL> update test
2 set r_date = to_date(r_day||'-'||r_month||'-'||r_year,'dd-mm-yyyy');
2 rows updated.
SQL> select * from test;
R_DAY R_MONTH R_YEAR R_DATE
1 1 2007 01-JAN-07
21 11 2007 21-NOV-07
NB:Please test before posting.. -
To display drill down values in the same table
Dear Friends,
Suppose if you apply drill down on one object, it wont appear upper level values of that perticular object. If you want to display all levels of values in the same report during drill down.From your view I belive that currently you have a structure in Rows containing Shipping and Sales for Current and Last year. Moreover, you have Year in the column and that is the reason you are getting the numbers in two different columns.
My suggestion is like this, remove the KFs from the selection of the structure and keep the name of each of the elements as it is. Remove Year from the Column and include them into selections of the structure elements.
Add the KFs, shipping and Sales into COlumns. Now as you already have restrictions into your selection, your numbers will be restricted in the output, but again here you will have Shipping coming in one column and Sales will be another column.
But you have above mentioned structure, you can include the cell refercing into the query. Overwrite the value of cells at the intersection (Shipping / Current Year) or (Shipping / Last Year) with the adjustant cells which will be (Sales / Current Year) and (Sales / Last Year).
______________________Shipping_____Sales
Shipping (Current Year)______1000
Sales (Current Year)__________________1000
Shipping (Last Yera)_________2000
Sales (Last Year)_____________________5000
After you apply cell referencing, 1000 and 5000 sales will be filled in the empty cells next of shipping next to sales.
- Danny -
Need to filter unique columns based on other column's values
I'm rookie and I'm running this query:
SELECT TO_NUMBER (hs_key) bug, "HS_TABLE_NAME", "HS_COLUMN_NAME",
"HS_CHANGE_DATE", "HS_CHANGE_TIME", "HS_CHANGER", "HS_NEW_VALUE"
FROM cb_tdqatodo1_history
WHERE (hs_column_name) = 'BG_STATUS'
AND (hs_new_value) LIKE '%Not a Bug'
AND (hs_change_date, hs_key) IN (
SELECT MAX (hs_change_date) hs_change_date,
hs_key
FROM cb_tdqatodo1_history
GROUP BY hs_key);
The result is
BUG HS_TABLE_NAME HS_COLUMN_NAME HS_CHANGE_DATE HS_CHANGE_TIME HS_CHANGER HS_NEW_VALUE
101 BUG BG_STATUS 12/16/2005 17:49:54 helpdesk Closed Not a Bug
101 BUG BG_STATUS 12/16/2005 12:20:22 hgarcia Not a Bug
1012 BUG BG_STATUS 1/21/2005 08:04:56 helpdesk Not a Bug
1014 BUG BG_STATUS 2/1/2005 14:33:56 lossa Not a Bug
1020 BUG BG_STATUS 1/28/2005 17:04:45 fgonzalez Not a Bug
I need to resolve the cases when the field BUG has the same value in HS_CHANGE_DATE but different value in HS_CHANGE_TIME without impact the rest of the records?
In this case I need the result just show me one Bug per line.
ThanksBasically you want to create two filters on different columns and have OR clause between them instead of an AND. To acheive this, add both of your filters, once added you will the them in the filters section. Click on AND, and it will change to OR. This should solve your problem.
Look at the below image where you can see two filters with an AND clause. Clicking on AND will change it into OR.
http://gerardnico.com/wiki/_media/dat/obiee/presentation_service/obiee_filters.jpg
Close thread and award points please.
Thanks,
-Amith. -
Calculating a count of rows where value matches another column value in the same table
Hi,
I'm struggling to do something in DAX that seems to me should be super easy (coming from a SQL world)!
That is to count all rows in column 1 where the value matches the current value for column 1?
E.g something like this:
[Col2]=Count of rows in [Col1] where value = this.[Col1]
Where the results are as in the table below:
Col1, Col2
A, 2
A, 2
B, 1
Anyone?
Martin Laukkanen
Nearbaseline blog - nearbaseline.com/blog
Bulk Edit and other Apps - nearbaseline.com/appsThanks, that's perfect!
I knew it had to be something so simple, but after spending over an hour banging my head against those exact functions I couldn't get anything working!
Martin Laukkanen
Nearbaseline blog - nearbaseline.com/blog
Bulk Edit and other Apps - nearbaseline.com/apps -
Create a query to compare values from the same table
Suppose you have the below table, same ID's occur for same month as well as different month
ID Month Value
226220 201203 100
1660 201204 200
26739 201204 1010
7750 201205 31.1
I need a query to determine the below laid result
ID Month Prior_month_value Prior_Month Value
1234 201203 10 201201 100
3456 201206 56.1 201204 78
Please help
Edited by: Jaguar on Jul 10, 2012 3:00 AMAs mentioned, you can use the analytical function lag...
SQL> ed
Wrote file afiedt.buf
1 with t as (select 226220 as id, 201203 as mnth, 100 val from dual union all
2 select 1660, 201204, 200 from dual union all
3 select 226220, 201204, 1010 from dual union all
4 select 1660, 201206, 31.1 from dual union all
5 select 7750, 201205, 60 from dual)
6 --
7 -- end of test data
8 --
9 select id
10 ,mnth
11 ,val
12 ,lag(mnth) over (partition by id order by mnth) as prev_month
13 ,lag(val) over (partition by id order by mnth) as prev_val
14 from t
15* order by id, mnth
SQL> /
ID MNTH VAL PREV_MONTH PREV_VAL
1660 201204 200
1660 201206 31.1 201204 200
7750 201205 60
226220 201203 100
226220 201204 1010 201203 100Edit to Add...
and to filter out just the ones where there is a previous month...
SQL> ed
Wrote file afiedt.buf
1 with t as (select 226220 as id, 201203 as mnth, 100 val from dual union all
2 select 1660, 201204, 200 from dual union all
3 select 226220, 201204, 1010 from dual union all
4 select 1660, 201206, 31.1 from dual union all
5 select 7750, 201205, 60 from dual)
6 --
7 -- end of test data
8 --
9 select id, mnth, val, prev_month, prev_val
10 from (
11 select id
12 ,mnth
13 ,val
14 ,lag(mnth) over (partition by id order by mnth) as prev_month
15 ,lag(val) over (partition by id order by mnth) as prev_val
16 from t
17 )
18 where prev_month is not null
19* order by id, mnth
SQL> /
ID MNTH VAL PREV_MONTH PREV_VAL
1660 201206 31.1 201204 200
226220 201204 1010 201203 100Edited by: BluShadow on 10-Jul-2012 11:32 -
Updating values with in the same table for other records matching conditions
Hi Experts,
Sorry for not providing the table structure(this is simple structure)
I have a requirement where i need to update the columns of a table based on values of the same table with some empid and date match. If the date and empid match then i have take these values from other record and update the one which is not having office details. I need the update query
Before update my table values are as below
Sort_num Emp_id office start_date
1 101 AUS 01/01/2013
2 101 01/01/2013
3 101 15/01/2013
4 103 USA 05/01/2013
5 103 01/01/2013
6 103 05/01/2013
7 104 FRA 10/01/2013
8 104 10/01/2013
9 104 01/01/2013
After update my table should be like below
Sort_num Emp_id office start_date
1 101 AUS 01/01/2013
2 101 AUS 01/01/2013
3 101 15/01/2013
4 103 USA 05/01/2013
5 103 01/01/2013
6 103 USA 05/01/2013
7 104 FRA 10/01/2013
8 104 FRA 10/01/2013
9 104 01/01/2013
Thanks in advanceI do not have time to create the table with data but basically you should be able to code the following
update table a
set office = ( select office from table b where b.emp_id = a.emp_id
and b.start_date = a.start_date
and b.office is not null
where exists ( [same query as in set] )
and a.office is null
I believe that will do the trick.
HTH -- Mark D Powell -- -
Logical (Business) Column based on physical column value
Hello everyone,
I'm new to here. I've been more of a reader than poster so far, but hopefully, I could offer some advice too.
My question today is the following - let's say I have brought 2 columns to the physical layer (in the same table or in different, but joined - it doesn't really matter). 1 column is defining EXPENSE_TYPE (such as "Air Travel", "Car rental", "Hotel"...Another column is simply EXPENSE_AMT.
I'd like to create 3 logical columns name AIR_TRAVEL_AMT, CAR_RENTAL_AMT, HOTEL_AMT in the busines layer based on the EXPENSE_AMT and EXPENSE_TYPE (AIR_TRAVEL_AMT= EXPENSE_AMT Where EXPENSE_TYPE="Air Travel")
I know that best practices would make me create those columns in the fact table during in ETL process, however, I have no choice here now.
My question is - how do I do it (I think it could be either variable/initialization block item - or possible I could write a CASE statement?).
Is this method going to affect performance negatively?
Thank you in advance.
UPD: I think it's possible to do this using something like
CASE WHEN Expense_Type = "AirType" THEN 1 else 0
am I on correct path on figuring this one out?
Message was edited by:
wildmightHi Wildmight,
you´re right, you can do it with a CASE statement:
For AIR_TRAVEL_AMT:
CASE WHEN EXPENSE_TYPE="Air Travel" THEN EXPENSE_AMT ELSE 0 END
Regards. -
Data of column datatype CLOB is moved to other columns of the same table
Hi all,
I have an issue with the tables having a CLOB datatype field.
When executing a simple query on a table with a column of type CLOB it returns error [POL-2403] value too large for column.
SQL> desc od_stock_nbcst_notes;
Name Null? Type
OD_STOCKID N NUMBER
NBC_SERVICETYPE N VARCHAR(40)
LANGUAGECODE N VARCHAR(8)
AU_USERIDINS Y NUMBER
INSERTDATE Y DATE
AU_USERIDUPD Y NUMBER
MODIFYDATE Y DATE
VERSION Y SMALLINT(4)
DBUSERINS Y VARCHAR(120)
DBUSERUPD Y VARCHAR(120)
TEXT Y CLOB(2000000000)
NBC_PROVIDERCODE N VARCHAR(40)
SQL> select * from od_stock_nbcst_notes;
[POL-2403] value too large for column
Checking deeply, some of the rows have got the data of the CLOB column moved in another column of the table.
When doing select length(nbc_providercode) the length is bigger than the datatype of the field (varchar(40)).
When doing substr(nbc_providercode,1,40) to see the content of the field, a portion of the Clob data is retrieved.
SQL> select max(length(nbc_providercode)) from od_stock_nbcst_notes;
MAX(LENGTH(NBC_PROVIDERCODE))
162
Choosing one random record, this is the stored information.
SQL> select length(nbc_providerCode), text from od_stock_nbcst_notes where length(nbc_providerCode)=52;
LENGTH(NBC_PROVIDERCODE) | TEXT
-------------------------+-----------
52 | poucos me
SQL> select nbc_providerCode from od_stock_nbcst_notes where length(nbc_providerCode)=52;
[POL-2403] value too large for column
SQL> select substr(nbc_providercode,1,40) from od_stock_nbcst_notes where length(nbc_providercode)=52 ;
SUBSTR(NBC_PROVIDERCODE
Aproveite e deixe o seu carro no parque
The content of the field is part of the content of the field text (datatype CLOB, containts an XML)!!!
The right content of the field must be 'MTS' (retrieved from Central DB).
The CLOB is being inserted into the Central DB, not into the Client ODB. Data is synchronized from CDB to ODB and the data is reaching the client in a wrong way.
The issue can be recreated all the time in the same DB, but between different users the "corrupted" records are different.
Any idea?939569 wrote:
Hello,
I am using Oracle 11.2, I would like to use SQL to update one column based on values of other rows at the same table. Here are the details:
create table TB_test (myId number(4), crtTs date, updTs date);
insert into tb_test(1, to_date('20110101', 'yyyymmdd'), null);
insert into tb_test(1, to_date('20110201', 'yyyymmdd'), null);
insert into tb_test(1, to_date('20110301', 'yyyymmdd'), null);
insert into tb_test(2, to_date('20110901', 'yyyymmdd'), null);
insert into tb_test(2, to_date('20110902', 'yyyymmdd'), null);
After running the SQL, I would like have the following result:
1, 20110101, 20110201
1, 20110201, 20110301
1, 20110301, null
2, 20110901, 20110902
2, 20110902, null
Thanks for your suggestion.How do I ask a question on the forums?
SQL and PL/SQL FAQ -
Nsert/Update and Add Column at the same Table and at the "same" Time
Hello,
I want Insert/Update and Add Column at the same Table and at the "same" Time but in different sessions.
Example:
At first the "insert/update" statement:
Insert into TestTable (Testid,Value) values (1,5105);
After that the "add" statement:
Alter table TestTable add TestColumn number;
- sadly now I get the message: ORA-00054: resource busy and acquire with NOWAIT specified
"insert/update" statement:
Insert into TestTable (Testid,Value) values (2,1135);
After that the execute commit.
I don't know when the first session set the commit statement so I want that the DB the "Alter Table..." statement execute if it's possible.
If it's possible I want to save a repeat loop with the "Alter Table..." statemtent.
Thanks for ideasWell I want to walk in the rain without and umbrella and still stay dry, but it ain't gonna happen.
You can't run a DDL statement against a table with transactions pending. Session 2 has to wait until session commits or rollbacks (or until the session is killed). That's just the way it is.
This makes sense if you think about it. The data dictionary has to be consistent across all sessions. If session 2 was allowed to change the table structure whilst session 1 has a pending transaction then the database is in an inconsistent state. This is easier to see if you consider the reverse situation - the ALTER TABLE statement run by session 2 does a DROP COLUMN TESTID rather than adding a column: now what should happen to session 1's INSERT statement? You have retrospectively invalidated a statement that was perfectly legal when it was executed.
If it's possible I want to save a repeat loop with the "Alter Table..." statemtent.Fnord.
Cheers, APC -
In Pages 5.2.2: How do you go from 1 column to 2 and keep them on the same page?
Sorry, I tried to say your answer solved my question, but I guess I told it that my response to you solved it. Now that I liked it, the solved option doesn't appear.
-
How to sum different column in the same table
Hi everyone
I would like to know how can I make the sum of different column in the same table using apex
exple:
TR_PROJ_BIL_TRIM.ENTPIDFISC as ENTPIDFISC,
TR_PROJ_BIL_TRIM.EXEANNEE as EXEANNEE,
TR_PROJ_BIL_TRIM.PROJBILTRIMT1PREV as PROJBILTRIMT1PREV,
TR_PROJ_BIL_TRIM.PROJBILTRIMT2PREV as PROJBILTRIMT2PREV,
trunc( TR_PROJ_BIL_TRIM.PROJBILTRIMT1PREV)+(TR_PROJ_BIL_TRIM.PROJBILTRIMT2PREV)
from TR_PROJ_BIL_TRIM TR_PROJ_BIL_TRIM
group by TR_PROJ_BIL_TRIM.ENTPIDFISC,TR_PROJ_BIL_TRIM.EXEANNEE
but while trying to run this script i get this error message:"ORA-00979: not a GROUP BY expression"
thanks for reading me and I hope to hear from you soonHi,
Your question do not have anything do with APEX.
It is pure SQL question and you will get better answer this kind questions from SQL and PL/SQL forum
You need have GROUP BY when you use aggregate functions like SUM.
I assume you like just add two columns.
Try
SELECT ENTPIDFISC
,EXEANNEE
,PROJBILTRIMT1PREV
,PROJBILTRIMT2PREV
,trunc(PROJBILTRIMT1PREV) + (PROJBILTRIMT2PREV)
FROM TR_PROJ_BIL_TRIM
Regards,
Jari -
Two columns in the same table that are foreign keys to the same master key
i want to create a table let say X, which have two columns that are foreign key that reference the same column in the master table, so does this count as bad database design.
here is the full ddl for the two table, where in the second table there are two columns that represent the primary key and they are also two foreign keys to the same columns in the master table (items)
Desc item table;
Item_id
Item_name
Item_price
Item_quantitiy
Create table item_recommendation ( item_id varchar(20), recommended_item varchar(20),
CONSTRAINT recom_primary PRIMARY KEY (item_id, recommended_item),
CONSTRAINT F1 FOREIGN KEY (item_id) REFERENCES items(item_id), ),
CONSTRAINT F2 FOREIGN KEY (recommended_item) REFERENCES items(item_id)); -
How to add column to report from the same table? Gives error now
Steps to reproduce:
Build a report on a table with easy report, select all columns
Add column to the table
Edit report and add column (one has to click Show Related Tables Only: No to view the same table!)
Report will give error as it will be build as
SELECT ... FROM table1, table1AH HAAA!!!!
And I was afraid to convert from the "SQL (Structured Query)" to "SQL". Probably because I blew up my other reports...
Thanks!
Maybe you are looking for
-
How can I recover my icloud address?
It's been over a year since I last used my icloud address. I cannot recall it and I don't know where to get the help to recover it. I need my icloud address to be able to activate my iPhone 5, I've tried everything, I've tried to get help with an A
-
I have 2 client workspaces 102 (Live) and 105 (Testing) and also have the same thing replicated in my own environment 102 and 105, the idea is that I develop changes in my 105 workspace and export/import into the client 105 for testing and then the c
-
What is initial username and password for AWS instance?
I have a newly created Media Server on Amazon Web Services. The vm was created from ami-44cd4274. The server is running. What is, or how do I find, the default username and password for the Administration Console?
-
What are the main instruction followed in flatfile for hierarchy
what are the main instruction followed in flatfile for hierarchy
-
Lightroom keeps installing to the default install location even though I have a specific install location set in the application manager. Is there a fix for this issue?