WriteBack: Update a field based on two conditions.
Hi Experts,
I am facing a serious problem in write back to database.
Let me explain the writeback i am trying to do.
I have a table as Below
Col1----- Col2---------Col3----------Col4
100--------1-------------2----------100/(1+2)
Col1,col2,col3 are editable.
Once the values are entered in these columns Col4 is calculated by the formula (Col1/(Col2+Co3))
If the user enters 0 in col2 and col3 then it will be a division by zero which i have handled by the DECODE function
But the user requires a standard value to be shown there that is Col1/0.57895 whenever he enters 0 in col2 and col3.
I initiially put a column formula for Col4 in answers saying if col2 or col3 = 0 then (Col1/0.57895)
But as this formula is only at the prsentation level...teh values were not getting saved in the database.
My requirement is i need to put this condition in the writeback xml itself and see to it that this standard value be updated in the table itself.
like
update table set col4=Col1/0.57895 where col2=0 and col3=0
Update table set col4=(Col1/(Col2+Co3)) where col2 <>0 or col3<>0
I am unable to use two update queries in teh xml template.
Please let me know how can i implement this in the xml template.
Appreciate your immediate response.
-Best Regards!
You can't do it in the xml but you can do it in the database with a before trigger update
http://www.techonthenet.com/oracle/triggers/before_update.php
Similar Messages
-
Unable to filter a formula field based on two conditions
hi,
I have a report with 3 subreports in it. When i drill down onto first subreport i am getting correct records in details based on selection criteria but when i am unable to populate the same record count in summary.
For example
On summary i see : 60 when i drill down i see 20 records which is correct but not reflecting onto summary report
the details selection criteria is based on two fields where field1>=1 and field2= "Text"It is coming out good (20 records) but in summary i am unable to populate this based on same selection criteria
The main issue i am facing was if i apply a filter on summary selection criteria all the subreport counts are getting affected. Is there a way i can apply filters only one one field
Please suggest
Thanks!
LuckyThanks! for the prompt response Abhilash
I got part of what you told me. Yes i am calculating the counts in the summary report.
Basically here is the selection criteria: i need to filter the records based on two conditions. One is x.field1= "Admin" and x.field2=act_pct>=1
For example:
Admin Returns 50 but when i dig into details it showing as 20 records ( based on selection criteira above)
when coming back to summary . 50 what ever is returing here is based on a formula ( if x.field1="admin" then 1 else 0) ..in addition to this i need to filter that by x.field2>=1 which is not taking it
Is there any syntax to do this
If i apply a filter on this particular 50 record its bee applying for whole summary report ...
And from what you said :
Why don't you create the summary in the Subreport and maybe use shared variables to bring it back to the Main Report?
i did not get this
Please suggest
Lucky -
Suppressing a section based on two conditions
Hello
currently, I am trying to suppress a section of group based on two conditions:
- The first condition is to suppress the section always if the user is not at DrillDownGroupLevel 1.
- The second condition is to supress the section if the GroupName ({Customer.TerritoryID}) is not UK or US.
I went to the section expert and entered this code in the "Suppress (No drill-down)" x-2 formula field:
DrillDownGroupLevel <> 1 AND
GroupName ({Customer.TerritoryID}) <> "US" OR
GroupName ({Customer.TerritoryID}) <> "UK"
Unfortunately, it does not work. Any ideas are very welcome!!
I am using Crystal Reports XI
Thanks in advance!!Which "section of a group" are you trying to conditionally suppress? (group header, group footer or details within a particular group......or all of them?)
AND you stated,
"currently, I am trying to suppress a section of group based on two conditions:
The first condition is to suppress the section always if the user is not at DrillDownGroupLevel 1.
The second condition is to supress the section if the GroupName ({Customer.TerritoryID}) is not UK or US.
Try this formula for the conditional suppression:
(DrillDownGroupLevel <> 1) AND
(GroupName ({Customer.TerritoryID}) "US") OR
(GroupName ({Customer.TerritoryID}) "UK")
If that does not work you may want to check and make sure your values are upper case in the TerritoryID.
In addition, a GOOD way to test conditional suppression formulas is to put them into a conditional highlighting color for the section so you can still see the values and the highlighting lets you know if it's working. For example:
IF
(DrillDownGroupLevel <> 1) AND
(GroupName ({Customer.TerritoryID}) "US") OR
(GroupName ({Customer.TerritoryID}) "UK")
then YELLOW else WHITE -
DBPolling based on two conditions
Hi All,
We have a requirement in our bpel to process to poll the DB based on two conditions as we know how to poll on DB for one conditions.
Any help is highly appreciated.
Thanks and Regards,
Nagaraju .DSorry it is late here, I was thinking of selecting data, forget what I have said.
Polling condition needs to be a sequence so there is no possibility of missing rows. Things like date, id etc
If you need to use multiple conditions you need to concatinate the fields as part of the select statement. You may need to create a view for this.
Obviously if you are doing a physical delete, or a logical delete there is no such issue as BPEL will read every row that is in the table, or where the flag is set to not processed.
Hopefully this helps, sorry for mucking you around
cheers
James -
Start Local chain based on two conditions
Hello,
I want to trigger a local chain in a metachain based on success of two conditions.
1) at a stipulated time.
2) and on the completion of above process.
Also is there a function module by which i can get the variant name of a process.how can this be achieved.
Thanks
Dutta -
Joins on different fields based on a condition
Hi,
I have 2 tables, each consists of 5 fields, based on Field3's data, I want to join either F1 & F2 or F4 & F5.
I have given below the field creation and sample data for your reference. When I run the SQL with "case when .."
statement, it gives "ORA-00905: missing keyword" error.
I can do this by splitting into 2 separate SQL statements one for F1 & F2 and the other for F4 and F5.
Is there any other better way of doing it in a single SELECT statement?
Please share your views, thank you.
create table tmp_a
(f1 varchar2(50),
f2 varchar2(50),
f3 char(1),
f4 varchar2(50),
f5 varchar2(50))
create table tmp_b
(f1 varchar2(50),
f2 varchar2(50),
f3 char(1),
f4 varchar2(50),
f5 varchar2(50))
begin
insert into tmp_a
values('R1', 'abc', 'L', 'A1', 'B1');
insert into tmp_a
values('R2', 'lkj', 'L', 'A2', 'B2');
insert into tmp_a
values('R3', 'qwe', 'M', 'A3', 'B3');
insert into tmp_a
values('R4', '123', 'M', 'A4', 'B4');
insert into tmp_b
values('R3', 'qwe', 'L', 'A1', 'B1');
insert into tmp_b
values('R2', 'lkj', 'L', 'A2', 'B2');
insert into tmp_b
values('R4', '123', 'M', 'A3', 'B3');
insert into tmp_b
values('R1', 'abc', 'M', 'A3', 'B3');
commit;
end;
select * from tmp_a;
select * from tmp_b;
select a.*, b.*
from tmp_a a, tmp_b b
where a.f1 = b.f1 and a.f2 = b.f2;
select a.*, b.*
from tmp_a a, tmp_b b
where a.f4 = b.f4 and a.f5 = b.f5;
select a.*, b.*
from tmp_a a, tmp_b b
where case when a.f3 = 'L' then
a.f4 = b.f4 and a.f5 = b.f5
else
a.f1 = b.f1 and a.f2 = b.f2
end;Maybe something like:
SQL> SELECT a.*, b.*
2 FROM tmp_a a, tmp_b b
3 WHERE CASE
4 WHEN a.f3 = 'L'
5 THEN a.f4
6 ELSE a.f1
7 END = CASE
8 WHEN a.f3 = 'L'
9 THEN b.f4
10 ELSE b.f1
11 END
12 AND CASE
13 WHEN a.f3 = 'L'
14 THEN a.f5
15 ELSE a.f2
16 END = CASE
17 WHEN a.f3 = 'L'
18 THEN b.f5
19 ELSE b.f2
20 END
21 /
F1 F2 F F4 F5 F1 F2 F F4 F5
R1 abc L A1 B1 R3 qwe L A1 B1
R2 lkj L A2 B2 R2 lkj L A2 B2
R3 qwe M A3 B3 R3 qwe L A1 B1
R4 123 M A4 B4 R4 123 M A3 B3
4 rows selected.Regards,
Jo
Edited by: Joice John on Jul 17, 2009 4:30 AM
Sigh!!! Sean you are too fast for me.... ;) -
Select or update a field based on a column on another row
hi
I have some 5000 rows for the following combination of columns. Each combination has two rows. The only difference between these two rows is an indicator field. If one row for the same combination is having indicator as 'M' the other row for the same combination should ideally have indicator 'R'. But unfortunately the other row's indicator is null.
ie. if the first row for same combination of fields, indicator is 'M. then other one is null which should have been 'R'. If the first row is 'R' then other one is again null which should have been 'M'.
PRODUCT_NO STATE MONTH INDICATOR
1001 CA SEPT M
1001 CA SEPT null
1002 NY OCT R
1002 NY OCT null
Here for the first combination indicator is M and other one is null. But i need to update it to 'R' since other rows is M.
Same way for second combination first row is R second row then should have M as indicator.
Basically it is changing field to a value based on the value in the other rows indicator for the same combination of the above columns.
Please help if anybody has idea to do this in simple steps
ThanksIs this what you are looking for?
WITH TABLE_A AS
SELECT '1001' PRODUCT_NO, 'CA' STATE, 'SEPT' MONTH, 'M' INDICATOR FROM DUAL UNION ALL
SELECT '1001' PRODUCT_NO, 'CA' STATE, 'SEPT' MONTH, null INDICATOR FROM DUAL UNION ALL
SELECT '1002' PRODUCT_NO, 'NY' STATE, 'OCT' MONTH, 'R' INDICATOR FROM DUAL UNION ALL
SELECT '1002' PRODUCT_NO, 'NY' STATE, 'OCT' MONTH, NULL INDICATOR FROM DUAL UNION ALL
SELECT '1003' PRODUCT_NO, 'LA' STATE, 'NOV' MONTH, 'R' INDICATOR FROM DUAL UNION ALL
SELECT '1003' PRODUCT_NO, 'LA' STATE, 'NOV' MONTH, 'M' INDICATOR FROM DUAL
SELECT
PRODUCT_NO,
STATE,
MONTH,
DECODE(A.INDICATOR,NULL,(SELECT DECODE(B.INDICATOR,'R','M','R') FROM TABLE_A B WHERE B.PRODUCT_NO = A.PRODUCT_NO AND B.STATE = A.STATE AND B.MONTH = A.MONTH AND B.INDICATOR IS NOT NULL), A.INDICATOR) INDICATOR
FROM
TABLE_A A -
Having a problem using Workflow to update a field based on ZIP code
I created a Workflow to update a Yes/No picklist called eligibility based on a Text (Short) field called Applicant ZIP code.
It's set to update on the Opportunity page:
Before modified record saved
And the value function is:
IIf(InStr("60601_60602",[<stApplicant_Zip_Code_ITAG>|http://forums.oracle.com/forums/]+)>0,"Yes","No")+
That was a guess of how to try it while relying on my limited MS SQL & Access knowledge.
It does work correctly using what I did. The problem I have is that I actually need to choose from over 600 ZIP codes. The function window only allows for 256 characters. (And I suspect my way is fairly inelegant for search a multi-thousand character string.)
Any suggestions?I created a Workflow to update a Yes/No picklist called eligibility based on a Text (Short) field called Applicant ZIP code.
It's set to update on the Opportunity page:
Before modified record saved
And the value function is:
IIf(InStr("60601_60602",[<stApplicant_Zip_Code_ITAG>|http://forums.oracle.com/forums/]+)>0,"Yes","No")+
That was a guess of how to try it while relying on my limited MS SQL & Access knowledge.
It does work correctly using what I did. The problem I have is that I actually need to choose from over 600 ZIP codes. The function window only allows for 256 characters. (And I suspect my way is fairly inelegant for search a multi-thousand character string.)
Any suggestions? -
Dynamic Action - How to enable text field based on a condition
Hi,
I have two text items. Need to create dynamic action for the following,
1. Order_type - Drop down values having CONSUMER & WHOLESALE.
2. Order_number- Text field
Order number should be disabled and only on selection of order type ,order number should be enabled.
Can someone please help me on this?Hi Gayathri,
Gayathri Venugopal wrote:
Hi,
I have two text items. Need to create dynamic action for the following,
1. Order_type - Drop down values having CONSUMER & WHOLESALE.
2. Order_number- Text field
Order number should be disabled and only on selection of order type ,order number should be enabled.
Can someone please help me on this?
Create two dynamic action
1. Make it order number item disable on page load.
Event : Page Load
Action : Disable
Fire When event result is : True
Selection Type : Item
Item : Your order number item
2 . enable and disable order number on selection of order type(assuming when order type is null it is disable otherwise it is enable)
Event : Change
Selection type : item
Item : your order type item
condition : is not null
True Action
Action : Enable
Fire When event result is : True
Fire on page load : True
Selection Type : Item
Item : Your order number item
False Action
Action : Disable
Fire When event result is : False
Fire on page load : True
Selection Type : Item
Item : Your order number item
Hope this helps you,
Regards,
Jitendra -
Update a field based on a max select query
Hi
I am just learning SQL so apologies if this is simple to you guys.
I have a table called [Stock WIP Table] which has duplicates in it. I have an [autonumber] field, a [palletid] field, and a [number5] field. I have the select query working to show the most recent record for each palletID:
SELECT
PalletID,MAX(autonumber)
FROMdbo.[Stock
WIP Table]
GROUPBYPalletID
How do I get the query to now delete all rows that are not in the select query?
Alternatively how could I add update the [number5] field to '1' where the [autonumber] is in the select and I can then delete all records that do not contain a '1' in [number5]
Can anyone help?
Thanks
AJHi
I am just learning SQL so apologies if this is simple to you guys.
I have a table called [Stock WIP Table] which has duplicates in it. I have an [autonumber] field, a [palletid] field, and a [number5] field. I have the select query working to show the most recent record for each palletID:
SELECT
PalletID,MAX(autonumber)
FROMdbo.[Stock
WIP Table]
GROUPBYPalletID
How do I get the query to now delete all rows that are not in the select query?
Alternatively how could I add update the [number5] field to '1' where the [autonumber] is in the select and I can then delete all records that do not contain a '1' in [number5]
Can anyone help?
Thanks
AJ
Simply this for the DELETE
DELETE t
FROM dbo.[Stock WIP Table]t
WHERE EXISTS (SELECT 1
FROM dbo.[Stock WIP Table]
WHERE PalletID = t.PalletID
AND autonumber > t.autonumber)
No need of UPDATE bit value and then deleting. just above will ensure it gets deleted in single step
another method you may use is this
DELETE t
FROM dbo.[Stock WIP Table] t
CROSS APPLY (SELECT MAX(autonumber) AS MaxID
FROM dbo.[Stock WIP Table]
WHERE PalletID = t.PalletID
)t1
WHERE t1.MaxID <> t.autonumber
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
Update multiple rows based on two columns in same row
I have a 1000 rows in a table I would like to update with a unique value. This unique value is a cocatenation of two columns in teh same row.
Each row has a (i) date and a (ii) time and a (iii) date_time column. I would like to update the date_time (iii) column with a cocatenation of the (i) date and (ii) time columns.
I know how I would update a single row but how can I update multiple rows with a cocatenation of each of the two columns - i.e put a different value into the date_time column for each row?this?
update table tab_name
set date_time =date||time
where your_condition -
Need Trigger that format a field based on two other fields
Hello!
I need to write a trigger, that reads on field and made some changes to it and saves the result in an other field in the same row. The trigger should work in insert and update cases.
Does anybody can send me a frame, where i can fill my logic?
Regards
Heiko GlaeskeIn this example, column1 and column2 are the values being examined and the resultant expression is saved in column3.
create or replace trigger trigger_name
before insert or update on table_name
for each row
begin
:new.column3 := :new.column1 + :new.column2;
end;
/ -
Hiding a caption and field based on context condition
Hi,
I have what should be a simple problem, but I'm not sure if what I'm doing is the correct way to solve it.
I have a telephone number of a user master being output, and if there is an extension number I want to output that as well, separated by ext
In the context node I have put a condition on the Extension field (GS_HEADER-FSABE-TEL_EXTENS1 not equals INITIAL), and debugging the code of the function module shows that %OUTPUT is not being called for the Extension field in the layout as expected.
The Extension field in the layout is bound to the Extension field in the context, and the caption is set as "Ext"
Therefore I either want to output
Telephone: 01234 567890 ext 1234
or
Telephone: 01234 567890
It's not working though, as I still get ext printing even when there is no Extension - have I done something wrong or is this not the correct way to go about this?
Thanks,
VindalooThanks very much, this has solved the problem
In the layout:ready event for the extension field I have put the following Javascript:
// Hide the Telephone Extension caption & value if it is not populated
if (this.rawValue == null) {
this.presence = "hidden";
I was under the misapprehension that simply putting a condition onto the field in the context would stop it being passed to the form and rendered.
The layout:ready event seems to be the best place to put this code. However, the adobe help for this event is confusing as it contains the following:
Initiates after the form design and data are merged, the form exists, and the form's layout is applied. At this time, the finished form has not been rendered; therefore, a calculation or script set to run on this event could modify the layout before the form is rendered.
This is fine and fits in with what I have. It then goes on to say:
Note: Scripts that fire on layout:ready should not do anything that would cause the layout of the form to change. For example, this would include anything involving subforms or tables that grow or shrink, adding fragments dynamically at run time, adding or removing subform instances, and toggling the presence setting of an object between hidden and visible.
This seems to be in direct conflict with the previous statement, regarding modifying the layout.
Vindaloo -
Top 10 based on two conditions
Hello BW Experts,
Wondering if this is possible in Bex.
-- by default show the top 10 customer based on gross sales
-- then give a navigational option in the context menu to show the top 10 customers by net sales.
can this be achieved in bw using conditions.
Any suggetions is greatly appreciated.
Thanks,
BWerHi BWer,
It is possible to do this using conditions. Start creating a condition in the query and use the Top N condition. Create 2 of these: One for each key figure. Then in the report you can activate and deactivate them to see results are desired.
Hope this helps... -
Best way to validate currency field based on two picklists
Hi,
Im having a great deal of trouble creating validation for the following statement:
If (Task type =”Call” or “Callback”) and (‘Outcome Category’ is “In Progress” or “Tried and Failed to Save” or “Saved”) then (‘Total Value of Policy’ must be > 0)
Both task type and outcome category are picklist items.
What is the easiest way for me to do this? Ive created something horribly complex which only works when I first create the record (possibly because of the use of FieldValue rather than stored values). Ive seen people use the NOT function before to do this - could this be an option?! Ive had no luck with anything Ive tried so far.
My current expression is as follows:
(FieldValue('<cTotal_Value_of_Policy_ITAG>') > 0
AND FieldValue('<Type>') <> LookupValue("TODO_TYPE", "Investigation") - - Because call or callback are the only other options in the list.
AND (FieldValue('<IndexedPick2>') <> LookupValue("OCC_INDEX_CUST_LOV_EVT_ACT_2", "In progress")
OR FieldValue('<IndexedPick2>') <> LookupValue("OCC_INDEX_CUST_LOV_EVT_ACT_2", "Tried & failed to save")
OR FieldValue('<IndexedPick2>') <> LookupValue("OCC_INDEX_CUST_LOV_EVT_ACT_2", "Saved")))
OR FieldValue('<Type>') = LookupValue("TODO_TYPE", "Investigation")
OR (FieldValue('<Type>') = LookupValue("TODO_TYPE", "Call")
AND (FieldValue('<IndexedPick2>') <> LookupValue("OCC_INDEX_CUST_LOV_EVT_ACT_2", "In progress")
AND FieldValue('<IndexedPick2>') <> LookupValue("OCC_INDEX_CUST_LOV_EVT_ACT_2", "Tried & failed to save")
AND FieldValue('<IndexedPick2>') <> LookupValue("OCC_INDEX_CUST_LOV_EVT_ACT_2", "Saved")))
Sorry for including this confusing chunk of code, but I think it explains how more complex i have made this than i probably need to!!
Any help would be greatly appreciated as this is quite an urgent issue..
Many Thanks
AJAnon,
In your edit form, create two hidden items p10_ha, p10_hb (for e.g.) Make the default values for these items as values of p10_item_a and p10_item_b respectively. So when you are processing the update, you have old values in hidden items and new values in p10_item_a and b.
Now create 'after submit' pl/sql computation and put similar code
if p10_ha !=1 and p10_hb !=1 then
if p10_item_a = 1 and p10_item_b = 1 then
-- your business logic here
:p_date_item := sysdate;
end if;
end if;Hope it helps
Cheers
Hari
Edited by: Hari_639 on Oct 27, 2009 9:21 AM
Maybe you are looking for
-
Please help!! Problem synching pictures from Laptop to iPhone4????
Hey guys, I am new to this so I would really appreciate anyones help very much! I just bought a brand new iPhone4 and last year a brand new Toshiba laptop. I dont know a great deal about how Itunes works but I know the basics. I downloaded all my app
-
Hi Everyone, whenever i try to open word (starter) 2010, it says "click-2-run configuration failure" Does anyone know what's going on /how to fix it? Thanks
-
My computer is a brand new HP Pavilion 15-p231tu laptop, I have only had it for about a month and the hardware and software should be current. I am really annoyed by this error as it is interfering with my uni work, so any help would be great. The on
-
Where to add mac filter without template on Prime 2.0?
Hi, Can someone point me to where I should go to add mac filter under security>AAA in Prime 2.0 directly to controller without using templates? Check the screenshot attached. there is no option to add filter. It only give option to edit. Going to Cla
-
OS X 10.5.3 Killed by GlowWorm firewall - Help!!
Hi, My MacBook has just been slaughtered by GlowWorm - I installed the beta 1.5.3b4 and force powered off the macbook because glowworm was not responding and neither were other applications (e.g. Adium) and I couldnt restart or shutdown normally. Aft