Else condition
Hi
I have a requirement, for the contact_typ='IA' then I need to display last name of the contact.
I wrote a case statement,
case when contact_typ='IA' then Last_Name End
but when executed in report I am getting
Mike---$100
peter--$200
IN
GF
SR
YT
I am also getting other types of contact_types in the end. For IA type it is displaying names, for other types it is null. But I only want contact_typ 'IA' in my report. Since I dint include else in my statement, I am getting that output, but knowing what to include in the else.Please help me.
Thanks
SARU
Hi SARU,
As per my understanding and the forum - you need display last name for the contact typ -= 'IA'
And, either you dont want to filter them in logical table source or write a case statement which shows nulls or 'N' and filter by 'N'.
And, you mentioned that you need it from back end.
So, Why dont you create another column in physical table (Database).
Say - I have table employee id, first name, last name, cont type
Now modify it by creating another extra column - display name
So, your table changes to employee id, first name, last name , cont type, display name
Now, based on your condition - update your display name column.
If, your unable to do that in database. Create a new physical table in physical layer - using select statement.
And, generate the table Emp Display -- which holds Employee id, Display name. And, display name gets generated by case statement.
http://allaboutobiee.blogspot.com/2012/03/creating-opaque-view-in-physical-layer.html
this will definitely resolve your issue.
thank you.
Similar Messages
-
IF - Else condition is not working properly in Bex Query Designer
Hi All,
I have a KF called KPI Value. Based on the KPI Value, my report display has to show by using the if-else condition. If the KPI value is '999999' then that particular KPI value has to display as 'X' against to that KPI No. Thats all my requirement. To achieve this I have created a formula based on the KF.
(KPI Value == 999999)*(1/0)+(KPI Value <> 999999)*(KPI Value)*1
Unfortunately, the above expression is shwoing the entire colmn as 'X' irrespective of the KPI value. i.e., logic is not working Could any one please suggest how to achieve this requirement. Your assistance is highly appreciable and very helpful. Thank you in advance!!!
Best Regards
Venkat...AL,
I can visualize how condition should give results. The problem here is reality, I tired in my system with your formula and I got like as I mentioned.
If you observe closely your If..else formula, (KPI Value == 999999)*0+(KPI Value <> 999999)*KPI Value
If KPI Value == 999999 Result is 0, Else(Assuming) KPI Value <> 999999 Result is other nos like 1111, 2222 etc.
Actually it is not If..else, it is IF..ENDIF. Both conditions should get satisfied to give below:--
KPI value Formula
9999 X
1111 1111
2222 2222
9999 X
3333 3333
4444 4444
9999 X
In the course of adding both conditions results, system is not able to add 0+ Other Values in single column. So it is giving mixed values * like below:--
KPI value Formula
9999 X
1111 *
2222 *
9999 X
3333 *
4444 *
9999 X
Note: Once again I want to say it is not to prove you wrong. Let's get some clarity on the issue. I might be also wrong. But I want to know the actual result. If you can test it tomorrow and let me know..it would be great.
Regards,
Suman -
I have to use count function in "if-else" condition in rtf tempelate
I have a nedd to use count fucntion in my rtf fucntion in IF-ELSE condition like this :
if
(count INVOICE_LEVEL from xml where (INVOICE_LEVEL=SM_SUMMARY_LEVEL)) = (count coloumn_A from xml ) --- if the count matches
THEN print "NO DATA FOUND"
else --- if not
end if ;
--------XML------
<COMP123>
<SM_SUMMARY_LEVEL>2</SM_SUMMARY_LEVEL>
<SM_CHARGE_HEAD>2</SM_CHARGE_HEAD>
<INVOICE_LEVEL>2</INVOICE_LEVEL>
<RCVR_ADDRS3_PART1>SG</RCVR_ADDRS3_PART1>
<RCVR_ADDRS3_PART2>ASIA ,</RCVR_ADDRS3_PART2>
<TXN_CSTMR_REF>ABC-DEF</TXN_CSTMR_REF>
<TAX_ID>PCT-ID</TAX_ID>
</COMP123>
<COMP123>
<SM_SUMMARY_LEVEL>2</SM_SUMMARY_LEVEL>
<SM_CHARGE_HEAD>2</SM_CHARGE_HEAD>
<INVOICE_LEVEL>2</INVOICE_LEVEL>
<RCVR_ADDRS3_PART1>SG</RCVR_ADDRS3_PART1>
<RCVR_ADDRS3_PART2>ASIA ,</RCVR_ADDRS3_PART2>
<TXN_CSTMR_REF>ABC-DEF</TXN_CSTMR_REF>
<TAX_ID>PCT-ID</TAX_ID>
</COMP123>
can any one help me to write the correct syntax and logic for this .
THANKS!I am using the below way but it is not working as desired it is always printing the derived value.
<?xdofx:if (xdofx:round((to_number(to_char(SYSDATE,'JSSSSS'))-to_number(to_char(to_date(DOB_DATE, 'YYYY-MM-DD'),'JSSSSS'))) div 100000)) <= 30 then '(1-30)' else '(1-100)' end if?>
Let me know if i missed anything..
Thanks,
Jana -
RETURN Clause in IF...ELSE Condition in PL/SQL Block
Hi
Could you please explain me the importance of a RETURN Clause in IF..ELSE Condition in PL/SQL Block with
an example.
Regards
Nakul.VHi,
RETURN clause permits get out of the block. For more information you can see [Using the RETURN Statement|http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/subprograms.htm#sthref1683]
SET SERVEROUTPUT ON
BEGIN
IF 1 = 1 THEN
dbms_output.put_line('Before return');
RETURN;
ELSE
dbms_output.put_line('Else');
END IF;
dbms_output.put_line('After if');
END;
Connected to Oracle Database 10g Enterprise Edition Release 10.2.0.1.0
Connected as hr
SQL>
SQL> BEGIN
2 IF 1 = 1 THEN
3 dbms_output.put_line('Before return');
4 RETURN;
5 ELSE
6 dbms_output.put_line('Else');
7 END IF;
8 dbms_output.put_line('After if');
9 END;
10 /
Before return
PL/SQL procedure successfully completed
SQL> Regards,
Edited by: Walter Fernández on Dec 12, 2008 9:41 AM - Adding output
Edited by: Walter Fernández on Dec 12, 2008 9:43 AM - Adding URL... -
Query on handling else condition in Oracle Business Rules.
Hi all.
I am working on Jdeveloper 11.1.1.1.0 Business Rules. While creating rules... i am able to write if conditions around the facts and attributes and also replicate the same using decision tables and is able to derive the action.
My Question is.. can i write an else condition which should be executed when none of the if condition are matched. If we can how... Instead of else condition, is there any way that we can initialize the facts and attributes to be derived to a default value.
Please help me guys in this... If this is not the right foru,... please redirect me to the correct one.. coz i couldnt find a forum for oracle business rules..
Thanks
EldhoThanks a lot for the response..
I have posted the query in
Query on handling else condition in Oracle Business Rules.
Thanks
Eldho -
Procedure with out parameter in if-then-else condition
Hi,
I want to fetch the out parameter of a procedure inside another procedure that has if-then-else condition.
<<Proc1_start>>
if ..
then <<proc2_>> --- with out parameter
end if;
<<proc1_end>>
How to do this...
Thanks.Ummm, the same way you would do it anywhere else?
Declare variable in proc1 to hold the output of proc2 and then call proc2.
John -
Hello,
I have four columns. The value of the fourth column depends on the first three columns. Here are the conditions. Col1 is always 0 or less than 0.
1) if col1 = 0, then col4 = 0
2) if (col2 + col3) + col1 >0, then col4 = col1
3) if (col2 + col3) + col1<0, then a) if col2 + col3 >0 then col4 = col1 - (col2 + col3)
b) if col2 + col3 <0 then col4 = 0
How can I write the if-else statements for the above mentioned conditions?
Please Help!I would suggest handling this at the query level using a case statement.
-
Implementing if then else condition
Hi! All
It would be very helpful if i can get answer of how to implement the condition below, using the functions available in graphical mapping editor....
I need to map 2 source fields to 1 Target field, based on the condition that field(source) is populated in the target field only if field 1 is null.
Source----->Target
part_id1----
>part_num(if part_id1 is null,then part_id2)
part_id2----
>
I tried using if then else function, it is working fine but errors out when part_id is null....need to make it work even when part_id1 or part_id2 is null.If both fields are null it should not populate anything.The boolean function is not accepting null inputs...
Please, let me know if there is a better way to implement this logic...Thanks a lot!
Regards,
PatrickJones,
Have this logic in your mapping:
part_id1>exists>and
part_id1>equals(textfunction)>null(take constant and dont put any value in it)>equals(text funciton)>false
Give the above two to if
Then in the then part give part_id1 and in the else part give part_id2.
So in the above if part_id1 exists and equals to null then part_id2 will be output and part_id1 exists and not equals to null then part_id1 will be the output and part_id1 doesnot exist then part_id2 will be the output.
Regards,
---Satish -
Getting error while using IF - ELSE condition in an LOV....
Hi All,
I have a Table by name TEST having columns - PROJECT,PERSON,MANAGER as shown below.
PROJECT PERSON MANAGER
PR_A ABC YES
PR_B DEF
PR_C XYZ YES
(Please read the above table as - PR_A as a PROJECT ; ABC as PERSON and the entry 'YES' for the manager column.)
The requirement is the entries present in PERSON column should be shown as an LOV provided the conditions are satisfied.
I have two page items - :PItem1 and :PItem2
IF :PItem1='Deletion' THEN
RETURN
SELECT PERSON d, PERSON r
from TEST
WHERE PROJECT =:PItem2 AND MANAGER = 'YES'
ORDER BY 1;
ELSE
RETURN
SELECT PERSON d, PERSON r
from TEST
WHERE PROJECT =:PItem2
ORDER BY 1;
END IF;
But when i run this code, I am getting an error like - ORA-00900: invalid SQL statement
Please help me to correct it.....
Thanks and Regards,
SuhasSELECT person d, person r
FROM TEST
WHERE project = :pitem2
AND NVL (manager, 'NO') =
CASE
WHEN :pitem1 = 'Deletion'
THEN 'YES'
ELSE NVL (manager, 'NO')
END
ORDER BY 1;Denes Kubicek
http://deneskubicek.blogspot.com/
http://www.apress.com/9781430235125
http://apex.oracle.com/pls/apex/f?p=31517:1
http://www.amazon.de/Oracle-APEX-XE-Praxis/dp/3826655494
------------------------------------------------------------------- -
How to acheive IF elseif elseif else condition using std mapping functions
How to perform the following mapping using standard graphical functions:
if (a = 1)
result.addValue("3");
else if (a = 2)
result.addValue("6");
else if (a = 5)
result.addvalue("7");
else if (a = 10)
result.addValue("11");
else
result.addValue(a);
can this requirement be acheived without using a UDF?
Regards
bhaskerUDF is better way to get this done.
you try like this using Standard function:
Const 3 /THEN
(A equals 1) IF (output of ifThenElse) ->TragetFiled
\ELSE
/THEN /(output of IfThenElse input to else of first If)
IF /
\ELSE
Like wise for other conditions....
In else part of ifThenElse, give the output of second ifThenElse. here in ths case you need four ifThenElse.
CodeGenerated:
/ns0:MT_/targetFIELD = iF(const([value=3]), stringEquals(/ns0:MT_XML_OB/A=, const([value=1])),
iF(const([value=6]), stringEquals(/ns0:MT_XML_OB/A=, const([value=2])),
iF(const([value=7]), stringEquals(/ns0:MT_XML_OB/A=, const([value=5])),
iF(const([value=11]), stringEquals(/ns0:MT_XML_OB/A=, const[value=10])), /ns0:MT_XML_OB/A=))))
Ritu
Edited by: Ritu Sinha on Apr 13, 2009 2:48 PM -
How to incorporate If Else condition for MDX
Hi,
I am creating a webi report from a universe built on Bex Query.
Below are my queries:
1) Can we drill on objects created at report level?
2) I am having a dimension "Organizational Unit" which is a BW hierarchy having 6 levels (L1 to L5). Now, i want to modify the L2
level such as it buckets the values of it starting with "Corp" else show other values of it. So i am trying to modify the L2 level
dimension at universe level. Please tell me how to incorporate the If Else MDX condition in it. (condition is as : =If(Left([L02 Organizational Unit];5)="Corp ") Then "Corporate" Else [L02 Organizational Unit])
The version:
BO XI 3.1 SP3
SAP BW 7.1 Patch Level 16
Pls advice <REMOVED_BY_MODERATOR>
Regards,
Akhil
Edited by: Pravender on Dec 10, 2010 8:06 PMThanks for the reply Oscar!!!
I wan't to club some members (starting with Corp) into one bucket and name it as "Corporate" for one of the hierarchy. so i was putting a condition =If(Substr([L2 Level];1;4)="Corp";"Corporate";[L2 Level]).
So how to use this condition at the universe level rater than using at report level because at universe level we need to provide MDX query for the same.
Can you please let me know the syntax put the above condition in terms of MDX recognizable query.
Hope you understood my point.
Many thanks in advance!!!
Regards,
Akhil -
Select statement in if/else condition
Hi i need to write a select statement in the if condition in pl/sql how can i write this
example :
if field_name not in (select statement) then
Is this type of if condition is possible in pl/sql?
thanks in advance for help.Qwerty wrote:
here pick a job example salesman for ename ward, now i want to compare this job that is "salesman" with all the jobs which are before it. that is clerk in line 1 and salesman in line 2Define "before it". There is no order in relational tables. Only ORDER BY means ordered sets. Therefore there is no before/after without ORDER BY. Assuming ORDER BY empno, job count of same job title before empno:
select ename,
job,
count(*) over(partition by job order by empno) - 1 same_job_count_before_empno
from emp
ENAME JOB SAME_JOB_COUNT_BEFORE_EMPNO
SCOTT ANALYST 0
FORD ANALYST 1
SMITH CLERK 0
ADAMS CLERK 1
JAMES CLERK 2
MILLER CLERK 3
JONES MANAGER 0
BLAKE MANAGER 1
CLARK MANAGER 2
KING PRESIDENT 0
ALLEN SALESMAN 0
ENAME JOB SAME_JOB_COUNT_BEFORE_EMPNO
WARD SALESMAN 1
MARTIN SALESMAN 2
TURNER SALESMAN 3
14 rows selected.To find job count of same job title as Ward has before Ward (by empno):
SELECT same_job_count_before_empno
FROM (
select ename,
count(*) over(partition by job order by empno) - 1 same_job_count_before_empno
from emp
WHERE ename = 'WARD'
SAME_JOB_COUNT_BEFORE_EMPNO
1SY. -
How do I use the IF-ELSE condition in a WHERE clause?
I want to merge the condition results of my 2 If statements. First if statement result shows only both 0 result, in second if statement result one of them has to be bigger than 0...
If (Inventory) <> 0 Then
If Apple = "" And Banana = "" Then
strSQL = strSQL & " AND (myApple = 0 AND myBanana = 0)"
End If
End If
If int(Inventory) <> -1 Then
If Apple = "" And Banana = "" Then
strSQL = strSQL & " AND (myApple <> 0 OR myBanana <> 0)"
End If
End If
**Want to get something like this**
If int(Inventory) <> 0 Then
If Apple = "" And Banana = "" Then
strSQL = strSQL & " AND ((myApple = 0 AND myBanana = 0) AND (myApple <> 0 AND myBanana <> 0))"
End If
End If
If int(Inventory) <> -1 Then
If Apple = "" And Banana = "" Then
strSQL = strSQL & " AND (myApple <> 0 AND myBanana <> 0)"
End If
End If
myApple myBanana
0 0
0 0
0 5
1 0
6 0
0 0
continue.....Maybe
with
fruits as
(select null apple,null banana from dual union all
select 'Golden Delicious','Chiquita' from dual union all
select 'Granny Smith',null from dual union all
select null,'Cavendish' from dual
select apple,banana,nvl2(apple,1,0) * nvl2(banana,1,0)
from fruits
APPLE
BANANA
NVL2(APPLE,1,0)*NVL2(BANANA,1,0)
0
Golden Delicious
Chiquita
1
Granny Smith
0
Cavendish
0
Regards
Etbin -
How to call oracle Function which has If else condition in Data Template
Hi,
currently I am working on creating Data Template which uses a Oracle Function which I need to make use in my data template. But I have some confusions on using the same. Could anybody please help me in this regard.
I have a function like this,
function invoice_query (p_facility_id facility.facility_id%TYPE,
p_wave_nbr pick_directive.wave_nbr%TYPE,
p_container_id unit_pick_group_detail.container_id%TYPE,
p_distro_nbr unit_pick_group_detail.distro_nbr%TYPE) return invoice_refcur IS
refcur invoice_refcur;
begin
IF p_wave_nbr IS NOT NULL THEN
OPEN refcur FOR SELECT t1.distro_nbr,
t1.cust_order_nbr,
t1.pick_not_before_date,
SYSDATE,
t1.ship_address_description,
t1.ship_address1,
t1.ship_address2,
t1.ship_address3,
t1.ship_address4,
t1.ship_address5,
t1.ship_city || ', ' || t1.ship_state || ' ' || t1.ship_zip,
t1.ship_country_code,
t1.bill_address_description,
t1.bill_address1,
t1.bill_address2,
t1.bill_address3,
t1.bill_address4,
t1.bill_address5,
t1.bill_city || ', ' || t1.bill_state || ' ' || t1.bill_zip,
t1.bill_country_code,
min(t2.pick_order),
NULL,
t2.wave_nbr
FROM stock_order t1,
pick_directive t2,
unit_pick_group_detail t3
WHERE t1.facility_id = t2.facility_id
AND t1.facility_id = t3.facility_id
AND t2.facility_id = t3.facility_id
AND t1.distro_nbr = t2.distro_nbr
AND t1.distro_nbr = t3.distro_nbr
AND t2.distro_nbr = t3.distro_nbr
AND t1.facility_id = p_facility_id
AND t2.wave_nbr = p_wave_nbr
AND g_scp(p_facility_id, 'interface_tcp_flag') = 'N'
AND t2.pick_type = 'U'
AND t3.group_id in (SELECT t4.group_id
FROM unit_pick_group t4
WHERE t4.facility_id = p_facility_id
AND t4.wave_nbr = p_wave_nbr)
GROUP BY t1.distro_nbr,
t1.cust_order_nbr,
t1.pick_not_before_date,
t1.ship_address_description,
t1.ship_address1,
t1.ship_address2,
t1.ship_address3,
t1.ship_address4,
t1.ship_address5,
t1.ship_city || ', ' || t1.ship_state || ' ' || t1.ship_zip,
t1.ship_country_code,
t1.bill_address_description,
t1.bill_address1,
t1.bill_address2,
t1.bill_address3,
t1.bill_address4,
t1.bill_address5,
t1.bill_city || ', ' || t1.bill_state || ' ' || t1.bill_zip,
t1.bill_country_code,
t2.wave_nbr
ORDER BY MIN(t3.group_id), MAX(t3.slot);
elsif p_container_id is not null then
OPEN refcur FOR SELECT distinct t1.distro_nbr,
t1.cust_order_nbr,
t1.pick_not_before_date,
SYSDATE,
t1.ship_address_description,
t1.ship_address1,
t1.ship_address2,
t1.ship_address3,
t1.ship_address4,
t1.ship_address5,
t1.ship_city || ', ' || t1.ship_state || ' ' || t1.ship_zip,
t1.ship_country_code,
t1.bill_address_description,
t1.bill_address1,
t1.bill_address2,
t1.bill_address3,
t1.bill_address4,
t1.bill_address5,
t1.bill_city || ', ' || t1.bill_state || ' ' || t1.bill_zip,
t1.bill_country_code,
NULL,
t2.dest_id,
null
FROM stock_order t1,
unit_pick_group_detail t2
WHERE t1.facility_id = t2.facility_id
and t1.distro_nbr = t2.distro_nbr
and t1.facility_id = p_facility_id
AND g_scp(p_facility_id, 'interface_tcp_flag') = 'N'
AND t2.container_id = p_container_id;
else
open refcur for SELECT distinct t1.distro_nbr,
t1.cust_order_nbr,
t1.pick_not_before_date,
SYSDATE,
t1.ship_address_description,
t1.ship_address1,
t1.ship_address2,
t1.ship_address3,
t1.ship_address4,
t1.ship_address5,
t1.ship_city || ', ' || t1.ship_state || ' ' || t1.ship_zip,
t1.ship_country_code,
t1.bill_address_description,
t1.bill_address1,
t1.bill_address2,
t1.bill_address3,
t1.bill_address4,
t1.bill_address5,
t1.bill_city || ', ' || t1.bill_state || ' ' || t1.bill_zip,
t1.bill_country_code,
NULL,
NULL,
t3.wave_nbr
FROM stock_order t1,
unit_pick_group_detail t2,
unit_pick_group t3
WHERE t1.facility_id = t2.facility_id
and t2.facility_id = t3.facility_id
and t1.distro_nbr = t2.distro_nbr
and t2.group_id = t3.group_id
and t1.facility_id = p_facility_id
AND g_scp(p_facility_id, 'interface_tcp_flag') = 'N'
AND t2.distro_nbr = p_distro_nbr;
END IF;
return refcur;
end;
I have created data template like following,
<sqlStatement name="Q_INVOICE">
<![CDATA[
SELECT Pack_Slip_R.invoice_query(:P_FACILITY_ID,:P_WAVE_NBR,:P_CONTAINER_ID,:P_DISTRO_NBR) from dual
]]>
</sqlStatement>
But how does I create a element for the "t1.ship_city || ', ' || t1.ship_state || ' ' || t1.ship_zip" column in the oracle function. I normally create an element like following,
<group name="G_INVOICE" source="Q_INVOICE">
<element name="CUST_ORDER_NBR" value="cust_order_nbr"/>
<element name=":dest_id" value="dest_id"/>
</Group>
But how do i create element if a column name is kind of dynamic. Please help. I cannot Rename/change the Column in SQL Query. Please let me know If I could handle this whole logic in BI Publsiher.
Regards,
Ashoka BLtry useing alias
t1.ship_city || ', ' || t1.ship_state || ' ' || t1.ship_zip as <COLUMN_ALIAS> -
Hi All,
Item with LOV defined and i wnat to dispaly the lov based on :
for Ex
if :P1_item >=1
then
select ename d, ename r from emp;
else
select deptno d, deptno r from dept;
end if;
it is not working any idea?
I am getting error
ERR-1000 Unable to determine LOV from "declare function x return varchar2 is begin if :P1_from_value >=1You need to have your LOV be based upon a function returning query..:Dynamic LOV - Function returning LOV query
Thank you,
Tony Miller
Webster, TX
Never Surrender Dreams!
JMS
If this question is answered, please mark the thread as closed and assign points where earned..
Maybe you are looking for
-
How to add a comment for each caption label present in a document?
Hello everyone, I am trying to write a script to add comments for each caption label for figure and table. How can I select a caption and use Comments object for adding a comment? I tried using AutoCaptions list for going through all captions present
-
Conversion from DATE to TIMESTAMP datatype
Hello, My issue is as follows: 1. I have one variable of type DATE, which I assign the value of SYSDATE mydatevar DATE:= SYSDATE;2. I want to find *"today"*, truncated to DAY TRUNC (mydatevar, 'DD') TRUNC function returns DATE datatype. So I will r
-
Import Manager - Convert Degree Symbol in XML
We have a situation whereby in our XML file we use the following code ° to convert to a degree symbol. So, in our XML file it would read 45° When I import this in Import Manager I get this: 45° Street Elbows In our Taxonomy
-
Leave the computer on sleep or turn it off-which is better?
Friend of mine has an intel iMac, I have an iMac PPC-G5. He told me that it's better to ALWAYS leave the computer on. Instead of doing a complete shutdown, one should log out and select sleep. The computer will last longer. Anyone got any thoughts or
-
Handler for http error code 500 is outside of app server
Hello, I am wondering if it is possible to redirect to a error page outside of app server in web.xml, this is required by our customer. For example: <error-page> <error-code> 500</error-code> <location>http://my-different-appserver/errorpage.jsp</loc